rmagick 1.9.3 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- data/ChangeLog +18 -0
- data/README.html +12 -12
- data/README.txt +10 -10
- data/configure +728 -367
- data/configure.ac +134 -69
- data/doc/comtasks.html +11 -3
- data/doc/constants.html +162 -40
- data/doc/draw.html +2 -2
- data/doc/ex/crop_resized.rb +10 -0
- data/doc/ex/get_type_metrics.rb +26 -22
- data/doc/ex/vignette.rb +19 -0
- data/doc/ilist.html +0 -5
- data/doc/image1.html +219 -49
- data/doc/image2.html +115 -47
- data/doc/image3.html +105 -23
- data/doc/imageattrs.html +4 -23
- data/doc/imusage.html +1 -1
- data/doc/index.html +8 -9
- data/doc/info.html +23 -3
- data/doc/magick.html +1 -1
- data/doc/rvg.html +1 -1
- data/doc/rvgclip.html +1 -1
- data/doc/rvggroup.html +1 -1
- data/doc/rvgimage.html +1 -1
- data/doc/rvgpattern.html +1 -1
- data/doc/rvgshape.html +1 -1
- data/doc/rvgstyle.html +1 -1
- data/doc/rvgtext.html +3 -3
- data/doc/rvgtspan.html +1 -1
- data/doc/rvgtut.html +119 -101
- data/doc/rvguse.html +1 -1
- data/doc/rvgxform.html +1 -1
- data/doc/struct.html +17 -11
- data/doc/usage.html +22 -4
- data/examples/histogram.rb +48 -12
- data/examples/spinner.rb +49 -0
- data/ext/RMagick/MANIFEST +4 -1
- data/ext/RMagick/rmagick.h +62 -33
- data/ext/RMagick/rmagick_config.h.in +28 -31
- data/ext/RMagick/rmdraw.c +14 -6
- data/ext/RMagick/rmfill.c +2 -2
- data/ext/RMagick/rmilist.c +8 -36
- data/ext/RMagick/rmimage.c +370 -97
- data/ext/RMagick/rminfo.c +6 -6
- data/ext/RMagick/rmmain.c +114 -25
- data/ext/RMagick/rmutil.c +98 -35
- data/lib/RMagick.rb +17 -2
- data/lib/rvg/clippath.rb +2 -2
- data/lib/rvg/container.rb +2 -2
- data/lib/rvg/describable.rb +2 -2
- data/lib/rvg/embellishable.rb +2 -2
- data/lib/rvg/misc.rb +3 -3
- data/lib/rvg/paint.rb +2 -2
- data/lib/rvg/pathdata.rb +2 -2
- data/lib/rvg/rvg.rb +2 -2
- data/lib/rvg/stretchable.rb +2 -2
- data/lib/rvg/stylable.rb +2 -2
- data/lib/rvg/text.rb +2 -2
- data/lib/rvg/transformable.rb +2 -2
- data/lib/rvg/units.rb +2 -2
- data/rmagick.gemspec +1 -1
- metadata +362 -353
data/doc/imageattrs.html
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
5
5
|
<head>
|
6
6
|
<meta name="generator" content=
|
7
|
-
"HTML Tidy for
|
7
|
+
"HTML Tidy for Linux/x86 (vers 1st December 2004), see www.w3.org" />
|
8
8
|
|
9
9
|
<title>RMagick: class Image (attribute methods)</title>
|
10
10
|
<meta http-equiv="Content-Type" content=
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
@@ -1200,27 +1200,8 @@ blur_image is 100% complete.
|
|
1200
1200
|
|
1201
1201
|
<h4>Returns</h4>
|
1202
1202
|
|
1203
|
-
<p>
|
1204
|
-
|
1205
|
-
<ul>
|
1206
|
-
<li>UndefinedOrientation</li>
|
1207
|
-
|
1208
|
-
<li>TopLeftOrientation</li>
|
1209
|
-
|
1210
|
-
<li>TopRightOrientation</li>
|
1211
|
-
|
1212
|
-
<li>BottomRightOrientation</li>
|
1213
|
-
|
1214
|
-
<li>BottomLeftOrientation</li>
|
1215
|
-
|
1216
|
-
<li>LeftTopOrientation</li>
|
1217
|
-
|
1218
|
-
<li>RightTopOrientation</li>
|
1219
|
-
|
1220
|
-
<li>RightBottomOrientation</li>
|
1221
|
-
|
1222
|
-
<li>LeftBottomOrientation</li>
|
1223
|
-
</ul>
|
1203
|
+
<p>An <a href=
|
1204
|
+
"constants.html#OrientationType">OrientationType</a> value.</p>
|
1224
1205
|
|
1225
1206
|
<h4>Magick API</h4>Available in ImageMagick 6.0.0.
|
1226
1207
|
|
data/doc/imusage.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/index.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<style type="text/css">
|
17
17
|
/*<![CDATA[*/
|
@@ -232,7 +232,7 @@
|
|
232
232
|
</ul>
|
233
233
|
</div>
|
234
234
|
|
235
|
-
<h2 id="
|
235
|
+
<h2 id="#introduction">Introduction</h2>
|
236
236
|
|
237
237
|
<h3>What is RMagick?</h3>
|
238
238
|
|
@@ -395,13 +395,12 @@
|
|
395
395
|
<p>For quickest results, include the RMagick, ×Magick and
|
396
396
|
Ruby version numbers, along with a thorough description of the
|
397
397
|
problem. RMagick will tell you both its version number and
|
398
|
-
×Magick's version number. Simply bring up irb and
|
399
|
-
<code>Magick::Long_version</code
|
398
|
+
×Magick's version number. Simply bring up irb and run this
|
399
|
+
command: <code>ruby -r RMagick -e "puts Magick::Long_version"</code></p>
|
400
400
|
<pre class="example" id="version">
|
401
|
-
|
402
|
-
|
403
|
-
Built
|
404
|
-
Built for ruby 1.8.1 (2003-12-25) [i686-linux]
|
401
|
+
This is RMagick 1.10.0 ($Date: 2006/01/08 00:21:58 $) Copyright (C) 2006 by Timothy P. Hunter
|
402
|
+
Built with ImageMagick 6.2.6 01/03/06 Q8 http://www.imagemagick.org
|
403
|
+
Built for ruby 1.8.3 (2005-09-21) [i686-linux]
|
405
404
|
Web page: http://rmagick.rubyforge.org
|
406
405
|
Email: rmagick@rubyforge.org
|
407
406
|
</pre>
|
@@ -438,7 +437,7 @@ Email: rmagick@rubyforge.org
|
|
438
437
|
Notices</a></h3>
|
439
438
|
|
440
439
|
<ul>
|
441
|
-
<li>RMagick is copyright ©
|
440
|
+
<li>RMagick is copyright © 2006 by Timothy P. Hunter.</li>
|
442
441
|
|
443
442
|
<li>ImageMagick is copyright © 2005 ImageMagick
|
444
443
|
Studio.</li>
|
data/doc/info.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
5
5
|
<head>
|
6
6
|
<meta name="generator" content=
|
7
|
-
"HTML Tidy for Linux/x86 (vers 1st
|
7
|
+
"HTML Tidy for Linux/x86 (vers 1st December 2004), see www.w3.org" />
|
8
8
|
|
9
9
|
<title>RMagick: class Image::Info - Optional method
|
10
10
|
arguments</title>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"text/html; charset=us-ascii" />
|
13
13
|
<meta name="GENERATOR" content="Quanta Plus" />
|
14
14
|
<meta name="Copyright" content=
|
15
|
-
"Copyright (C)
|
15
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
16
16
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
17
17
|
<script type="text/javascript" src="scripts/doc.js">
|
18
18
|
</script>
|
@@ -133,6 +133,8 @@
|
|
133
133
|
|
134
134
|
<div class="toccol">
|
135
135
|
<ul>
|
136
|
+
<li><a href="#orientation">orientation</a></li>
|
137
|
+
|
136
138
|
<li><a href="#page">page</a></li>
|
137
139
|
|
138
140
|
<li><a href="#pointsize">pointsize</a></li>
|
@@ -859,7 +861,7 @@ self.undefine("tiff", "bits-per-sample")
|
|
859
861
|
<h4>Arguments</h4>
|
860
862
|
|
861
863
|
<p>See <a href=
|
862
|
-
"http://www.imagemagick.org/
|
864
|
+
"http://www.imagemagick.org/script/formats.php">File
|
863
865
|
Formats</a>.</p>
|
864
866
|
</div>
|
865
867
|
|
@@ -1066,6 +1068,24 @@ self.undefine("tiff", "bits-per-sample")
|
|
1066
1068
|
<code>subrange</code> attribute.</p>
|
1067
1069
|
</div>
|
1068
1070
|
|
1071
|
+
<div class="sig">
|
1072
|
+
<h3 id="orientation">orientation</h3>
|
1073
|
+
|
1074
|
+
<p><span class="arg">self</span>.orientation=<span class=
|
1075
|
+
"arg">anOrientationType</span></p>
|
1076
|
+
</div>
|
1077
|
+
|
1078
|
+
<div class="desc">
|
1079
|
+
<h4>Description</h4>
|
1080
|
+
|
1081
|
+
<p>Specify the orientation of the image pixels.</p>
|
1082
|
+
|
1083
|
+
<h4>Argument</h4>
|
1084
|
+
|
1085
|
+
<p>An <a href=
|
1086
|
+
"constants.html#OrientationType">OrientationType</a> value.</p>
|
1087
|
+
</div>
|
1088
|
+
|
1069
1089
|
<div class="sig">
|
1070
1090
|
<h3 id="page">page</h3>
|
1071
1091
|
|
data/doc/magick.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvg.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvgclip.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvggroup.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvgimage.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvgpattern.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvgshape.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<link rel="stylesheet" type="text/css" href="css/ref.css" />
|
17
17
|
<script type="text/javascript" src="scripts/doc.js">
|
data/doc/rvgstyle.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvgtext.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
@@ -242,8 +242,8 @@
|
|
242
242
|
<h3 id='tspan'>tspan</h3>
|
243
243
|
|
244
244
|
<p><span class="arg">text</span>.tspan(<span class=
|
245
|
-
"arg">string</span>=
|
246
|
-
<span class="arg">y</span>=
|
245
|
+
"arg">string</span>=nil, <span class="arg">x</span>=nil,
|
246
|
+
<span class="arg">y</span>=nil) [ <span class="arg">{ |tspan|
|
247
247
|
...}</span> ] -> aTspan</p>
|
248
248
|
</div>
|
249
249
|
|
data/doc/rvgtspan.html
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"text/html; charset=us-ascii" />
|
12
12
|
<meta name="GENERATOR" content="Quanta Plus" />
|
13
13
|
<meta name="Copyright" content=
|
14
|
-
"Copyright (C)
|
14
|
+
"Copyright (C) 2006 by Timothy P. Hunter" />
|
15
15
|
<link rel="stylesheet" type="text/css" href="css/doc.css" />
|
16
16
|
<script type="text/javascript" src="scripts/doc.js">
|
17
17
|
</script>
|
data/doc/rvgtut.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
4
|
|
5
5
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
6
|
-
<!-- $Id: rvgtut.html,v 1.
|
6
|
+
<!-- $Id: rvgtut.html,v 1.7 2005/11/26 15:03:05 rmagick Exp $ -->
|
7
7
|
|
8
8
|
<head>
|
9
9
|
<meta name="generator" content=
|
@@ -62,43 +62,44 @@
|
|
62
62
|
</div>
|
63
63
|
</div>
|
64
64
|
<pre class="example">
|
65
|
-
1
|
66
|
-
2
|
65
|
+
1 require 'rvg/rvg'
|
66
|
+
2 include magick
|
67
67
|
3
|
68
|
-
4
|
68
|
+
4 RVG::dpi = 72
|
69
69
|
5
|
70
|
-
6
|
71
|
-
7
|
70
|
+
6 rvg = rvg.new(2.5.in, 2.5.in).viewbox(0,0,250,250) do |canvas|
|
71
|
+
7 canvas.background_fill = 'white'
|
72
72
|
8
|
73
|
-
9
|
74
|
-
10
|
73
|
+
9 canvas.g.translate(100, 150).rotate(-30) do |body|
|
74
|
+
10 body.styles(:fill=>'yellow', :stroke=>'black', :stroke_width=>2)
|
75
75
|
11 body.ellipse(50, 30)
|
76
|
-
12 body.rect(45, 20, -20, -10).
|
76
|
+
12 body.rect(45, 20, -20, -10).skewx(-35)
|
77
77
|
13 end
|
78
78
|
14
|
79
|
-
15 canvas.g.translate(130, 83)
|
80
|
-
16 head.
|
81
|
-
17 head.circle(
|
82
|
-
18 head.
|
83
|
-
19
|
84
|
-
20
|
85
|
-
21
|
86
|
-
22
|
87
|
-
23
|
88
|
-
24
|
89
|
-
25
|
90
|
-
26
|
91
|
-
27
|
92
|
-
28
|
93
|
-
29
|
94
|
-
30
|
95
|
-
31
|
96
|
-
32
|
97
|
-
33
|
98
|
-
34
|
99
|
-
35
|
100
|
-
36
|
101
|
-
37
|
79
|
+
15 canvas.g.translate(130, 83) do |head|
|
80
|
+
16 head.styles(:stroke=>'black', :stroke_width=>2)
|
81
|
+
17 head.circle(30).styles(:fill=>'yellow')
|
82
|
+
18 head.circle(5, 10, -5).styles(:fill=>'black')
|
83
|
+
19 head.polygon(30,0, 70,5, 30,10, 62,25, 23,20).styles(:fill=>'orange')
|
84
|
+
20 end
|
85
|
+
21
|
86
|
+
22 foot = rvg::group.new do |_foot|
|
87
|
+
23 _foot.path('m0,0 v30 l30,10 l5,-10, l-5,-10 l-30,10z').
|
88
|
+
24 styles(:stroke_width=>2, :fill=>'orange', :stroke=>'black')
|
89
|
+
25 end
|
90
|
+
26 canvas.use(foot).translate(75, 188).rotate(15)
|
91
|
+
27 canvas.use(foot).translate(100, 185).rotate(-15)
|
92
|
+
28
|
93
|
+
29 canvas.text(125, 30) do |title|
|
94
|
+
30 title.tspan("duck|").styles(:text_anchor=>'end', :font_size=>20,
|
95
|
+
31 :font_family=>'helvetica', :fill=>'black')
|
96
|
+
32 title.tspan("type").styles(:font_size=>22,
|
97
|
+
33 :font_family=>'times', :font_style=>'italic', :fill=>'red')
|
98
|
+
34 end
|
99
|
+
35 canvas.rect(249,249).styles(:stroke=>'blue', :fill=>'none')
|
100
|
+
36 end
|
101
|
+
37
|
102
|
+
38 rvg.draw.write('duck.gif')
|
102
103
|
</pre>
|
103
104
|
|
104
105
|
<h2>Summary</h2>
|
@@ -207,11 +208,11 @@
|
|
207
208
|
|
208
209
|
<h2>Lines 9-13</h2>
|
209
210
|
<pre class="example">
|
210
|
-
9
|
211
|
-
10
|
212
|
-
11
|
213
|
-
12
|
214
|
-
13
|
211
|
+
9 canvas.g.translate(100, 150).rotate(-30) do |body|
|
212
|
+
10 body.styles(:fill=>'yellow', :stroke=>'black', :stroke_width=>2)
|
213
|
+
11 body.ellipse(50, 30)
|
214
|
+
12 body.rect(45, 20, -20, -10).skewx(-35)
|
215
|
+
13 end
|
215
216
|
</pre>
|
216
217
|
|
217
218
|
<p>There's a lot going on in these few lines - seven method calls
|
@@ -227,15 +228,14 @@
|
|
227
228
|
<code>g</code> method yields if a block is present. In this
|
228
229
|
example, there is no block associated with <code>g</code>, so
|
229
230
|
<code>g</code> returns the new group. The <code>g</code> method
|
230
|
-
adds the group to the content of
|
231
|
-
container is
|
232
|
-
|
233
|
-
<code>translate</code
|
234
|
-
<code>
|
235
|
-
system transforms</em>
|
236
|
-
|
237
|
-
|
238
|
-
<p>(Okay, there <em>is</em> a block, but there are 3 method calls
|
231
|
+
adds the group to the content of its container. In this example,
|
232
|
+
the group's container is the canvas object created in line 6. The
|
233
|
+
graphic objects in the group are drawn as part of drawing the
|
234
|
+
container. The <code>translate</code> and <code>rotate</code>
|
235
|
+
chained to <code>g</code> modify the group by adding
|
236
|
+
<em>coordinate system transforms</em>.</p>
|
237
|
+
|
238
|
+
<p>(Okay, there <em>is</em> a block, but there are 2 method calls
|
239
239
|
between <code>g</code> and the block. I'll explain more
|
240
240
|
later.)</p>
|
241
241
|
|
@@ -267,7 +267,7 @@
|
|
267
267
|
"duck body" /></p>
|
268
268
|
|
269
269
|
<div style="position:absolute; left:200px;top:0">
|
270
|
-
<p><strong>The
|
270
|
+
<p><strong>The transform methods</strong></p>
|
271
271
|
|
272
272
|
<p>There are six transform methods. In addition to
|
273
273
|
<code>translate</code> and <code>rotate</code>, there's
|
@@ -286,10 +286,13 @@
|
|
286
286
|
values are, well, style values. In this example there are three
|
287
287
|
style names. The :fill style sets the fill color to 'yellow'. The
|
288
288
|
:stroke style sets the outline color to 'black'. The
|
289
|
-
:stroke_width style sets the width of the outline to 2.
|
290
|
-
|
291
|
-
|
292
|
-
|
289
|
+
:stroke_width style sets the width of the outline to 2. I want
|
290
|
+
the styles to apply to all objects within the group so in line 10
|
291
|
+
I call <code>styles</code> on the new group object.</p>
|
292
|
+
|
293
|
+
<p>The <code>styles</code> method is a real workhorse. It's
|
294
|
+
defined in almost every class in RVG and there are many other
|
295
|
+
style names in addition to these three..</p>
|
293
296
|
|
294
297
|
<h3>Basic shapes</h3>
|
295
298
|
|
@@ -309,8 +312,22 @@
|
|
309
312
|
centered on the origin. The upper-left corner of the rectangle is
|
310
313
|
slightly up and to the left of the origin.</p>
|
311
314
|
|
312
|
-
<
|
313
|
-
|
315
|
+
<div style="position:relative">
|
316
|
+
<p><img src="ex/images/duck3.gif" alt=
|
317
|
+
"default coordinate system" width="180" height="180" /></p>
|
318
|
+
|
319
|
+
<div style="position:absolute; left:200px;top:0">
|
320
|
+
<p><strong>The shape methods</strong></p>
|
321
|
+
|
322
|
+
<p>There are 7 shape methods. In addition to
|
323
|
+
<code>ellipse</code> and <code>rect</code>, there's
|
324
|
+
<code>circle</code>, <code>line</code>, <code>path</code>,
|
325
|
+
<code>polygon</code>, and <code>polyline</code>. You can also
|
326
|
+
think of text as a shape. Shapes are stroked and filled, and
|
327
|
+
can be modified by the transform methods and the
|
328
|
+
<code>styles</code> method.</p>
|
329
|
+
</div>
|
330
|
+
</div>
|
314
331
|
|
315
332
|
<h3>SkewX</h3>
|
316
333
|
|
@@ -330,27 +347,27 @@
|
|
330
347
|
<p><img src="ex/images/duck4.gif" width="180" height="180" alt=
|
331
348
|
"duck wing" /></p>
|
332
349
|
|
333
|
-
<p>That's it for the body. Let's tie up one loose end before
|
334
|
-
|
350
|
+
<p>That's it for the body. Let's tie up one loose end before
|
351
|
+
moving on. I said earlier that container constructors (such as
|
335
352
|
<code>g</code>) yield to a block if present. In this case,
|
336
|
-
though,
|
337
|
-
<code>
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
common RVG idiom. You'll see it a lot in the examples.</p>
|
353
|
+
though, the <code>translate</code> and <code>rotate</code>
|
354
|
+
methods intervene between <code>g</code> and the block. All the
|
355
|
+
transform methods yield when there is an associated block, so I
|
356
|
+
can easily chain them to a container constructor and still use a
|
357
|
+
block argument to define the graphic objects in the group. Method
|
358
|
+
chaining is a common RVG idiom. You'll see it a lot in the
|
359
|
+
examples.</p>
|
344
360
|
|
345
361
|
<p>The next group draws the head.</p>
|
346
362
|
|
347
|
-
<h2>Lines 15-
|
363
|
+
<h2>Lines 15-20</h2>
|
348
364
|
<pre class="example">
|
349
|
-
15
|
350
|
-
16
|
351
|
-
17
|
352
|
-
18
|
353
|
-
19
|
365
|
+
15 canvas.g.translate(130, 83) do |head|
|
366
|
+
16 head.styles(:stroke=>'black', :stroke_width=>2)
|
367
|
+
17 head.circle(30).styles(:fill=>'yellow')
|
368
|
+
18 head.circle(5, 10, -5).styles(:fill=>'black')
|
369
|
+
19 head.polygon(30,0, 70,5, 30,10, 62,25, 23,20).styles(:fill=>'orange')
|
370
|
+
20 end
|
354
371
|
</pre>
|
355
372
|
|
356
373
|
<p>This section is very similar to the previous one. I'm defining
|
@@ -361,14 +378,16 @@
|
|
361
378
|
<p><img src="ex/images/duck6.gif" width="180" height="180" alt=
|
362
379
|
"duck head" /></p>
|
363
380
|
|
364
|
-
<p>
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
381
|
+
<p>In line 16 I define the <code>stroke</code> and
|
382
|
+
<code>stroke_width</code> styles on the group. Styles defined on
|
383
|
+
the group propogate to shapes within the group unless you
|
384
|
+
override them. To do that, call <code>styles</code> on the
|
385
|
+
shapes. In this group each shape has its own fill color. The
|
386
|
+
yellow circle forms the head. The <code>circle</code> method
|
387
|
+
takes 3 parameters. The first parameter is the radius of the
|
388
|
+
circle. The other two parameters are the (x,y) coordinate of the
|
389
|
+
center. If omitted, as here, they default to (0,0). I use a small
|
390
|
+
black circle for the eye.</p>
|
372
391
|
|
373
392
|
<p>Last, I use the <code>polygon</code> method to draw the beak.
|
374
393
|
This method draws a polygon from a series of (x,y) coordinates.
|
@@ -380,28 +399,27 @@
|
|
380
399
|
<p><img src="ex/images/duck8.gif" width="180" height="180" alt=
|
381
400
|
"duck head final" /></p>
|
382
401
|
|
383
|
-
<h2>Lines
|
402
|
+
<h2>Lines 22-25</h2>
|
384
403
|
<pre class="example">
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
404
|
+
22 foot = rvg::group.new do |_foot|
|
405
|
+
23 _foot.path('m0,0 v30 l30,10 l5,-10, l-5,-10 l-30,10z').
|
406
|
+
24 styles(:stroke_width=>2, :fill=>'orange', :stroke=>'black')
|
407
|
+
25 end
|
389
408
|
</pre>
|
390
409
|
|
391
410
|
<p>Here I create a group by directly calling <code>new</code>
|
392
|
-
instead of calling the <code>g</code> method on a container.
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
this:</p>
|
411
|
+
instead of calling the <code>g</code> method on a container. This
|
412
|
+
creates a group object that is not contained within the canvas.
|
413
|
+
You might think of the foot as not being attached to anything,
|
414
|
+
like this:</p>
|
397
415
|
|
398
416
|
<p><img src="ex/images/duck9.gif" width="180" height="180" alt=
|
399
417
|
"duck foot" /></p>
|
400
418
|
|
401
|
-
<h2>Lines
|
419
|
+
<h2>Lines 26-27</h2>
|
402
420
|
<pre class="example">
|
403
|
-
|
404
|
-
|
421
|
+
26 canvas.use(foot).translate(75, 188).rotate(15)
|
422
|
+
27 canvas.use(foot).translate(100, 185).rotate(-15)
|
405
423
|
</pre>
|
406
424
|
|
407
425
|
<p>To add the group to the canvas I use the <code>use</code>
|
@@ -428,14 +446,14 @@
|
|
428
446
|
<p><img src="ex/images/duck12.gif" width="180" height="180" alt=
|
429
447
|
"final duck foot" /></p>
|
430
448
|
|
431
|
-
<h2>Lines
|
449
|
+
<h2>Lines 29-34</h2>
|
432
450
|
<pre class="example">
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
451
|
+
29 canvas.text(125, 30) do |title|
|
452
|
+
30 title.tspan("duck|").styles(:text_anchor=>'end', :font_size=>20,
|
453
|
+
31 :font_family=>'helvetica', :fill=>'black')
|
454
|
+
32 title.tspan("type").styles(:font_size=>22,
|
455
|
+
33 :font_family=>'times', :font_style=>'italic', :fill=>'red')
|
456
|
+
34 end
|
439
457
|
</pre>
|
440
458
|
|
441
459
|
<p>All I need now is a title for the picture. Text in RVG is a
|
@@ -461,9 +479,9 @@
|
|
461
479
|
<p><img src="ex/images/duck14.gif" width="180" height="180" alt=
|
462
480
|
"duck title" /></p>
|
463
481
|
|
464
|
-
<h2>Line
|
482
|
+
<h2>Line 35</h2>
|
465
483
|
<pre class="example">
|
466
|
-
|
484
|
+
35 canvas.rect(249,249).styles(:stroke=>'blue', :fill=>'none')
|
467
485
|
</pre>
|
468
486
|
|
469
487
|
<p>I'm almost done. All I need to do it add a blue border. (I'm
|
@@ -473,9 +491,9 @@
|
|
473
491
|
<p><img src="ex/images/duck15.gif" width="180" height="180" alt=
|
474
492
|
"duck with border" /></p>
|
475
493
|
|
476
|
-
<h2>Line
|
494
|
+
<h2>Line 38</h2>
|
477
495
|
<pre class="example">
|
478
|
-
|
496
|
+
38 rvg.draw.write('duck.gif')
|
479
497
|
</pre>
|
480
498
|
|
481
499
|
<p>The <code>draw</code> method call doesn't occupy a lot of
|