rmagick 2.16.0 → 3.0.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.

Files changed (238) hide show
  1. checksums.yaml +5 -5
  2. data/.appveyor.yml +19 -0
  3. data/.circleci/config.yml +56 -0
  4. data/.rubocop.yml +8 -335
  5. data/.rubocop_todo.yml +255 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +6 -49
  8. data/CHANGELOG.md +23 -0
  9. data/CONTRIBUTING.md +34 -0
  10. data/Gemfile +0 -6
  11. data/README.textile +11 -3
  12. data/Rakefile +23 -15
  13. data/before_install_linux.sh +12 -15
  14. data/doc/ex/InitialCoords.rb +4 -4
  15. data/doc/ex/NewCoordSys.rb +4 -4
  16. data/doc/ex/OrigCoordSys.rb +2 -2
  17. data/doc/ex/PreserveAspectRatio.rb +34 -34
  18. data/doc/ex/RotateScale.rb +7 -7
  19. data/doc/ex/Skew.rb +7 -7
  20. data/doc/ex/Use01.rb +1 -1
  21. data/doc/ex/Use02.rb +4 -4
  22. data/doc/ex/Use03.rb +2 -2
  23. data/doc/ex/ViewBox.rb +4 -4
  24. data/doc/ex/affine.rb +5 -5
  25. data/doc/ex/affine_transform.rb +3 -3
  26. data/doc/ex/arc.rb +9 -9
  27. data/doc/ex/arcpath.rb +2 -2
  28. data/doc/ex/arcs01.rb +6 -6
  29. data/doc/ex/arcs02.rb +8 -8
  30. data/doc/ex/axes.rb +11 -11
  31. data/doc/ex/baseline_shift01.rb +5 -5
  32. data/doc/ex/bilevel_channel.rb +1 -1
  33. data/doc/ex/blur_image.rb +1 -1
  34. data/doc/ex/border.rb +1 -1
  35. data/doc/ex/bounding_box.rb +11 -11
  36. data/doc/ex/cbezier1.rb +12 -12
  37. data/doc/ex/cbezier2.rb +13 -13
  38. data/doc/ex/cbezier3.rb +13 -13
  39. data/doc/ex/cbezier4.rb +13 -13
  40. data/doc/ex/cbezier5.rb +13 -13
  41. data/doc/ex/cbezier6.rb +19 -19
  42. data/doc/ex/channel.rb +2 -2
  43. data/doc/ex/chop.rb +2 -2
  44. data/doc/ex/circle.rb +7 -7
  45. data/doc/ex/circle01.rb +2 -2
  46. data/doc/ex/clip_path.rb +6 -6
  47. data/doc/ex/coalesce.rb +6 -6
  48. data/doc/ex/color_fill_to_border.rb +8 -8
  49. data/doc/ex/color_floodfill.rb +8 -8
  50. data/doc/ex/color_histogram.rb +2 -2
  51. data/doc/ex/color_reset.rb +2 -2
  52. data/doc/ex/colors.rb +4 -4
  53. data/doc/ex/compose_mask.rb +2 -2
  54. data/doc/ex/composite.rb +39 -39
  55. data/doc/ex/composite_layers.rb +1 -2
  56. data/doc/ex/contrast.rb +3 -3
  57. data/doc/ex/crop.rb +2 -2
  58. data/doc/ex/crop_with_gravity.rb +5 -5
  59. data/doc/ex/cubic01.rb +12 -12
  60. data/doc/ex/cubic02.rb +22 -22
  61. data/doc/ex/cycle_colormap.rb +3 -3
  62. data/doc/ex/dissolve.rb +0 -0
  63. data/doc/ex/drawcomp.rb +8 -9
  64. data/doc/ex/drop_shadow.rb +4 -4
  65. data/doc/ex/ellipse.rb +9 -9
  66. data/doc/ex/ellipse01.rb +3 -3
  67. data/doc/ex/enhance.rb +2 -2
  68. data/doc/ex/evenodd.rb +19 -19
  69. data/doc/ex/fill_pattern.rb +3 -3
  70. data/doc/ex/flatten_images.rb +1 -1
  71. data/doc/ex/font_styles.rb +13 -13
  72. data/doc/ex/fonts.rb +2 -6
  73. data/doc/ex/frame.rb +1 -1
  74. data/doc/ex/get_multiline_type_metrics.rb +3 -3
  75. data/doc/ex/get_pixels.rb +4 -6
  76. data/doc/ex/get_type_metrics.rb +26 -25
  77. data/doc/ex/gradientfill.rb +2 -2
  78. data/doc/ex/grav.rb +12 -12
  79. data/doc/ex/gravity.rb +14 -16
  80. data/doc/ex/group.rb +11 -11
  81. data/doc/ex/hatchfill.rb +2 -2
  82. data/doc/ex/image.rb +9 -9
  83. data/doc/ex/implode.rb +2 -2
  84. data/doc/ex/line.rb +10 -10
  85. data/doc/ex/line01.rb +7 -7
  86. data/doc/ex/mask.rb +0 -0
  87. data/doc/ex/matte_fill_to_border.rb +3 -3
  88. data/doc/ex/matte_floodfill.rb +2 -2
  89. data/doc/ex/matte_replace.rb +3 -3
  90. data/doc/ex/median_filter.rb +2 -2
  91. data/doc/ex/mono.rb +2 -2
  92. data/doc/ex/morph.rb +1 -1
  93. data/doc/ex/mosaic.rb +7 -5
  94. data/doc/ex/motion_blur.rb +1 -1
  95. data/doc/ex/negate_channel.rb +0 -0
  96. data/doc/ex/nested_rvg.rb +2 -2
  97. data/doc/ex/nonzero.rb +19 -19
  98. data/doc/ex/opacity.rb +9 -9
  99. data/doc/ex/path.rb +17 -17
  100. data/doc/ex/pattern1.rb +4 -4
  101. data/doc/ex/pattern2.rb +2 -2
  102. data/doc/ex/polaroid.rb +0 -1
  103. data/doc/ex/polygon.rb +7 -7
  104. data/doc/ex/polygon01.rb +7 -7
  105. data/doc/ex/polyline.rb +7 -7
  106. data/doc/ex/polyline01.rb +8 -8
  107. data/doc/ex/posterize.rb +0 -0
  108. data/doc/ex/qbezierpath.rb +16 -16
  109. data/doc/ex/quad01.rb +6 -6
  110. data/doc/ex/quantize-m.rb +2 -2
  111. data/doc/ex/random_threshold_channel.rb +1 -1
  112. data/doc/ex/rect01.rb +2 -2
  113. data/doc/ex/rect02.rb +3 -3
  114. data/doc/ex/rectangle.rb +6 -6
  115. data/doc/ex/reduce_noise.rb +2 -2
  116. data/doc/ex/remap.rb +0 -0
  117. data/doc/ex/resize_to_fill.rb +0 -0
  118. data/doc/ex/resize_to_fit.rb +0 -0
  119. data/doc/ex/roll.rb +1 -1
  120. data/doc/ex/rotate.rb +8 -8
  121. data/doc/ex/rotate_f.rb +1 -1
  122. data/doc/ex/roundrect.rb +6 -6
  123. data/doc/ex/rubyname.rb +4 -4
  124. data/doc/ex/rvg_clippath.rb +3 -3
  125. data/doc/ex/rvg_linecap.rb +7 -7
  126. data/doc/ex/rvg_linejoin.rb +7 -7
  127. data/doc/ex/rvg_opacity.rb +5 -5
  128. data/doc/ex/rvg_pattern.rb +8 -8
  129. data/doc/ex/rvg_stroke_dasharray.rb +2 -2
  130. data/doc/ex/sepiatone.rb +0 -0
  131. data/doc/ex/shadow.rb +6 -6
  132. data/doc/ex/shear.rb +2 -2
  133. data/doc/ex/skewx.rb +8 -8
  134. data/doc/ex/skewy.rb +9 -9
  135. data/doc/ex/smile.rb +5 -4
  136. data/doc/ex/sparse_color.rb +0 -4
  137. data/doc/ex/splice.rb +1 -1
  138. data/doc/ex/stegano.rb +4 -5
  139. data/doc/ex/stroke_dasharray.rb +10 -10
  140. data/doc/ex/stroke_fill.rb +2 -2
  141. data/doc/ex/stroke_linecap.rb +12 -12
  142. data/doc/ex/stroke_linejoin.rb +12 -12
  143. data/doc/ex/stroke_width.rb +11 -11
  144. data/doc/ex/swirl.rb +2 -2
  145. data/doc/ex/text.rb +6 -6
  146. data/doc/ex/text01.rb +4 -4
  147. data/doc/ex/text_align.rb +5 -5
  148. data/doc/ex/text_antialias.rb +2 -2
  149. data/doc/ex/text_styles.rb +8 -8
  150. data/doc/ex/text_undercolor.rb +4 -4
  151. data/doc/ex/texture_fill_to_border.rb +8 -8
  152. data/doc/ex/texture_floodfill.rb +8 -8
  153. data/doc/ex/texturefill.rb +2 -2
  154. data/doc/ex/threshold.rb +2 -2
  155. data/doc/ex/to_blob.rb +1 -1
  156. data/doc/ex/translate.rb +8 -8
  157. data/doc/ex/transparent.rb +6 -6
  158. data/doc/ex/transpose.rb +0 -0
  159. data/doc/ex/transverse.rb +0 -0
  160. data/doc/ex/tref01.rb +6 -6
  161. data/doc/ex/triangle01.rb +2 -2
  162. data/doc/ex/trim.rb +2 -2
  163. data/doc/ex/tspan01.rb +5 -5
  164. data/doc/ex/tspan02.rb +5 -5
  165. data/doc/ex/tspan03.rb +5 -5
  166. data/doc/ex/unsharp_mask.rb +3 -3
  167. data/doc/ex/viewex.rb +5 -5
  168. data/doc/ex/vignette.rb +0 -0
  169. data/doc/ex/watermark.rb +6 -6
  170. data/doc/ex/wet_floor.rb +2 -2
  171. data/doc/ex/writing_mode01.rb +12 -12
  172. data/doc/ex/writing_mode02.rb +12 -12
  173. data/examples/constitute.rb +1 -1
  174. data/examples/crop_with_gravity.rb +5 -5
  175. data/examples/demo.rb +6 -7
  176. data/examples/describe.rb +8 -10
  177. data/examples/find_similar_region.rb +3 -3
  178. data/examples/histogram.rb +192 -201
  179. data/examples/identify.rb +62 -73
  180. data/examples/image_opacity.rb +0 -1
  181. data/examples/import_export.rb +1 -1
  182. data/examples/pattern_fill.rb +3 -4
  183. data/examples/rotating_text.rb +5 -4
  184. data/examples/spinner.rb +5 -5
  185. data/examples/thumbnail.rb +3 -3
  186. data/examples/vignette.rb +5 -5
  187. data/ext/RMagick/extconf.rb +213 -230
  188. data/ext/RMagick/rmagick.c +1 -0
  189. data/ext/RMagick/rmagick.h +26 -29
  190. data/ext/RMagick/rmdraw.c +3 -38
  191. data/ext/RMagick/rmenum.c +36 -0
  192. data/ext/RMagick/rmimage.c +166 -10
  193. data/ext/RMagick/rminfo.c +7 -2
  194. data/ext/RMagick/rmkinfo.c +247 -0
  195. data/ext/RMagick/rmmain.c +96 -0
  196. data/ext/RMagick/rmutil.c +4 -0
  197. data/lib/rmagick/version.rb +3 -3
  198. data/lib/rmagick_internal.rb +226 -308
  199. data/lib/rvg/clippath.rb +2 -4
  200. data/lib/rvg/container.rb +25 -22
  201. data/lib/rvg/deep_equal.rb +11 -11
  202. data/lib/rvg/describable.rb +2 -2
  203. data/lib/rvg/embellishable.rb +60 -66
  204. data/lib/rvg/misc.rb +122 -128
  205. data/lib/rvg/pathdata.rb +15 -17
  206. data/lib/rvg/rvg.rb +41 -44
  207. data/lib/rvg/stretchable.rb +22 -28
  208. data/lib/rvg/stylable.rb +10 -10
  209. data/lib/rvg/text.rb +164 -165
  210. data/lib/rvg/transformable.rb +15 -15
  211. data/lib/rvg/units.rb +2 -2
  212. data/rmagick.gemspec +9 -33
  213. data/spec/rmagick/draw_spec.rb +5 -6
  214. data/spec/rmagick/image/blue_shift_spec.rb +1 -3
  215. data/spec/rmagick/image/channel_entropy_spec.rb +9 -0
  216. data/spec/rmagick/image/composite_spec.rb +2 -4
  217. data/spec/rmagick/image/constitute_spec.rb +2 -4
  218. data/spec/rmagick/image/dispatch_spec.rb +1 -3
  219. data/spec/rmagick/image/from_blob_spec.rb +1 -3
  220. data/spec/rmagick/image/ping_spec.rb +1 -3
  221. data/spec/rmagick/image/properties_spec.rb +0 -2
  222. data/spec/rmagick/image/read_spec.rb +28 -0
  223. data/spec/spec_helper.rb +7 -1
  224. data/spec/support/issue_200/app.rb +8 -0
  225. data/test/Image1.rb +70 -70
  226. data/test/Image2.rb +369 -361
  227. data/test/Image3.rb +64 -63
  228. data/test/ImageList1.rb +796 -792
  229. data/test/ImageList2.rb +43 -44
  230. data/test/Image_attributes.rb +26 -48
  231. data/test/Import_Export.rb +71 -77
  232. data/test/Info.rb +30 -31
  233. data/test/Magick.rb +47 -46
  234. data/test/Pixel.rb +24 -24
  235. data/test/Preview.rb +7 -6
  236. data/test/test_all_basic.rb +15 -7
  237. data/test/tmpnam_test.rb +3 -3
  238. metadata +57 -18
@@ -14,10 +14,11 @@ module Magick
14
14
  # The placement & orientation is affected by the
15
15
  # current user coordinate system.
16
16
  def brace(w, h)
17
- fail(ArgumentError, 'width must be != 0') unless w != 0
18
- fail(ArgumentError, 'height must be != 0') unless h != 0
19
- path("M0,0 Q#{w},0 #{w/2.0},#{-h/4.0} T#{w},#{-h/2.0}" \
20
- "Q0,#{-h/2.0} #{w/2.0},#{-(3.0*h/4.0)} T0,#{-h}")
17
+ raise(ArgumentError, 'width must be != 0') unless w != 0
18
+ raise(ArgumentError, 'height must be != 0') unless h != 0
19
+
20
+ path("M0,0 Q#{w},0 #{w / 2.0},#{-h / 4.0} T#{w},#{-h / 2.0}" \
21
+ "Q0,#{-h / 2.0} #{w / 2.0},#{-(3.0 * h / 4.0)} T0,#{-h}")
21
22
  end
22
23
  end
23
24
  end
@@ -53,32 +54,32 @@ gc.circle(0, 0, 0, 2)
53
54
 
54
55
  # All our lines will be medium-gray, dashed, and thin.
55
56
  gc.stroke('gray50')
56
- gc.stroke_dasharray(5,2)
57
+ gc.stroke_dasharray(5, 2)
57
58
  gc.stroke_width(1)
58
59
  gc.fill('none')
59
60
 
60
61
  # baseline
61
- gc.line(-10, 0, metrics.width+20, 0)
62
+ gc.line(-10, 0, metrics.width + 20, 0)
62
63
 
63
64
  # a vertical line through the origin
64
- gc.line(0, -metrics.descent-metrics.height-10, 0, -metrics.descent+15)
65
+ gc.line(0, -metrics.descent - metrics.height - 10, 0, -metrics.descent + 15)
65
66
 
66
67
  # descent
67
- gc.line(-10, -metrics.descent, metrics.width+20, -metrics.descent)
68
+ gc.line(-10, -metrics.descent, metrics.width + 20, -metrics.descent)
68
69
 
69
70
  # ascent
70
- gc.line(-10, -metrics.ascent, metrics.width+20, -metrics.ascent)
71
+ gc.line(-10, -metrics.ascent, metrics.width + 20, -metrics.ascent)
71
72
 
72
73
  # height
73
- gc.line(-10, -metrics.descent-metrics.height,
74
- metrics.width+10, -metrics.descent-metrics.height)
74
+ gc.line(-10, -metrics.descent - metrics.height,
75
+ metrics.width + 10, -metrics.descent - metrics.height)
75
76
 
76
77
  # width
77
- gc.line(metrics.width, -metrics.descent-metrics.height-10,
78
- metrics.width, -metrics.descent+20)
78
+ gc.line(metrics.width, -metrics.descent - metrics.height - 10,
79
+ metrics.width, -metrics.descent + 20)
79
80
 
80
81
  # max_advance
81
- gc.line(metrics.max_advance, -10, metrics.max_advance, -metrics.descent+20)
82
+ gc.line(metrics.max_advance, -10, metrics.max_advance, -metrics.descent + 20)
82
83
 
83
84
  gc.draw(canvas)
84
85
 
@@ -94,33 +95,33 @@ gc.translate(Origin_x, Origin_y)
94
95
 
95
96
  # between origin and descent
96
97
  gc.push
97
- gc.translate(metrics.width+23, 0)
98
+ gc.translate(metrics.width + 23, 0)
98
99
  gc.brace(10, metrics.descent)
99
100
  gc.pop
100
101
 
101
102
  # between origin and ascent
102
103
  gc.push
103
- gc.translate(metrics.width+23, 0)
104
+ gc.translate(metrics.width + 23, 0)
104
105
  gc.brace(10, metrics.ascent)
105
106
  gc.pop
106
107
 
107
108
  # between origin and height
108
109
  gc.push
109
- gc.translate(-13, -metrics.descent-metrics.height)
110
+ gc.translate(-13, -metrics.descent - metrics.height)
110
111
  gc.rotate(180)
111
112
  gc.brace(10, metrics.height)
112
113
  gc.pop
113
114
 
114
115
  # between origin and width
115
116
  gc.push
116
- gc.translate(metrics.width, -metrics.descent-metrics.height-10-3)
117
+ gc.translate(metrics.width, -metrics.descent - metrics.height - 10 - 3)
117
118
  gc.rotate(-90)
118
119
  gc.brace(10, metrics.width)
119
120
  gc.pop
120
121
 
121
122
  # between origin and max_advance
122
123
  gc.push
123
- gc.translate(0, -metrics.descent+15)
124
+ gc.translate(0, -metrics.descent + 15)
124
125
  gc.rotate(90)
125
126
  gc.brace(10, metrics.max_advance)
126
127
  gc.pop
@@ -130,12 +131,12 @@ gc.font_weight(Magick::NormalWeight)
130
131
  gc.font_style(Magick::NormalStyle)
131
132
  gc.stroke('none')
132
133
  gc.fill('black')
133
- gc.text(metrics.width+40, -(metrics.ascent/2)+4, 'ascent')
134
- gc.text(metrics.width+40, -(metrics.descent/2)+4, 'descent')
135
- gc.text(-60, -metrics.descent-metrics.height/2+4, 'height')
136
- gc.text((metrics.width/2)-15, -metrics.descent-metrics.height-25, 'width')
137
- gc.text((metrics.max_advance)/2-38, -metrics.descent+35, 'max_advance')
134
+ gc.text(metrics.width + 40, -(metrics.ascent / 2) + 4, 'ascent')
135
+ gc.text(metrics.width + 40, -(metrics.descent / 2) + 4, 'descent')
136
+ gc.text(-60, -metrics.descent - metrics.height / 2 + 4, 'height')
137
+ gc.text((metrics.width / 2) - 15, -metrics.descent - metrics.height - 25, 'width')
138
+ gc.text(metrics.max_advance / 2 - 38, -metrics.descent + 35, 'max_advance')
138
139
 
139
140
  gc.draw(canvas)
140
- canvas.border!(1,1,'blue')
141
+ canvas.border!(1, 1, 'blue')
141
142
  canvas.write('get_type_metrics.gif')
@@ -15,13 +15,13 @@ img = Magick::Image.new(Cols, Rows, fill)
15
15
  # Annotate the filled image with the code that created the fill.
16
16
 
17
17
  ann = Magick::Draw.new
18
- ann.annotate(img, 0,0,0,0, "GradientFill.new(0, 0, 0, #{Rows}, '#{Start}', '#{End}')") do
18
+ ann.annotate(img, 0, 0, 0, 0, "GradientFill.new(0, 0, 0, #{Rows}, '#{Start}', '#{End}')") do
19
19
  self.gravity = Magick::CenterGravity
20
20
  self.fill = 'white'
21
21
  self.stroke = 'transparent'
22
22
  self.pointsize = 14
23
23
  end
24
24
 
25
- #img.display
25
+ # img.display
26
26
  img.write('gradientfill.gif')
27
27
  exit
@@ -3,16 +3,16 @@
3
3
  require 'rmagick'
4
4
 
5
5
  imgl = Magick::ImageList.new
6
- imgl.new_image(400,200, Magick::HatchFill.new('white', 'lightcyan2'))
6
+ imgl.new_image(400, 200, Magick::HatchFill.new('white', 'lightcyan2'))
7
7
 
8
8
  gc = Magick::Draw.new
9
9
 
10
10
  # Draw blue lines to indicate positioning
11
11
  gc.stroke('blue')
12
12
  gc.fill('transparent')
13
- gc.rectangle(20,20, 380,180)
14
- gc.line(200,20, 200,180)
15
- gc.line(20,100, 380,100)
13
+ gc.rectangle(20, 20, 380, 180)
14
+ gc.line(200, 20, 200, 180)
15
+ gc.line(20, 100, 380, 100)
16
16
 
17
17
  # Draw text at all 9 compass points.
18
18
  gc.font_weight(Magick::NormalWeight)
@@ -20,26 +20,26 @@ gc.font_style(Magick::NormalStyle)
20
20
  gc.stroke('transparent')
21
21
  gc.fill('black')
22
22
  gc.gravity(Magick::NorthWestGravity)
23
- gc.text(20,20, 'NorthWestGravity')
23
+ gc.text(20, 20, 'NorthWestGravity')
24
24
  gc.gravity(Magick::NorthGravity)
25
- gc.text( 0,20, 'NorthGravity')
25
+ gc.text(0, 20, 'NorthGravity')
26
26
  gc.gravity(Magick::NorthEastGravity)
27
- gc.text(20,20, 'NorthEastGravity')
27
+ gc.text(20, 20, 'NorthEastGravity')
28
28
  gc.gravity(Magick::WestGravity)
29
29
  gc.text(20, 0, 'WestGravity')
30
30
  gc.gravity(Magick::CenterGravity)
31
- gc.text( 0, 0, 'CenterGravity')
31
+ gc.text(0, 0, 'CenterGravity')
32
32
  gc.gravity(Magick::EastGravity)
33
33
  gc.text(20, 0, 'EastGravity')
34
34
  gc.gravity(Magick::SouthWestGravity)
35
- gc.text(20,20, 'SouthWestGravity')
35
+ gc.text(20, 20, 'SouthWestGravity')
36
36
  gc.gravity(Magick::SouthGravity)
37
- gc.text( 0,20, 'SouthGravity')
37
+ gc.text(0, 20, 'SouthGravity')
38
38
  gc.gravity(Magick::SouthEastGravity)
39
- gc.text(20,20, 'SouthEastGravity')
39
+ gc.text(20, 20, 'SouthEastGravity')
40
40
  gc.draw(imgl)
41
41
 
42
- imgl.border!(1,1, 'lightcyan2')
42
+ imgl.border!(1, 1, 'lightcyan2')
43
43
 
44
44
  imgl.write('grav.gif')
45
45
  exit
@@ -9,15 +9,14 @@ x = 100
9
9
  y = 100
10
10
 
11
11
  begin
12
-
13
12
  pic = Magick::ImageList.new
14
13
 
15
14
  lines = Magick::Draw.new
16
15
  lines.stroke '#600'
17
16
  lines.fill_opacity 0
18
- lines.line 300,100, 300,500
19
- lines.line 100,300, 500,300
20
- lines.rectangle 100,100, 500,500
17
+ lines.line 300, 100, 300, 500
18
+ lines.line 100, 300, 500, 300
19
+ lines.rectangle 100, 100, 500, 500
21
20
 
22
21
  draw = Magick::Draw.new
23
22
  draw.pointsize = 30
@@ -30,49 +29,48 @@ begin
30
29
 
31
30
  lines.draw pic
32
31
 
33
- draw.annotate(pic, 0,0,x,y, 'NorthWest') do
32
+ draw.annotate(pic, 0, 0, x, y, 'NorthWest') do
34
33
  self.gravity = Magick::NorthWestGravity
35
34
  self.rotation = angle
36
35
  end
37
- draw.annotate(pic, 0,0,0,y, 'North') do
36
+ draw.annotate(pic, 0, 0, 0, y, 'North') do
38
37
  self.gravity = Magick::NorthGravity
39
38
  self.rotation = angle
40
39
  end
41
- draw.annotate(pic, 0,0,x,y, 'NorthEast') do
40
+ draw.annotate(pic, 0, 0, x, y, 'NorthEast') do
42
41
  self.gravity = Magick::NorthEastGravity
43
42
  self.rotation = angle
44
43
  end
45
- draw.annotate(pic, 0,0,x,0, 'East') do
44
+ draw.annotate(pic, 0, 0, x, 0, 'East') do
46
45
  self.gravity = Magick::EastGravity
47
46
  self.rotation = angle
48
47
  end
49
- draw.annotate(pic, 0,0,0,0, 'Center') do
48
+ draw.annotate(pic, 0, 0, 0, 0, 'Center') do
50
49
  self.gravity = Magick::CenterGravity
51
50
  self.rotation = angle
52
51
  end
53
- draw.annotate(pic, 0,0,x,y, 'SouthEast') do
52
+ draw.annotate(pic, 0, 0, x, y, 'SouthEast') do
54
53
  self.gravity = Magick::SouthEastGravity
55
54
  self.rotation = angle
56
55
  end
57
- draw.annotate(pic, 0,0,0,y, 'South') do
56
+ draw.annotate(pic, 0, 0, 0, y, 'South') do
58
57
  self.gravity = Magick::SouthGravity
59
58
  self.rotation = angle
60
59
  end
61
- draw.annotate(pic, 0,0,x,y, 'SouthWest') do
60
+ draw.annotate(pic, 0, 0, x, y, 'SouthWest') do
62
61
  self.gravity = Magick::SouthWestGravity
63
62
  self.rotation = angle
64
63
  end
65
- draw.annotate(pic, 0,0,x,0, 'West') do
64
+ draw.annotate(pic, 0, 0, x, 0, 'West') do
66
65
  self.gravity = Magick::WestGravity
67
66
  self.rotation = angle
68
67
  end
69
68
  end
70
69
 
71
- puts "Writing image \"rm_gravity_out.miff\"..."
70
+ puts 'Writing image "rm_gravity_out.miff"...'
72
71
  pic.delay = 20
73
72
  pic.write './rm_gravity_out.miff'
74
-
75
- rescue
73
+ rescue StandardError
76
74
  puts "#{$ERROR_INFO} exception raised."
77
75
  exit 1
78
76
  end
@@ -2,23 +2,23 @@ require 'rvg/rvg'
2
2
 
3
3
  Magick::RVG.dpi = 90
4
4
 
5
- rvg = Magick::RVG.new(6.cm, 4.cm).viewbox(0,0,600,400) do |canvas|
5
+ rvg = Magick::RVG.new(6.cm, 4.cm).viewbox(0, 0, 600, 400) do |canvas|
6
6
  canvas.background_fill = 'white'
7
- canvas.rect(595,395,1,1).styles(:stroke=>'blue', :fill=>'none', :stroke_width=>2)
7
+ canvas.rect(595, 395, 1, 1).styles(stroke: 'blue', fill: 'none', stroke_width: 2)
8
8
 
9
9
  # Define a stick figure.
10
- stick = Magick::RVG::Group.new.styles(:stroke=>'black', :fill=>'none', :stroke_width=>6) do |fig|
11
- fig.circle(42, 50, 50).styles(:stroke=>'red')
12
- fig.polyline(30,40, 50,40, 45,60, 50,40, 65,40).styles(:stroke_width=>4)
13
- fig.polyline(10,100, 50,130, 90,100)
14
- fig.line(50,97, 50, 155)
15
- fig.polyline(10,200, 50,155, 90,200)
10
+ stick = Magick::RVG::Group.new.styles(stroke: 'black', fill: 'none', stroke_width: 6) do |fig|
11
+ fig.circle(42, 50, 50).styles(stroke: 'red')
12
+ fig.polyline(30, 40, 50, 40, 45, 60, 50, 40, 65, 40).styles(stroke_width: 4)
13
+ fig.polyline(10, 100, 50, 130, 90, 100)
14
+ fig.line(50, 97, 50, 155)
15
+ fig.polyline(10, 200, 50, 155, 90, 200)
16
16
  end
17
17
 
18
18
  # Draw 12 copies.
19
- 2.times do|y|
20
- 6.times do|x|
21
- canvas.use(stick, x*100, y*200)
19
+ 2.times do |y|
20
+ 6.times do |x|
21
+ canvas.use(stick, x * 100, y * 200)
22
22
  end
23
23
  end
24
24
  end
@@ -16,12 +16,12 @@ img.new_image(Cols, Rows, fill)
16
16
  # Annotate the filled image with the code that created the fill.
17
17
 
18
18
  ann = Magick::Draw.new
19
- ann.annotate(img, 0,0,0,0, "HatchFill.new('#{Background}', '#{Foreground}')") do
19
+ ann.annotate(img, 0, 0, 0, 0, "HatchFill.new('#{Background}', '#{Foreground}')") do
20
20
  self.gravity = Magick::CenterGravity
21
21
  self.fill = 'black'
22
22
  self.stroke = 'transparent'
23
23
  self.pointsize = 14
24
24
  end
25
- #img.display
25
+ # img.display
26
26
  img.write('hatchfill.gif')
27
27
  exit
@@ -2,36 +2,36 @@ require 'rvg/rvg'
2
2
 
3
3
  rvg = Magick::RVG.new(525, 270) do |canvas|
4
4
  canvas.background_fill = 'white'
5
- canvas.rect(524, 269).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>1)
5
+ canvas.rect(524, 269).styles(fill: 'none', stroke: 'blue', stroke_width: 1)
6
6
 
7
7
  hat = ::Magick::Image.read('images/Flower_Hat.jpg').first
8
8
 
9
9
  canvas.image(hat, 100, 75, 25, 40).preserve_aspect_ratio('none')
10
- canvas.rect(100, 75, 25, 40).styles(:fill => 'none', :stroke => 'blue')
10
+ canvas.rect(100, 75, 25, 40).styles(fill: 'none', stroke: 'blue')
11
11
 
12
12
  canvas.image(hat, 100, 75, 150, 40).preserve_aspect_ratio('xMinYMin', 'meet')
13
- canvas.rect(100, 75, 150, 40).styles(:fill => 'none', :stroke => 'blue')
13
+ canvas.rect(100, 75, 150, 40).styles(fill: 'none', stroke: 'blue')
14
14
 
15
15
  canvas.image(hat, 100, 75, 275, 40).preserve_aspect_ratio('xMidYMid', 'meet')
16
- canvas.rect(100, 75, 275, 40).styles(:fill => 'none', :stroke => 'blue')
16
+ canvas.rect(100, 75, 275, 40).styles(fill: 'none', stroke: 'blue')
17
17
 
18
18
  canvas.image(hat, 100, 75, 400, 40).preserve_aspect_ratio('xMaxYMax', 'meet')
19
- canvas.rect(100, 75, 400, 40).styles(:fill => 'none', :stroke => 'blue')
19
+ canvas.rect(100, 75, 400, 40).styles(fill: 'none', stroke: 'blue')
20
20
 
21
21
  canvas.image(hat, 100, 75, 150, 155).preserve_aspect_ratio('xMinYMin', 'slice')
22
- canvas.rect(100, 75, 150, 155).styles(:fill => 'none', :stroke => 'blue')
22
+ canvas.rect(100, 75, 150, 155).styles(fill: 'none', stroke: 'blue')
23
23
 
24
24
  canvas.image(hat, 100, 75, 275, 155).preserve_aspect_ratio('xMidYMid', 'slice')
25
- canvas.rect(100, 75, 275, 155).styles(:fill => 'none', :stroke => 'blue')
25
+ canvas.rect(100, 75, 275, 155).styles(fill: 'none', stroke: 'blue')
26
26
 
27
27
  canvas.image(hat, 100, 75, 400, 155).preserve_aspect_ratio('xMaxYMax', 'slice')
28
- canvas.rect(100, 75, 400, 155).styles(:fill => 'none', :stroke => 'blue')
28
+ canvas.rect(100, 75, 400, 155).styles(fill: 'none', stroke: 'blue')
29
29
 
30
30
  canvas.line(150, 20, 305, 20)
31
31
  canvas.line(345, 20, 500, 20)
32
32
  canvas.line(150, 250, 305, 250)
33
33
  canvas.line(340, 250, 500, 250)
34
- canvas.g.styles(:stroke=>'none', :font_weight=>'normal', :font_style=>'normal') do |t|
34
+ canvas.g.styles(stroke: 'none', font_weight: 'normal', font_style: 'normal') do |t|
35
35
  t.text(310, 23, 'meet')
36
36
  t.text(60, 140, 'none')
37
37
  t.text(170, 140, 'xMinYMin')
@@ -14,7 +14,7 @@ frames = Magick::ImageList.new
14
14
  implosion = 0.25
15
15
  8.times do
16
16
  frames << img.implode(implosion)
17
- legend.annotate(frames, 0,0,10,20, sprintf('% 4.2f', implosion))
17
+ legend.annotate(frames, 0, 0, 10, 20, format('% 4.2f', implosion))
18
18
  frames.matte = false
19
19
  implosion -= 0.10
20
20
  end
@@ -22,7 +22,7 @@ end
22
22
  7.times do
23
23
  implosion += 0.10
24
24
  frames << img.implode(implosion)
25
- legend.annotate(frames, 0,0,10,20, sprintf('% 4.2f', implosion))
25
+ legend.annotate(frames, 0, 0, 10, 20, format('% 4.2f', implosion))
26
26
  frames.matte = false
27
27
  end
28
28
 
@@ -2,7 +2,7 @@
2
2
  require 'rmagick'
3
3
 
4
4
  imgl = Magick::ImageList.new
5
- imgl.new_image(250, 250, Magick::HatchFill.new('white','LightCyan2'))
5
+ imgl.new_image(250, 250, Magick::HatchFill.new('white', 'LightCyan2'))
6
6
 
7
7
  gc = Magick::Draw.new
8
8
 
@@ -12,30 +12,30 @@ gc.stroke_linejoin('round')
12
12
  # Make each line 2 pixels wide.
13
13
  gc.stroke('red')
14
14
  gc.stroke_width(3)
15
- gc.line(50,50, 50,200)
15
+ gc.line(50, 50, 50, 200)
16
16
  gc.stroke('blue')
17
- gc.line(50,200, 200,200)
17
+ gc.line(50, 200, 200, 200)
18
18
  gc.stroke('green')
19
- gc.line(200,200, 50,50)
19
+ gc.line(200, 200, 50, 50)
20
20
 
21
21
  # Identify the endpoints with gray circles
22
22
  gc.stroke('gray50')
23
23
  gc.stroke_width(1)
24
24
  gc.fill_opacity(0)
25
- gc.circle(50,50, 53,53)
26
- gc.circle(50,200, 53,203)
27
- gc.circle(200,200, 203,203)
25
+ gc.circle(50, 50, 53, 53)
26
+ gc.circle(50, 200, 53, 203)
27
+ gc.circle(200, 200, 203, 203)
28
28
 
29
29
  # Annotate the endpoints
30
30
  gc.font_weight(Magick::NormalWeight)
31
31
  gc.font_style(Magick::NormalStyle)
32
32
  gc.fill('black')
33
33
  gc.stroke('transparent')
34
- gc.text(30,40, "'50,50'")
35
- gc.text(30,220, "'50,200'")
34
+ gc.text(30, 40, "'50,50'")
35
+ gc.text(30, 220, "'50,200'")
36
36
  gc.text(180, 220, "'200,200'")
37
37
 
38
38
  gc.draw(imgl)
39
- imgl.border!(1,1, 'LightCyan2')
39
+ imgl.border!(1, 1, 'LightCyan2')
40
40
 
41
41
  imgl.write('line.gif')
@@ -7,14 +7,14 @@ rvg = Magick::RVG.new(12.cm, 4.cm).viewbox(0, 0, 1200, 400) do |canvas|
7
7
  canvas.desc = 'Example line01 - lines expressed in user coordinates'
8
8
 
9
9
  # Show outline of canvas using the 'rect' method
10
- canvas.rect(1195, 395, 1, 1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>2)
10
+ canvas.rect(1195, 395, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 2)
11
11
 
12
- canvas.g.styles(:stroke=>'green') do |grp|
13
- grp.line(100, 300, 300, 100).styles(:stroke_width=>5)
14
- grp.line(300, 300, 500, 100).styles(:stroke_width=>10)
15
- grp.line(500, 300, 700, 100).styles(:stroke_width=>15)
16
- grp.line(700, 300, 900, 100).styles(:stroke_width=>20)
17
- grp.line(900, 300, 1100, 100).styles(:stroke_width=>25)
12
+ canvas.g.styles(stroke: 'green') do |grp|
13
+ grp.line(100, 300, 300, 100).styles(stroke_width: 5)
14
+ grp.line(300, 300, 500, 100).styles(stroke_width: 10)
15
+ grp.line(500, 300, 700, 100).styles(stroke_width: 15)
16
+ grp.line(700, 300, 900, 100).styles(stroke_width: 20)
17
+ grp.line(900, 300, 1100, 100).styles(stroke_width: 25)
18
18
  end
19
19
  end
20
20