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
@@ -3,32 +3,32 @@ require 'rvg/rvg'
3
3
  rvg = Magick::RVG.new(400, 120) do |canvas|
4
4
  canvas.desc = 'Example RotateScale - Rotate and scale transforms'
5
5
  canvas.background_fill = 'white'
6
- canvas.g.styles(:fill=>'none', :stroke=>'black', :stroke_width=>3) do |grp|
6
+ canvas.g.styles(fill: 'none', stroke: 'black', stroke_width: 3) do |grp|
7
7
  # Draw the axes of the original coordinate system
8
8
  grp.line(0, 1.5, 400, 1.5)
9
9
  grp.line(1.5, 0, 1.5, 120)
10
10
  end
11
11
  # Establish a new coordinate system whose origin is at (50,30)
12
12
  # in the original coord. system and which is rotated by 30 degrees.
13
- canvas.g.translate(50,30) do |grp|
13
+ canvas.g.translate(50, 30) do |grp|
14
14
  grp.g.rotate(30) do |grp2|
15
- grp2.g.styles(:fill=>'none',:stroke=>'red',:stroke_width=>3) do |grp3|
15
+ grp2.g.styles(fill: 'none', stroke: 'red', stroke_width: 3) do |grp3|
16
16
  grp3.line(0, 0, 50, 0)
17
17
  grp3.line(0, 0, 0, 50)
18
18
  end
19
- grp2.text(0, 0, 'ABC (rotate)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
19
+ grp2.text(0, 0, 'ABC (rotate)').styles(font_size: 20, fill: 'blue', font_family: 'Verdana', font_weight: 'normal', font_style: 'normal')
20
20
  end
21
21
  end
22
22
 
23
23
  # Establish a new coordinate system whose origin is at (200,40)
24
24
  # in the original coord. systm and which is scaled by 1.5
25
- canvas.g.translate(200,40) do |grp|
25
+ canvas.g.translate(200, 40) do |grp|
26
26
  grp.g.scale(1.5) do |grp2|
27
- grp2.g.styles(:fill=>'none',:stroke=>'red',:stroke_width=>3) do |grp3|
27
+ grp2.g.styles(fill: 'none', stroke: 'red', stroke_width: 3) do |grp3|
28
28
  grp3.line(0, 0, 50, 0)
29
29
  grp3.line(0, 0, 0, 50)
30
30
  end
31
- grp2.text(0, 0, 'ABC (scale)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
31
+ grp2.text(0, 0, 'ABC (scale)').styles(font_size: 20, fill: 'blue', font_family: 'Verdana', font_weight: 'normal', font_style: 'normal')
32
32
  end
33
33
  end
34
34
  end
@@ -4,7 +4,7 @@ rvg = Magick::RVG.new(400, 120) do |canvas|
4
4
  canvas.desc = 'Example Skew - Show effects of skewX and skewY'
5
5
  canvas.background_fill = 'white'
6
6
 
7
- canvas.g.styles(:fill=>'none',:stroke=>'black',:stroke_width=>3) do |grp|
7
+ canvas.g.styles(fill: 'none', stroke: 'black', stroke_width: 3) do |grp|
8
8
  # Draw the axes of the original coordinate system
9
9
  grp.line(0, 1.5, 400, 1.5)
10
10
  grp.line(1.5, 0, 1.5, 120)
@@ -12,25 +12,25 @@ rvg = Magick::RVG.new(400, 120) do |canvas|
12
12
 
13
13
  # Establisha new coordinate system whose origin is at (30,30)
14
14
  # in the initial coord. system and which is skewed in X by 30 degrees.
15
- canvas.g.translate(30,30) do |grp|
15
+ canvas.g.translate(30, 30) do |grp|
16
16
  grp.skewX(30) do |grp2|
17
- grp2.g.styles(:fill=>'none', :stroke=>'red', :stroke_width=>3) do |grp3|
17
+ grp2.g.styles(fill: 'none', stroke: 'red', stroke_width: 3) do |grp3|
18
18
  grp3.line(0, 0, 50, 0)
19
19
  grp3.line(0, 0, 0, 50)
20
20
  end
21
- grp.text(0, 0, 'ABC (skewX)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
21
+ grp.text(0, 0, 'ABC (skewX)').styles(font_size: 20, fill: 'blue', font_family: 'Verdana', font_weight: 'normal', font_style: 'normal')
22
22
  end
23
23
  end
24
24
 
25
25
  # Establish a new coordinate system whose origin is at (200,30)
26
26
  # in the initial coord. system and which is skewed in Y by 30 degrees.
27
- canvas.g.translate(200,30) do |grp|
27
+ canvas.g.translate(200, 30) do |grp|
28
28
  grp.skewY(30) do |grp2|
29
- grp2.g.styles(:fill=>'none', :stroke=>'red', :stroke_width=>3) do |grp3|
29
+ grp2.g.styles(fill: 'none', stroke: 'red', stroke_width: 3) do |grp3|
30
30
  grp3.line(0, 0, 50, 0)
31
31
  grp3.line(0, 0, 0, 50)
32
32
  end
33
- grp.text(0, 0, 'ABC (skewY)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
33
+ grp.text(0, 0, 'ABC (skewY)').styles(font_size: 20, fill: 'blue', font_family: 'Verdana', font_weight: 'normal', font_style: 'normal')
34
34
  end
35
35
  end
36
36
  end
@@ -8,7 +8,7 @@ rvg = Magick::RVG.new(10.cm, 3.cm).viewbox(0, 0, 100, 30) do |canvas|
8
8
  r = Magick::RVG::Group.new do |grp|
9
9
  grp.rect(60, 10)
10
10
  end
11
- canvas.rect(99.6, 29.6, 0.1, 0.1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>0.2)
11
+ canvas.rect(99.6, 29.6, 0.1, 0.1).styles(fill: 'none', stroke: 'blue', stroke_width: 0.2)
12
12
  canvas.use(r, 20, 10)
13
13
  end
14
14
 
@@ -6,15 +6,15 @@ rvg = Magick::RVG.new(10.cm, 3.5.cm).viewbox(0, 0, 100, 35) do |canvas|
6
6
  canvas.background_fill = 'white'
7
7
  canvas.desc = "Example Use02 - Chain 'styles' to 'use'"
8
8
  r = Magick::RVG::Group.new do |grp|
9
- grp.rect(60, 10).styles(:fill=>'yellow')
9
+ grp.rect(60, 10).styles(fill: 'yellow')
10
10
  end
11
- canvas.rect(99.6, 34.6, 0.1, 0.1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>0.2)
11
+ canvas.rect(99.6, 34.6, 0.1, 0.1).styles(fill: 'none', stroke: 'blue', stroke_width: 0.2)
12
12
 
13
13
  # Since the rectangle specified the fill color the :fill style is ignored here.
14
14
  # However, since the rectangle did not specify a stroke color, the :stroke style
15
15
  # specified here is respected.
16
- canvas.use(r, 20, 5).styles(:fill=>'green', :stroke=>'red')
17
- canvas.use(r, 20, 20).styles(:fill=>'green', :stroke=>'blue')
16
+ canvas.use(r, 20, 5).styles(fill: 'green', stroke: 'red')
17
+ canvas.use(r, 20, 20).styles(fill: 'green', stroke: 'blue')
18
18
  end
19
19
 
20
20
  rvg.draw.write('Use02.gif')
@@ -9,8 +9,8 @@ rvg = Magick::RVG.new(10.cm, 3.cm).viewbox(0, 0, 100, 30) do |canvas|
9
9
  myrect = Magick::RVG::Group.new do |grp|
10
10
  grp.rect(60, 10)
11
11
  end
12
- canvas.rect(99.6, 29.6, 0.1, 0.1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>0.2)
13
- canvas.use(myrect).translate(20,2.5).rotate(10)
12
+ canvas.rect(99.6, 29.6, 0.1, 0.1).styles(fill: 'none', stroke: 'blue', stroke_width: 0.2)
13
+ canvas.use(myrect).translate(20, 2.5).rotate(10)
14
14
  end
15
15
 
16
16
  rvg.draw.write('Use03.gif')
@@ -7,7 +7,7 @@ def example(cols, rows)
7
7
  Example ViewBox - uses the viewBox attribute to automatically create an
8
8
  initial user coordinate system which causes the graphic to scale to fit
9
9
  into the viewport no matter what size the viewport is.
10
- END_DESC
10
+ END_DESC
11
11
 
12
12
  canvas.viewbox(0, 0, 1500, 1000)
13
13
  canvas.preserve_aspect_ratio('none')
@@ -16,13 +16,13 @@ def example(cols, rows)
16
16
  # Because of the viewBox attribute above,
17
17
  # the rectangle will end up filling the entire area
18
18
  # reserved for the SVG content.
19
- canvas.rect(1500, 1000).styles(:fill=>'yellow',:stroke=>'blue',:stroke_width=>12)
19
+ canvas.rect(1500, 1000).styles(fill: 'yellow', stroke: 'blue', stroke_width: 12)
20
20
 
21
21
  # A large, red triangle
22
- canvas.path('M 750,100 L 250,900 L 1250,900 z').styles(:fill=>'red')
22
+ canvas.path('M 750,100 L 250,900 L 1250,900 z').styles(fill: 'red')
23
23
 
24
24
  # A text string that spans most of the viewport
25
- canvas.text(100, 600, 'Stretch to fit').styles(:font_size=>200, :font_style=>'normal', :font_weight=>'normal', :font_family=>'Verdana')
25
+ canvas.text(100, 600, 'Stretch to fit').styles(font_size: 200, font_style: 'normal', font_weight: 'normal', font_family: 'Verdana')
26
26
  end
27
27
  rvg.draw
28
28
  end
@@ -6,7 +6,7 @@ require 'rmagick'
6
6
  # left corner.
7
7
 
8
8
  imgl = Magick::ImageList.new
9
- imgl.new_image 200, 200, Magick::HatchFill.new('white','lightcyan2')
9
+ imgl.new_image 200, 200, Magick::HatchFill.new('white', 'lightcyan2')
10
10
 
11
11
  gc = Magick::Draw.new
12
12
 
@@ -25,10 +25,10 @@ gc.fill('gray50')
25
25
  gc.stroke_width(1)
26
26
 
27
27
  # Draw up-pointing arrow.
28
- gc.polyline(10, 10, 10, max_y-10, 5, max_y-15, 15, max_y-15, 10, max_y-10)
28
+ gc.polyline(10, 10, 10, max_y - 10, 5, max_y - 15, 15, max_y - 15, 10, max_y - 10)
29
29
 
30
30
  # Draw right-pointing arrow
31
- gc.polyline(10, 10, max_x-10, 10, max_x-15, 5, max_x-15, 15, max_x-10, 10)
31
+ gc.polyline(10, 10, max_x - 10, 10, max_x - 15, 5, max_x - 15, 15, max_x - 10, 10)
32
32
 
33
33
  gc.draw(imgl)
34
34
 
@@ -38,8 +38,8 @@ text_gc = Magick::Draw.new
38
38
  text_gc.pointsize(14)
39
39
  text_gc.font_weight(Magick::NormalWeight)
40
40
  text_gc.stroke('transparent')
41
- text_gc.text(15, max_y-15, "'0,0'")
42
- text_gc.text(max_x-20, max_y-16, "'+x'")
41
+ text_gc.text(15, max_y - 15, "'0,0'")
42
+ text_gc.text(max_x - 20, max_y - 16, "'+x'")
43
43
  text_gc.text(12, 15, "'+y'")
44
44
  text_gc.draw(imgl)
45
45
 
@@ -6,15 +6,15 @@ require 'rmagick'
6
6
  img = Magick::Image.read('images/Flower_Hat.jpg').first
7
7
 
8
8
  # Construct a simple affine matrix
9
- flipflop = Magick::AffineMatrix.new(1, Math::PI/6, Math::PI/6, 1, 0, 0)
9
+ flipflop = Magick::AffineMatrix.new(1, Math::PI / 6, Math::PI / 6, 1, 0, 0)
10
10
 
11
11
  # Apply the transform
12
12
  img = img.affine_transform(flipflop)
13
13
 
14
14
  # Scale the image, make the background transparent,
15
15
  # and write it to a JPEG file.
16
- img.scale!(250.0/img.rows)
17
- img = img.matte_replace(0,0)
16
+ img.scale!(250.0 / img.rows)
17
+ img = img.matte_replace(0, 0)
18
18
  img.write('affine_transform.jpg')
19
19
 
20
20
  exit
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby -w
2
2
  require 'rmagick'
3
3
 
4
- i = Magick::Image.new(300, 220, Magick::HatchFill.new('white','lightcyan2'))
4
+ i = Magick::Image.new(300, 220, Magick::HatchFill.new('white', 'lightcyan2'))
5
5
  gc = Magick::Draw.new
6
6
 
7
7
  # Draw the border rectangle.
@@ -12,10 +12,10 @@ gc.rectangle(40, 50, 250, 180)
12
12
 
13
13
  # Draw the circles around the rectangle corners and
14
14
  # arc endpoints. All the circles have a 3-pixel radius.
15
- gc.circle(40, 50, 40+3, 50)
16
- gc.circle(250, 180, 250+3, 180)
17
- gc.circle(250, 114, 250+3, 114)
18
- gc.circle(146, 50, 146+3, 50)
15
+ gc.circle(40, 50, 40 + 3, 50)
16
+ gc.circle(250, 180, 250 + 3, 180)
17
+ gc.circle(250, 114, 250 + 3, 114)
18
+ gc.circle(146, 50, 146 + 3, 50)
19
19
 
20
20
  # Annotate
21
21
  gc.font_weight(Magick::NormalWeight)
@@ -30,7 +30,7 @@ gc.text(42, 37, '{40, 50}')
30
30
  gc.text(188, 108, '{0 degrees}')
31
31
 
32
32
  gc.gravity(Magick::SouthEastGravity)
33
- gc.text(300-250, 220-195, '{250, 180}')
33
+ gc.text(300 - 250, 220 - 195, '{250, 180}')
34
34
 
35
35
  gc.gravity(Magick::NorthGravity)
36
36
  gc.text(0, 67, '{270 degrees}')
@@ -38,12 +38,12 @@ gc.text(0, 67, '{270 degrees}')
38
38
  # Draw the arc
39
39
  gc.fill_opacity(0)
40
40
  gc.stroke('red').stroke_width(3)
41
- gc.arc(40, 50, 250,180, 0, 270)
41
+ gc.arc(40, 50, 250, 180, 0, 270)
42
42
 
43
43
  # Draw on the canvas
44
44
  gc.draw(i)
45
45
 
46
- i.border!(1,1, 'lightcyan2')
46
+ i.border!(1, 1, 'lightcyan2')
47
47
 
48
- #i.display
48
+ # i.display
49
49
  i.write('arc.gif')
@@ -4,7 +4,7 @@ require 'rmagick'
4
4
  # Demonstrate the "path" drawing primitive.
5
5
 
6
6
  imgl = Magick::ImageList.new
7
- imgl.new_image(450, 200, Magick::HatchFill.new('white','lightcyan2'))
7
+ imgl.new_image(450, 200, Magick::HatchFill.new('white', 'lightcyan2'))
8
8
 
9
9
  gc = Magick::Draw.new
10
10
 
@@ -27,6 +27,6 @@ gc.path('M200,175 l 25,-12.5 ' \
27
27
  'a12.5,50 -15 0,1 25,-12.5 l 25,-12.5')
28
28
 
29
29
  gc.draw imgl
30
- imgl.border!(1,1, 'lightcyan2')
30
+ imgl.border!(1, 1, 'lightcyan2')
31
31
 
32
32
  imgl.write('arcpath.gif')
@@ -7,22 +7,22 @@ rvg = Magick::RVG.new(12.cm, 5.25.cm).viewbox(0, 0, 1200, 400) do |canvas|
7
7
  canvas.desc = <<-END_DESC
8
8
  Picture of a pie chart with two pie wedges and a picture
9
9
  of a line with arc blips
10
- END_DESC
10
+ END_DESC
11
11
  canvas.background_fill = 'white'
12
- canvas.rect(1196, 395, 1, 1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>1)
12
+ canvas.rect(1196, 395, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 1)
13
13
 
14
14
  canvas.path('M300,200 h-150 a150,150 0 1,0 150,-150 z')
15
- .styles(:fill=>'red', :stroke=>'blue', :stroke_width=>5)
15
+ .styles(fill: 'red', stroke: 'blue', stroke_width: 5)
16
16
  canvas.path('M275,175 v-150 a150,150 0 0,0 -150,150 z')
17
- .styles(:fill=>'yellow', :stroke=>'blue', :stroke_width=>5)
17
+ .styles(fill: 'yellow', stroke: 'blue', stroke_width: 5)
18
18
  canvas.path(<<-END_PATH
19
19
  M600,350 l 50,-25
20
20
  a25,25 -30 0,1 50,-25 l 50,-25
21
21
  a25,50 -30 0,1 50,-25 l 50,-25
22
22
  a25,75 -30 0,1 50,-25 l 50,-25
23
23
  a25,100 -30 0,1 50,-25 l 50,-25
24
- END_PATH
25
- ).styles(:fill=>'none', :stroke=>'red', :stroke_width=>5)
24
+ END_PATH
25
+ ).styles(fill: 'none', stroke: 'red', stroke_width: 5)
26
26
  end
27
27
 
28
28
  rvg.draw.write('arcs01.gif')
@@ -2,16 +2,16 @@ require 'rvg/rvg'
2
2
 
3
3
  Magick::RVG.dpi = 90
4
4
 
5
- PathStyles = {:fill=>'none', :stroke=>'red', :stroke_width=>6}
6
- BaseEllipsesStyles = {:font_size=>20, :font_family=>'Verdana',:fill=>'none', :stroke=>'#888', :stroke_width=>2}
5
+ PathStyles = { fill: 'none', stroke: 'red', stroke_width: 6 }
6
+ BaseEllipsesStyles = { font_size: 20, font_family: 'Verdana', fill: 'none', stroke: '#888', stroke_width: 2 }
7
7
 
8
- rvg = Magick::RVG.new(12.cm, (5.25).cm).viewbox(0, 0, 1200, 525) do |canvas|
8
+ rvg = Magick::RVG.new(12.cm, 5.25.cm).viewbox(0, 0, 1200, 525) do |canvas|
9
9
  canvas.title = 'Example arcs02 - arc options in paths'
10
10
  canvas.desc = <<-END_DESC
11
11
  Pictures showing the result of setting
12
12
  large-arc-flag and sweep-flag to the four
13
13
  possible combinations of 0 and 1.
14
- END_DESC
14
+ END_DESC
15
15
  canvas.background_fill = 'white'
16
16
 
17
17
  base_ellipses = Magick::RVG::Group.new.styles(BaseEllipsesStyles) do |base|
@@ -21,19 +21,19 @@ rvg = Magick::RVG.new(12.cm, (5.25).cm).viewbox(0, 0, 1200, 525) do |canvas|
21
21
  base.text(225, 145, 'Arc end')
22
22
  end
23
23
 
24
- canvas.rect(1196, 522, 1, 1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>1)
24
+ canvas.rect(1196, 522, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 1)
25
25
 
26
- canvas.g.styles(:font_size=>30, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal') do |grp|
26
+ canvas.g.styles(font_size: 30, font_family: 'Verdana', font_weight: 'normal', font_style: 'normal') do |grp|
27
27
  grp.use(base_ellipses)
28
28
 
29
- grp.g.translate(400,0) do |grp2|
29
+ grp.g.translate(400, 0) do |grp2|
30
30
  grp2.text(50, 210, 'large-arc-flag=0')
31
31
  grp2.text(50, 250, 'sweep-flag=0')
32
32
  grp2.use(base_ellipses)
33
33
  grp2.path('M 125,75 a100,50 0 0,0 100,50').styles(PathStyles)
34
34
  end
35
35
 
36
- grp.g.translate(800,0) do |grp2|
36
+ grp.g.translate(800, 0) do |grp2|
37
37
  grp2.text(50, 210, 'large-arc-flag=0')
38
38
  grp2.text(50, 250, 'sweep-flag=1')
39
39
  grp2.use(base_ellipses)
@@ -14,7 +14,7 @@ canvas.new_image(250, 250, Magick::HatchFill.new('white', 'gray90'))
14
14
  border = Magick::Draw.new
15
15
  border.stroke('thistle')
16
16
  border.fill_opacity(0)
17
- border.rectangle(0,0, canvas.columns-1, canvas.rows-1)
17
+ border.rectangle(0, 0, canvas.columns - 1, canvas.rows - 1)
18
18
  border.draw(canvas)
19
19
 
20
20
  # Draw gold axes with arrow-heads.
@@ -24,9 +24,9 @@ axes.stroke('gold3')
24
24
  axes.stroke_width(4)
25
25
  axes.stroke_linecap('round')
26
26
  axes.stroke_linejoin('round')
27
- axes.polyline(18,canvas.rows-10, 10,canvas.rows-3, 3,canvas.rows-10,
28
- 10,canvas.rows-10, 10,10, canvas.columns-10,10,
29
- canvas.columns-10,3, canvas.columns-3,10, canvas.columns-10, 18)
27
+ axes.polyline(18, canvas.rows - 10, 10, canvas.rows - 3, 3, canvas.rows - 10,
28
+ 10, canvas.rows - 10, 10, 10, canvas.columns - 10, 10,
29
+ canvas.columns - 10, 3, canvas.columns - 3, 10, canvas.columns - 10, 18)
30
30
  axes.draw(canvas)
31
31
 
32
32
  # Draw a red circle to show the direction of rotation.
@@ -38,8 +38,8 @@ circle.stroke_opacity(0.75)
38
38
  circle.stroke_width(6)
39
39
  circle.stroke_linecap('round')
40
40
  circle.stroke_linejoin('round')
41
- circle.ellipse(canvas.rows/2,canvas.columns/2, 80, 80, 0, 315)
42
- circle.polyline(180,70, 173,78, 190,78, 191,62)
41
+ circle.ellipse(canvas.rows / 2, canvas.columns / 2, 80, 80, 0, 315)
42
+ circle.polyline(180, 70, 173, 78, 190, 78, 191, 62)
43
43
  circle.draw(canvas)
44
44
 
45
45
  # Label the axes and the circle.
@@ -50,15 +50,15 @@ labels.stroke('transparent')
50
50
  labels.font_style(Magick::ItalicStyle)
51
51
  labels.pointsize(14)
52
52
  labels.gravity(Magick::NorthWestGravity)
53
- labels.text(20,30, "'0,0'")
53
+ labels.text(20, 30, "'0,0'")
54
54
  labels.gravity(Magick::NorthEastGravity)
55
- labels.text(20,30, "'+x'")
55
+ labels.text(20, 30, "'+x'")
56
56
  labels.gravity(Magick::SouthWestGravity)
57
- labels.text(20,20, "'+y'")
57
+ labels.text(20, 20, "'+y'")
58
58
  labels.gravity(Magick::CenterGravity)
59
- labels.text(0,0, 'Rotation')
59
+ labels.text(0, 0, 'Rotation')
60
60
  labels.draw(canvas)
61
61
 
62
- #canvas.display
62
+ # canvas.display
63
63
  canvas.write('axes.gif')
64
64
  exit
@@ -2,16 +2,16 @@ require 'rvg/rvg'
2
2
 
3
3
  rvg = Magick::RVG.new(150, 100) do |canvas|
4
4
  canvas.background_fill = 'white'
5
- canvas.text(40, 35).styles(:font_weight=>'bold', :font_size=>28) do |txt|
5
+ canvas.text(40, 35).styles(font_weight: 'bold', font_size: 28) do |txt|
6
6
  txt.tspan('H')
7
- txt.tspan('2').styles(:font_size=>20, :fill=>'red', :baseline_shift=>'sub')
7
+ txt.tspan('2').styles(font_size: 20, fill: 'red', baseline_shift: 'sub')
8
8
  txt.tspan('O')
9
9
  end
10
- canvas.text(40, 80).styles(:font_style=>'italic', :font_size=>28) do |txt|
10
+ canvas.text(40, 80).styles(font_style: 'italic', font_size: 28) do |txt|
11
11
  txt.tspan('e=mc')
12
- txt.tspan('2').styles(:font_size=>20, :fill=>'red', :baseline_shift=>'super')
12
+ txt.tspan('2').styles(font_size: 20, fill: 'red', baseline_shift: 'super')
13
13
  end
14
- canvas.rect(149, 99).styles(:fill=>'none', :stroke=>'blue')
14
+ canvas.rect(149, 99).styles(fill: 'none', stroke: 'blue')
15
15
  end
16
16
 
17
17
  rvg.draw.write('baseline_shift01.gif')
@@ -3,6 +3,6 @@
3
3
  require 'rmagick'
4
4
 
5
5
  img = Magick::Image.read('images/Flower_Hat.jpg').first
6
- result = img.bilevel_channel(2*Magick::QuantumRange/3, Magick::RedChannel)
6
+ result = img.bilevel_channel(2 * Magick::QuantumRange / 3, Magick::RedChannel)
7
7
  result.write('bilevel_channel.jpg')
8
8
  exit
@@ -6,7 +6,7 @@ require 'rmagick'
6
6
  img = Magick::Image.read('images/Flower_Hat.jpg').first
7
7
 
8
8
  # Make a blurry copy.
9
- img = img.blur_image(0.0,2.5)
9
+ img = img.blur_image(0.0, 2.5)
10
10
 
11
11
  img.write('blur_image.jpg')
12
12
  exit
@@ -5,6 +5,6 @@ require 'rmagick'
5
5
 
6
6
  img = Magick::Image.read('images/Flower_Hat.jpg').first
7
7
 
8
- img.border!(10,10,'rgb(255,110,140)')
8
+ img.border!(10, 10, 'rgb(255,110,140)')
9
9
  img.write('border.jpg')
10
10
  exit
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby -w
2
2
  require 'rmagick'
3
3
 
4
- img = Magick::Image.new(200,200) { self.background_color = '#ffffcc' }
4
+ img = Magick::Image.new(200, 200) { self.background_color = '#ffffcc' }
5
5
 
6
6
  # Draw a blue circle.
7
7
  gc = Magick::Draw.new
8
8
  gc.stroke_width(5)
9
9
  gc.stroke('blue')
10
10
  gc.fill_opacity(0)
11
- gc.circle(100,100, 100,150)
11
+ gc.circle(100, 100, 100, 150)
12
12
  gc.draw(img)
13
13
 
14
14
  # Get the bounding box. Use the values to draw
@@ -19,22 +19,22 @@ bb = img.bounding_box
19
19
  gc = Magick::Draw.new
20
20
  gc.stroke('gray50')
21
21
  gc.fill_opacity(0)
22
- gc.rectangle(bb.x, bb.y, bb.x+bb.width, bb.y+bb.height)
22
+ gc.rectangle(bb.x, bb.y, bb.x + bb.width, bb.y + bb.height)
23
23
  gc.stroke('red')
24
- gc.circle(bb.x, bb.y, bb.x+2, bb.y+2)
25
- gc.circle(bb.x+bb.width, bb.y, bb.x+bb.width+2, bb.y+2)
26
- gc.circle(bb.x, bb.y+bb.height, bb.x+2, bb.y+bb.height+2)
27
- gc.circle(bb.x+bb.width, bb.y+bb.height, bb.x+bb.width+2, bb.y+bb.height+2)
24
+ gc.circle(bb.x, bb.y, bb.x + 2, bb.y + 2)
25
+ gc.circle(bb.x + bb.width, bb.y, bb.x + bb.width + 2, bb.y + 2)
26
+ gc.circle(bb.x, bb.y + bb.height, bb.x + 2, bb.y + bb.height + 2)
27
+ gc.circle(bb.x + bb.width, bb.y + bb.height, bb.x + bb.width + 2, bb.y + bb.height + 2)
28
28
 
29
29
  gc.fill('black')
30
30
  gc.stroke('transparent')
31
31
  gc.font_weight(Magick::NormalWeight)
32
32
  gc.font_style(Magick::NormalStyle)
33
33
  gc.pointsize(9)
34
- gc.text(bb.x-15, bb.y-5, "\'#{bb.x},#{bb.y}\'")
35
- gc.text(bb.x+bb.width-15, bb.y-5, "\'#{bb.x+bb.width},#{bb.y}\'")
36
- gc.text(bb.x-15, bb.y+bb.height+15, "\'#{bb.x},#{bb.y+bb.height}\'")
37
- gc.text(bb.x+bb.width-15, bb.y+bb.height+15, "\'#{bb.x+bb.width},#{bb.y+bb.height}\'")
34
+ gc.text(bb.x - 15, bb.y - 5, "\'#{bb.x},#{bb.y}\'")
35
+ gc.text(bb.x + bb.width - 15, bb.y - 5, "\'#{bb.x + bb.width},#{bb.y}\'")
36
+ gc.text(bb.x - 15, bb.y + bb.height + 15, "\'#{bb.x},#{bb.y + bb.height}\'")
37
+ gc.text(bb.x + bb.width - 15, bb.y + bb.height + 15, "\'#{bb.x + bb.width},#{bb.y + bb.height}\'")
38
38
 
39
39
  gc.draw(img)
40
40