-
Notifications
You must be signed in to change notification settings - Fork 138
/
rvgshape.html
406 lines (298 loc) · 11.5 KB
/
rvgshape.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
<title>RMagick 0.0.0: RVG Reference: Shapes</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<meta name="GENERATOR" content="Quanta Plus" />
<meta name="Copyright" content=
"Copyright (C) 2006 by Timothy P. Hunter" />
<link rel="stylesheet" type="text/css" href="css/doc.css" />
<link rel="stylesheet" type="text/css" href="css/ref.css" />
<script type="text/javascript" src="scripts/doc.js">
</script>
<script type="text/javascript">
//<![CDATA[
//]]>
</script>
<style type="text/css">
/*<![CDATA[*/
}
/*]]>*/
</style>
</head>
<body>
<h6 id="header">RMagick 0.0.0 User's Guide and Reference</h6>
<div class="nav">
« <a href="rvgstyle.html">Prev</a> | <a href=
"index.html">Contents</a> | <a href=
"rvgxform.html">Next</a> »
</div>
<h1>The shape methods</h1>
<div id="toc">
<h2>Table of Contents</h2>
<h3>About the shape methods</h3>
<h3>Shape methods</h3>
<div class="toccol">
<ul>
<li><a href="#circle">circle</a></li>
<li><a href="#ellipse">ellipse</a></li>
<li><a href="#line">line</a></li>
<li><a href="#path">path</a></li>
<li><a href="#polygon">polygon</a></li>
<li><a href="#polyline">polyline</a></li>
<li><a href="#rect">rect</a></li>
</ul>
</div>
</div>
<div class="subhd">
<h2>About the shape methods</h2>
</div>
<div class="intro">
<p>The shape methods listed below are defined in the <a href=
"rvg.html">RVG</a>, <a href="rvgclip.html">RVG::ClipPath</a>,
<a href="rvggroup.html">RVG::Group</a>, and <a href=
"rvgpattern.html">RVG::Pattern</a> classes. You can chain the
<a href="rvgstyle.html">styles</a> method and the <a href=
"rvgxform.html">transform methods</a> to the shape methods.</p>
</div>
<div class="subhd">
<h2>shape</h2>
</div>
<div class="sig">
<h4 id='circle'>circle</h4>
<p><span class="arg">obj</span>.circle(<span class=
"arg">radius</span>, <span class="arg">cx</span>=0,
<span class="arg">cy</span>=0) -> <em>circle</em></p>
</div>
<div class='desc'>
<h5>Description</h5>
<p>Adds a circle to the target object. The arc of a circle
begins at the "3 o'clock" point on the radius and progresses
towards the "9 o'clock" point. The starting point and direction
of the arc are affected by the user space transform in the same
manner as the geometry of the object.</p>
<h5>Arguments</h5>
<dl>
<dt>radius</dt>
<dd>The radius of the circle</dd>
<dt>cx, cy</dt>
<dd>The center of the circle</dd>
</dl>
<h5>Example</h5>
<p><a href="javascript:popup('circle01.rb.html')"><img src=
"ex/circle01.gif" title="Click to see the example script" alt=
"circle example" /></a></p>
</div>
<div class="sig">
<h4 id='ellipse'>ellipse</h4>
<p><span class="arg">obj</span>.ellipse(<span class=
"arg">rx</span>, <span class="arg">ry</span>, <span class=
"arg">cx</span>=0, <span class="arg">cy</span>=0) ->
<em>ellipse</em></p>
</div>
<div class='desc'>
<h5>Description</h5>
<p>Adds an ellipse to the target object. The arc of an ellipse
begins at the "3 o'clock" point on the radius and progresses
towards the "9 o'clock" point. The starting point and direction
of the arc are affected by the user space transform in the same
manner as the geometry of the object.</p>
<h5>Arguments</h5>
<dl>
<dt>rx, ry</dt>
<dd>The <em>x</em>- and <em>y</em>-radii of the ellipse</dd>
<dt>cx, cy</dt>
<dd>The center of the ellipse</dd>
</dl>
<h5>Example</h5>
<p><a href="javascript:popup('ellipse01.rb.html')"><img src=
"ex/ellipse01.gif" title="Click to see the example script" alt=
"ellipse example" /></a></p>
</div>
<div class="sig">
<h4 id='line'>line</h4>
<p><span class="arg">obj</span>.line(<span class=
"arg">x1</span>=0, y1=0, <span class="arg">x2</span>=0,
<span class="arg">y2</span>=0) -> <em>line</em></p>
</div>
<div class='desc'>
<h5>Description</h5>
<p>Adds a line to the target object. Lines are never
filled.</p>
<h5>Arguments</h5>
<dl>
<dt>x1, y1</dt>
<dd>The starting point of the line</dd>
<dt>x2, y2</dt>
<dd>The ending point of the line</dd>
</dl>
<h5>Example</h5>
<p><a href="javascript:popup('line01.rb.html')"><img src=
"ex/line01.gif" title="Click to see the example script" alt=
"line example" /></a></p>
</div>
<div class="sig">
<h4 id='path'>path</h4>
<p><span class="arg">obj</span>.path(<span class=
"arg">path_data</span>) -> <em>path</em></p>
</div>
<div class="desc">
<h5>Description</h5>
<p>Adds a path to the target object.</p>
<h5>Arguments</h5>
<p>A path string. The path string has the same syntax as the
<strong>d=</strong> attribute on SVG's path element. See the
<a href="http://www.w3.org/TR/SVG11/paths.html">SVG
standard</a> for a complete description of the syntax.</p>
<h5>Examples</h5>
<p>moveto, lineto, and closepath commands<a href=
"javascript:popup('triangle01.rb.html')"><img src=
"ex/triangle01.gif" title="Click to see the example script"
alt="triangle example" /></a></p>
<p>simple uses of cubic Bézier commands within a
path<a href="javascript:popup('cubic01.rb.html')"><img src=
"ex/cubic01.gif" title="Click to see the example script" alt=
"cubic Bezier commands example" /></a></p>
<p>cubic Bézier commands change their shape according to
the position of the control points<a href=
"javascript:popup('cubic02.rb.html')"><img src="ex/cubic02.gif"
title="Click to see the example script" alt=
"cubic Bezier commands example" /></a></p>
<p>simple uses of quadratic Bézier commands within a
path <a href="javascript:popup('quad01.rb.html')"><img src=
"ex/quad01.gif" title="Click to see the example script" alt=
"quadratic Bezier commands example" /></a></p>
<p>simple uses of arc commands within a path<a href=
"javascript:popup('arcs01.rb.html')"><img src="ex/arcs01.gif"
title="Click to see the example script" alt=
"arc commands example" /></a></p>
<p>Elliptical arcs: The following illustrates the four
combinations of large-arc-flag and sweep-flag and the four
different arcs that will be drawn based on the values of these
flags. <a href="javascript:popup('arcs02.rb.html')"><img src=
"ex/arcs02.gif" title="Click to see the example script" alt=
"elliptical arc example" /></a></p>
</div>
<div class="sig">
<h4 id='polygon'>polygon</h4>
<p><span class="arg">obj</span>.polygon(<span class=
"arg">x1</span>, y1, <span class="arg">x2</span>, <span class=
"arg">y2</span>...) -> <em>polygon</em><br />
<span class="arg">obj</span>.polygon(<span class=
"arg">array</span>) -> <em>polygon</em><br />
<span class="arg">obj</span>.polygon(<span class=
"arg">array1</span>, <span class="arg">array2</span>) ->
<em>polygon</em></p>
</div>
<div class="desc">
<h5>Description</h5>
<p>Adds a closed shape consisting of a series of connected line
segments to the target object.</p>
<h5>Arguments</h5>
<p>The arguments to <code>polygon</code> and <a href=
"#polyline">polyline</a> can be</p>
<ol>
<li>At least 4 numbers that describe the [x, y] coordinates
of the points of the polygon/polyline.</li>
<li>One array containing at least 4 numbers.</li>
<li>Two arrays. The first array is a list of x-coordinates.
The second array is a list of y-coordinates. Both arrays must
have at least one element. If one array is shorter than the
other, the shorter array is extended by duplicating its
elements as necessary. The combined arrays must describe at
least 2 pairs of [x,y] coordinates. For example
<pre>
x = [1, 3, 5, 7, 9]
y = [2,4]
canvas.polygon(x, y)
# is equivalent to canvas.polygon(1,2, 3,4, 5,2, 7,4, 9,2)
</pre>
</li>
</ol>
<p>It is an error to specify an odd number of coordinates.
Array arguments can be any objects that can be converted to
arrays by the Kernel#Array method.</p>
<h5>Example</h5>
<p><a href="javascript:popup('polygon01.rb.html')"><img src=
"ex/polygon01.gif" title="Click to see the example script" alt=
"polygon example" /></a></p>
</div>
<div class="sig">
<h4 id='polyline'>polyline</h4>
<p><span class="arg">obj</span>.polyline(<span class=
"arg">x1</span>, y1, <span class="arg">x2</span>, <span class=
"arg">y2</span>...) -> <em>polyline</em><br />
<span class="arg">obj</span>.polyline(<span class=
"arg">array</span>) -> <em>polyline</em><br />
<span class="arg">obj</span>.polyline(<span class=
"arg">array1</span>, <span class="arg">array2</span>) ->
<em>polyline</em></p>
</div>
<div class="desc">
<h5>Description</h5>
<p>Adds a set of connected lines segments to the target object.
Typically a polyline defines an open shape.</p>
<h5>Arguments</h5>
<p>See <a href="#polygon">polygon</a></p>
<h5>Example</h5>
<p><a href="javascript:popup('polyline01.rb.html')"><img src=
"ex/polyline01.gif" title="Click to see the example script"
alt="polyline example" /></a></p>
</div>
<div class="sig">
<h4 id='rect'>rect</h4>
<p><span class="arg">obj</span>.rect(<span class=
"arg">width</span>, <span class="arg">height</span>,
<span class="arg">x</span>=0, <span class="arg">y</span>=0)
-> <em>rect</em></p>
</div>
<div class="desc">
<h5>Description</h5>
<p>Adds a rectangle to the target object.</p>
<h5>Arguments</h5>
<dl>
<dt>width, height</dt>
<dd>The width and height of the rectangle</dd>
<dt>x, y</dt>
<dd>The <em>x</em>- and <em>y</em>-axis coordinates of the
upper-left corner</dd>
</dl>
<h5>Example</h5>
<p><a href="javascript:popup('rect01.rb.html')"><img src=
"ex/rect01.gif" title="Click to see the example script" alt=
"rect example" /></a></p>
<h5>Rounded rectangles</h5>
<p>You can define a rounded rectangle by chaining the
<code>round</code> method to <code>rect</code>:</p>
<p><span class="arg">obj</span>.rect(<span class=
"arg">width</span>, <span class="arg">height</span>,
<span class="arg">x</span>=0, <span class=
"arg">y</span>=0).round(<code>rx</code>[, <code>ry</code>])</p>
<p>The round method accepts two arguments.</p>
<dl>
<dt>rx</dt>
<dd>The x-axis radius of the ellipse used to round off the
corners of the rectangle</dd>
<dt>ry</dt>
<dd>The y-axis radius of the ellipse used to round off the
corners of the rectangle</dd>
</dl>
<p>If the second argument is omitted it defaults to the value
of the first argument.</p>
<h5>Example</h5>
<p><a href="javascript:popup('rect02.rb.html')"><img src=
"ex/rect02.gif" title="Click to see the example script" alt=
"rect example" /></a></p>
</div>
<p class="spacer"> </p>
<div class="nav">
« <a href="rvgstyle.html">Prev</a> | <a href=
"index.html">Contents</a> | <a href="rvgxform.html">Next</a>
»
</div>
</body>
</html>