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
@@ -2,13 +2,13 @@ require 'rvg/rvg'
2
2
 
3
3
  Magick::RVG.dpi = 90
4
4
 
5
- Border = { :fill=>'none', :stroke=>'blue', :stroke_width=>1 }
6
- Connect = { :fill=>'none', :stroke=>'#888888', :stroke_width=>2 }
7
- SamplePath = { :fill=>'none', :stroke=>'red', :stroke_width=>5 }
8
- EndPoint = { :fill=>'none', :stroke=>'#888888', :stroke_width=>2 }
9
- CtlPoint = { :fill=>'#888888', :stroke=>'none' }
10
- AutoCtlPoint = { :fill=>'none', :stroke=>'blue', :stroke_width=>4 }
11
- Label = { :text_anchor=>'middle', :font_size=>22, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal' }
5
+ Border = { fill: 'none', stroke: 'blue', stroke_width: 1 }
6
+ Connect = { fill: 'none', stroke: '#888888', stroke_width: 2 }
7
+ SamplePath = { fill: 'none', stroke: 'red', stroke_width: 5 }
8
+ EndPoint = { fill: 'none', stroke: '#888888', stroke_width: 2 }
9
+ CtlPoint = { fill: '#888888', stroke: 'none' }
10
+ AutoCtlPoint = { fill: 'none', stroke: 'blue', stroke_width: 4 }
11
+ Label = { text_anchor: 'middle', font_size: 22, font_family: 'Verdana', font_weight: 'normal', font_style: 'normal' }
12
12
 
13
13
  rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
14
14
  canvas.title = 'Example cubic02 - cubic Bezier commands in path data'
@@ -16,14 +16,14 @@ rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
16
16
  Picture showing examples of "C" and "S" commands,
17
17
  along with annotations showing the control points
18
18
  and end points
19
- END_DESC
19
+ END_DESC
20
20
 
21
21
  canvas.background_fill = 'white'
22
22
  canvas.rect(996, 996, 1, 1).styles(Border)
23
23
 
24
24
  # Path 1
25
- canvas.polyline(100,200, 100,100).styles(Connect)
26
- canvas.polyline(400,100, 400,200).styles(Connect)
25
+ canvas.polyline(100, 200, 100, 100).styles(Connect)
26
+ canvas.polyline(400, 100, 400, 200).styles(Connect)
27
27
  canvas.path('M100,200 C100,100 400,100 400,200').styles(SamplePath)
28
28
  canvas.circle(10, 100, 200).styles(EndPoint)
29
29
  canvas.circle(10, 400, 200).styles(EndPoint)
@@ -32,8 +32,8 @@ rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
32
32
  canvas.text(250, 275, 'M100,200 C100,100 400,100 400,200').styles(Label)
33
33
 
34
34
  # Path 2
35
- canvas.polyline(100,500, 25,400).styles(Connect)
36
- canvas.polyline(475,400, 400,500).styles(Connect)
35
+ canvas.polyline(100, 500, 25, 400).styles(Connect)
36
+ canvas.polyline(475, 400, 400, 500).styles(Connect)
37
37
  canvas.path('M100,500 C25,400 475,400 400,500').styles(SamplePath)
38
38
  canvas.circle(10, 100, 500).styles(EndPoint)
39
39
  canvas.circle(10, 400, 500).styles(EndPoint)
@@ -42,8 +42,8 @@ rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
42
42
  canvas.text(250, 575, 'M100,500 C25,400 475,400 400,500').styles(Label)
43
43
 
44
44
  # Path 3
45
- canvas.polyline(100,800, 175,700).styles(Connect)
46
- canvas.polyline(325,700, 400,800).styles(Connect)
45
+ canvas.polyline(100, 800, 175, 700).styles(Connect)
46
+ canvas.polyline(325, 700, 400, 800).styles(Connect)
47
47
  canvas.path('M100,800 C175,700 325,700 400,800').styles(SamplePath)
48
48
  canvas.circle(10, 100, 800).styles(EndPoint)
49
49
  canvas.circle(10, 400, 800).styles(EndPoint)
@@ -52,8 +52,8 @@ rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
52
52
  canvas.text(250, 875, 'M100,800 C175,700 325,700 400,800').styles(Label)
53
53
 
54
54
  # Path 4
55
- canvas.polyline(600,200, 675,100).styles(Connect)
56
- canvas.polyline(975,100, 900,200).styles(Connect)
55
+ canvas.polyline(600, 200, 675, 100).styles(Connect)
56
+ canvas.polyline(975, 100, 900, 200).styles(Connect)
57
57
  canvas.path('M600,200 C675,100 975,100 900,200').styles(SamplePath)
58
58
  canvas.circle(10, 600, 200).styles(EndPoint)
59
59
  canvas.circle(10, 900, 200).styles(EndPoint)
@@ -62,8 +62,8 @@ rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
62
62
  canvas.text(750, 275, 'M600,200 C675,100 975,100 900,200').styles(Label)
63
63
 
64
64
  # Path 5
65
- canvas.polyline(600,500, 600,350).styles(Connect)
66
- canvas.polyline(900,650, 900,500).styles(Connect)
65
+ canvas.polyline(600, 500, 600, 350).styles(Connect)
66
+ canvas.polyline(900, 650, 900, 500).styles(Connect)
67
67
  canvas.path('M600,500 C600,350 900,650 900,500').styles(SamplePath)
68
68
  canvas.circle(10, 600, 500).styles(EndPoint)
69
69
  canvas.circle(10, 900, 500).styles(EndPoint)
@@ -72,10 +72,10 @@ rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
72
72
  canvas.text(750, 575, 'M600,500 C600,350 900,650 900,500').styles(Label)
73
73
 
74
74
  # Path 6 (C and S command)
75
- canvas.polyline(600,800, 625,700).styles(Connect)
76
- canvas.polyline(725,700, 750,800).styles(Connect)
77
- canvas.polyline(750,800, 775,900).styles(Connect)
78
- canvas.polyline(875,900, 900,800).styles(Connect)
75
+ canvas.polyline(600, 800, 625, 700).styles(Connect)
76
+ canvas.polyline(725, 700, 750, 800).styles(Connect)
77
+ canvas.polyline(750, 800, 775, 900).styles(Connect)
78
+ canvas.polyline(875, 900, 900, 800).styles(Connect)
79
79
  canvas.path('M600,800 C625,700 725,700 750,800 S875,900 900,800').styles(SamplePath)
80
80
  canvas.circle(10, 600, 800).styles(EndPoint)
81
81
  canvas.circle(10, 750, 800).styles(EndPoint)
@@ -14,8 +14,8 @@ animation[0] = balloons
14
14
  5.times { animation << animation.cycle_colormap(jump) }
15
15
  4.times { animation << animation.cycle_colormap(-jump) }
16
16
 
17
- animation.delay=20
18
- animation.iterations = 10000
19
- #animation.animate
17
+ animation.delay = 20
18
+ animation.iterations = 10_000
19
+ # animation.animate
20
20
  animation.write('cycle_colormap.gif')
21
21
  exit
File without changes
@@ -5,37 +5,36 @@ require 'rmagick'
5
5
  # Read the snake image file and scale to 200 pixels high.
6
6
  begin
7
7
  snake = Magick::ImageList.new('images/Snake.wmf')
8
- snake.scale!(200.0/snake.rows)
8
+ snake.scale!(200.0 / snake.rows)
9
9
 
10
10
  # Read the coffee cup image and scale to 200 pixels high.
11
11
  coffee = Magick::ImageList.new('images/Coffee.wmf')
12
- coffee.scale!(200.0/coffee.rows)
12
+ coffee.scale!(200.0 / coffee.rows)
13
13
 
14
14
  # We want the "no" symbol to be a little smaller.
15
15
  # Read and scale to 150 pixels high.
16
16
  sign = Magick::ImageList.new('images/No.wmf')
17
- sign.scale!(150.0/sign.rows)
17
+ sign.scale!(150.0 / sign.rows)
18
18
 
19
19
  # Change the white pixels in the sign to transparent.
20
- sign = sign.matte_replace(0,0)
20
+ sign = sign.matte_replace(0, 0)
21
21
 
22
22
  # Create a "nosnake" draw object. Add a composite
23
23
  # primitive that composites the "no" symbol over
24
24
  # the snake. Draw it.
25
25
  nosnake = Magick::Draw.new
26
- nosnake.composite((snake.columns-sign.columns)/2,
27
- (snake.rows-sign.rows)/2, 0, 0, sign)
26
+ nosnake.composite((snake.columns - sign.columns) / 2,
27
+ (snake.rows - sign.rows) / 2, 0, 0, sign)
28
28
  nosnake.draw(snake)
29
29
 
30
30
  # Repeat for the coffee cup.
31
31
  nocoffee = Magick::Draw.new
32
- nocoffee.composite((coffee.columns-sign.columns)/2,
33
- (coffee.columns-sign.columns)/2, 0, 0, sign)
32
+ nocoffee.composite((coffee.columns - sign.columns) / 2,
33
+ (coffee.columns - sign.columns) / 2, 0, 0, sign)
34
34
  nocoffee.draw(coffee)
35
35
 
36
36
  coffee.write('drawcomp1.gif')
37
37
  snake.write('drawcomp2.gif')
38
-
39
38
  rescue Magick::ImageMagickError
40
39
  puts "#{$PROGRAM_NAME}: ImageMagickError - #{$ERROR_INFO}"
41
40
  end
@@ -26,7 +26,7 @@ text.stroke = 'transparent'
26
26
 
27
27
  # Draw the shadow text first. The color is a very light gray.
28
28
  # Position the text to the right and down.
29
- text.annotate(ex, 0,0,2,2, Text) do
29
+ text.annotate(ex, 0, 0, 2, 2, Text) do
30
30
  self.fill = 'gray60'
31
31
  end
32
32
 
@@ -34,12 +34,12 @@ end
34
34
  anim << ex.copy
35
35
 
36
36
  # Blur the shadow. Save a copy of the image as the 2nd frame.
37
- ex = ex.blur_image(0,3)
37
+ ex = ex.blur_image(0, 3)
38
38
  anim << ex.copy
39
39
 
40
40
  # Add the foreground text in solid black. Position it
41
41
  # to the left and up from the shadow text.
42
- text.annotate(ex, 0,0,-1,-1, Text) do
42
+ text.annotate(ex, 0, 0, -1, -1, Text) do
43
43
  self.fill = 'maroon'
44
44
  end
45
45
 
@@ -55,6 +55,6 @@ anim.cur_image.delay = 300
55
55
  # Iterate forever.
56
56
  anim.iterations = 0
57
57
 
58
- #anim.animate
58
+ # anim.animate
59
59
  anim.write('drop_shadow.gif')
60
60
  exit
@@ -2,7 +2,7 @@
2
2
  require 'rmagick'
3
3
 
4
4
  imgl = Magick::ImageList.new
5
- imgl.new_image(360, 250, Magick::HatchFill.new('white','LightCyan2'))
5
+ imgl.new_image(360, 250, Magick::HatchFill.new('white', 'LightCyan2'))
6
6
 
7
7
  gc = Magick::Draw.new
8
8
 
@@ -10,36 +10,36 @@ gc.fill_opacity(0)
10
10
  gc.stroke('red').stroke_width(3)
11
11
 
12
12
  # Draw ellipse
13
- gc.ellipse(180,125, 150,75, 0, 270)
13
+ gc.ellipse(180, 125, 150, 75, 0, 270)
14
14
 
15
15
  # Draw horizontal width line
16
16
  gc.stroke('gray50').stroke_width(1)
17
- gc.line(180-150, 125, 180, 125)
17
+ gc.line(180 - 150, 125, 180, 125)
18
18
 
19
19
  # Draw vertical height line
20
- gc.line(180, 125-75, 180, 125)
20
+ gc.line(180, 125 - 75, 180, 125)
21
21
  gc.fill_opacity(0)
22
22
 
23
23
  # Draw arcStart circle
24
- gc.circle(180+150, 125, 180+150+3, 125+3)
24
+ gc.circle(180 + 150, 125, 180 + 150 + 3, 125 + 3)
25
25
 
26
26
  # Draw arcEnd circle
27
- gc.circle(180, 125-75, 180+3, 125-75+3)
27
+ gc.circle(180, 125 - 75, 180 + 3, 125 - 75 + 3)
28
28
 
29
29
  # Annotate
30
30
  gc.font_weight(Magick::NormalWeight)
31
31
  gc.font_style(Magick::NormalStyle)
32
32
  gc.fill_opacity(1)
33
- gc.circle(180,125, 183,128)
33
+ gc.circle(180, 125, 183, 128)
34
34
  gc.fill('black')
35
35
  gc.stroke('transparent')
36
- gc.text(187,125, "'180,125'")
36
+ gc.text(187, 125, "'180,125'")
37
37
  gc.text(253, 118, "'Start 0 degrees'")
38
38
  gc.text(187, 50, "'End 270 degrees'")
39
39
  gc.text(120, 100, "'Height=75'")
40
40
  gc.text(85, 140, "'Width=150'")
41
41
  gc.draw(imgl)
42
42
 
43
- imgl.border!(1,1, 'LightCyan2')
43
+ imgl.border!(1, 1, 'LightCyan2')
44
44
 
45
45
  imgl.write('ellipse.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 ellipse01 - examples of ellipses'
8
8
 
9
9
  # Show outline of canvas using 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
12
  canvas.g.translate(300, 200) do |grp|
13
- grp.ellipse(250, 100).styles(:fill=>'red')
13
+ grp.ellipse(250, 100).styles(fill: 'red')
14
14
  end
15
15
 
16
16
  canvas.g.translate(900, 200).rotate(-30) do |grp|
17
- grp.ellipse(250, 100).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>20)
17
+ grp.ellipse(250, 100).styles(fill: 'none', stroke: 'blue', stroke_width: 20)
18
18
  end
19
19
  end
20
20
 
@@ -13,12 +13,12 @@ img.resize!(3)
13
13
  eimg.resize!(3)
14
14
 
15
15
  # Make a before-and-after composite
16
- eimg.crop!(Magick::EastGravity, eimg.columns/2, eimg.rows)
16
+ eimg.crop!(Magick::EastGravity, eimg.columns / 2, eimg.rows)
17
17
  img = img.composite(eimg, Magick::EastGravity, Magick::OverCompositeOp)
18
18
 
19
19
  # Draw a black line between the before and after parts.
20
20
  line = Magick::Draw.new
21
- line.line(img.columns/2, 0, img.columns/2, img.rows)
21
+ line.line(img.columns / 2, 0, img.columns / 2, img.rows)
22
22
  line.draw(img)
23
23
 
24
24
  # Crop everything but the face.
@@ -7,35 +7,35 @@ rvg = Magick::RVG.new(12.cm, 4.cm).viewbox(0, 0, 1200, 400) do |canvas|
7
7
  canvas.background_fill = 'white'
8
8
  canvas.desc = "Example fillrule - nonzero - demonstrates fill_rule=>'nonzero'"
9
9
 
10
- canvas.rect(1195, 393, 1, 1).styles(:fill=>'none', :stroke=>'blue')
10
+ canvas.rect(1195, 393, 1, 1).styles(fill: 'none', stroke: 'blue')
11
11
 
12
12
  triangle = Magick::RVG::Group.new do |defs|
13
- defs.path('M 16,0 L -8,9 v-18 z').styles(:fill=>'black', :stroke=>'none')
13
+ defs.path('M 16,0 L -8,9 v-18 z').styles(fill: 'black', stroke: 'none')
14
14
  end
15
15
 
16
- canvas.g.styles(:clip_rule=>'evenodd', :fill=>'red', :stroke=>'black', :stroke_width=>3) do |grp|
16
+ canvas.g.styles(clip_rule: 'evenodd', fill: 'red', stroke: 'black', stroke_width: 3) do |grp|
17
17
  grp.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
18
18
  grp.use(triangle).translate(306.21, 249).rotate(72)
19
- grp.use(triangle).translate(175.16,193.2).rotate(216)
20
- grp.use(triangle).translate(314.26,161).rotate(0)
21
- grp.use(triangle).translate(221.16,268.8).rotate(144)
22
- grp.use(triangle).translate(233.21,126.98).rotate(288)
19
+ grp.use(triangle).translate(175.16, 193.2).rotate(216)
20
+ grp.use(triangle).translate(314.26, 161).rotate(0)
21
+ grp.use(triangle).translate(221.16, 268.8).rotate(144)
22
+ grp.use(triangle).translate(233.21, 126.98).rotate(288)
23
23
  grp.path('M 600,81 A 107,107 0 0,1 600,295 A 107,107 0 0,1 600,81 z' \
24
24
  'M 600,139 A 49,49 0 0,1 600,237 A 49,49 0 0,1 600,139 z')
25
- grp.use(triangle).translate(600,188).rotate(0).translate(107,0).rotate(90)
26
- grp.use(triangle).translate(600,188).rotate(120).translate(107,0).rotate(90)
27
- grp.use(triangle).translate(600,188).rotate(240).translate(107,0).rotate(90)
28
- grp.use(triangle).translate(600,188).rotate(60).translate(49,0).rotate(90)
29
- grp.use(triangle).translate(600,188).rotate(180).translate(49,0).rotate(90)
30
- grp.use(triangle).translate(600,188).rotate(300).translate(49,0).rotate(90)
25
+ grp.use(triangle).translate(600, 188).rotate(0).translate(107, 0).rotate(90)
26
+ grp.use(triangle).translate(600, 188).rotate(120).translate(107, 0).rotate(90)
27
+ grp.use(triangle).translate(600, 188).rotate(240).translate(107, 0).rotate(90)
28
+ grp.use(triangle).translate(600, 188).rotate(60).translate(49, 0).rotate(90)
29
+ grp.use(triangle).translate(600, 188).rotate(180).translate(49, 0).rotate(90)
30
+ grp.use(triangle).translate(600, 188).rotate(300).translate(49, 0).rotate(90)
31
31
  grp.path('M 950,81 A 107,107 0 0,1 950,295 A 107,107 0 0,1 950,81 z' \
32
32
  'M 950,139 A 49,49 0 0,0 950,237 A 49,49 0 0,0 950,139 z')
33
- grp.use(triangle).translate(950,188).rotate(0).translate(107,0).rotate(90)
34
- grp.use(triangle).translate(950,188).rotate(120).translate(107,0).rotate(90)
35
- grp.use(triangle).translate(950,188).rotate(240).translate(107,0).rotate(90)
36
- grp.use(triangle).translate(950,188).rotate(60).translate(49,0).rotate(-90)
37
- grp.use(triangle).translate(950,188).rotate(180).translate(49,0).rotate(-90)
38
- grp.use(triangle).translate(950,188).rotate(300).translate(49,0).rotate(-90)
33
+ grp.use(triangle).translate(950, 188).rotate(0).translate(107, 0).rotate(90)
34
+ grp.use(triangle).translate(950, 188).rotate(120).translate(107, 0).rotate(90)
35
+ grp.use(triangle).translate(950, 188).rotate(240).translate(107, 0).rotate(90)
36
+ grp.use(triangle).translate(950, 188).rotate(60).translate(49, 0).rotate(-90)
37
+ grp.use(triangle).translate(950, 188).rotate(180).translate(49, 0).rotate(-90)
38
+ grp.use(triangle).translate(950, 188).rotate(300).translate(49, 0).rotate(-90)
39
39
  end
40
40
  end
41
41
 
@@ -4,11 +4,11 @@ require 'rmagick'
4
4
  # Demonstrate the Magick::Draw#fill_pattern and #stroke_pattern attributes.
5
5
 
6
6
  temp = Magick::ImageList.new
7
- temp << Magick::Image.new(5, 10) {self.background_color = 'black'}
8
- temp << Magick::Image.new(5, 10) {self.background_color = 'gold'}
7
+ temp << Magick::Image.new(5, 10) { self.background_color = 'black' }
8
+ temp << Magick::Image.new(5, 10) { self.background_color = 'gold' }
9
9
  stroke_pattern = temp.append(false)
10
10
 
11
- img = Magick::Image.new(280, 250) {self.background_color = 'none'}
11
+ img = Magick::Image.new(280, 250) { self.background_color = 'none' }
12
12
 
13
13
  gc = Magick::Draw.new
14
14
  gc.annotate(img, 0, 0, 0, 0, "PATT\nERNS") do
@@ -9,7 +9,7 @@ RMagick = 'RMagick'
9
9
  i = Magick::ImageList.new
10
10
 
11
11
  # Create a background image with a gradient fill
12
- i.new_image(200, 100, Magick::GradientFill.new(100,50, 100, 50, 'khaki1', 'turquoise'))
12
+ i.new_image(200, 100, Magick::GradientFill.new(100, 50, 100, 50, 'khaki1', 'turquoise'))
13
13
 
14
14
  # Create a transparent image for the text shadow
15
15
  i.new_image(200, 100) { self.background_color = 'transparent' }
@@ -5,28 +5,28 @@ rvg = Magick::RVG.new(200, 250) do |canvas|
5
5
  canvas.background_fill = 'white'
6
6
 
7
7
  canvas.g do |grp|
8
- grp.g.styles(:font_weight=>'normal', :font_style=>'normal') do |grp2|
8
+ grp.g.styles(font_weight: 'normal', font_style: 'normal') do |grp2|
9
9
  grp2.text(10, 30, 'default size')
10
- grp2.text(10, 50, ':font_size=>14').styles(:font_size=>14)
11
- grp2.text(10, 70, ':font_size=>16').styles(:font_size=>16)
12
- grp2.text(10,100, ':font_size=>24').styles(:font_size=>24)
10
+ grp2.text(10, 50, ':font_size=>14').styles(font_size: 14)
11
+ grp2.text(10, 70, ':font_size=>16').styles(font_size: 16)
12
+ grp2.text(10, 100, ':font_size=>24').styles(font_size: 24)
13
13
  end
14
14
  end
15
15
 
16
- canvas.g.styles(:font_size=>14, :font_weight=>'normal', :font_style=>'normal') do |grp|
16
+ canvas.g.styles(font_size: 14, font_weight: 'normal', font_style: 'normal') do |grp|
17
17
  if RUBY_PLATFORM =~ /mswin32/
18
- grp.text( 8, 120, ":font_family=>'Courier-New'").styles(:font_family=>'Courier-New')
18
+ grp.text(8, 120, ":font_family=>'Courier-New'").styles(font_family: 'Courier-New')
19
19
  else
20
- grp.text( 8, 120, ":font_family=>'Courier'").styles(:font_family=>'Courier')
20
+ grp.text(8, 120, ":font_family=>'Courier'").styles(font_family: 'Courier')
21
21
  end
22
- grp.text(10, 140, ":font_weight=>'bold'").styles(:font_weight=>'bold')
23
- grp.text(10, 160, ":font_stretch=>'normal'").styles(:font_stretch=>'normal')
24
- grp.text(10, 180, ":font_stretch=>'condensed'").styles(:font_stretch=>'condensed')
25
- grp.text(10, 200, ":font_style=>'italic'").styles(:font_style=>'italic')
26
- grp.text(10, 220, ':font_weight=>900').styles(:font_weight=>900)
22
+ grp.text(10, 140, ":font_weight=>'bold'").styles(font_weight: 'bold')
23
+ grp.text(10, 160, ":font_stretch=>'normal'").styles(font_stretch: 'normal')
24
+ grp.text(10, 180, ":font_stretch=>'condensed'").styles(font_stretch: 'condensed')
25
+ grp.text(10, 200, ":font_style=>'italic'").styles(font_style: 'italic')
26
+ grp.text(10, 220, ':font_weight=>900').styles(font_weight: 900)
27
27
  end
28
28
 
29
- canvas.rect(199, 249).styles(:fill=>'none', :stroke=>'blue')
29
+ canvas.rect(199, 249).styles(fill: 'none', stroke: 'blue')
30
30
  end
31
31
 
32
32
  rvg.draw.write('font_styles.gif')
@@ -5,12 +5,8 @@ require 'rmagick'
5
5
  name_length = 0
6
6
  family_length = 0
7
7
  Magick.fonts do |font|
8
- if font.name.length > name_length
9
- name_length = font.name.length
10
- end
11
- if font.family.length > family_length
12
- family_length = font.family.length
13
- end
8
+ name_length = font.name.length if font.name.length > name_length
9
+ family_length = font.family.length if font.family.length > family_length
14
10
  end
15
11
 
16
12
  # Print all fonts
@@ -5,7 +5,7 @@ require 'rmagick'
5
5
 
6
6
  img = Magick::Image.read('images/Flower_Hat.jpg').first
7
7
 
8
- img.matte_color='gray75'
8
+ img.matte_color = 'gray75'
9
9
  img = img.frame
10
10
 
11
11
  img.write('frame.jpg')
@@ -28,14 +28,14 @@ gc.stroke_width(5)
28
28
  gc.stroke_linejoin('round')
29
29
  gc.fill('cyan')
30
30
  gc.fill_opacity(0.10)
31
- gc.rectangle(x, y, x+metrics.width, y+metrics.height)
31
+ gc.rectangle(x, y, x + metrics.width, y + metrics.height)
32
32
 
33
33
  gc.stroke('white')
34
34
  gc.stroke_width(1)
35
35
  gc.fill('none')
36
- gc.rectangle(x, y, x+metrics.width, y+metrics.height)
36
+ gc.rectangle(x, y, x + metrics.width, y + metrics.height)
37
37
  gc.draw(background)
38
38
 
39
- background.border!(1,1, 'blue')
39
+ background.border!(1, 1, 'blue')
40
40
 
41
41
  background.write('get_multiline_type_metrics.gif')
@@ -8,7 +8,7 @@ require 'rmagick'
8
8
  # Read the colorful picture of a rock formation. Scale
9
9
  # it to 300 pixels high because we don't want a big picture.
10
10
  rocks = Magick::Image.read('images/Red_Rocks.jpg').first
11
- rocks.scale!(250.0/rocks.rows)
11
+ rocks.scale!(250.0 / rocks.rows)
12
12
 
13
13
  # Make a monochrome copy. See Image#quantize for details
14
14
  grayrocks = rocks.quantize(256, Magick::GRAYColorspace)
@@ -25,9 +25,7 @@ step = Magick::TransparentOpacity / cols.to_f
25
25
  opacity_steps = Array.new(cols)
26
26
  cols.times do |x|
27
27
  opacity_steps[x] = Magick::TransparentOpacity - Integer(x * step)
28
- if opacity_steps[x] < Magick::OpaqueOpacity
29
- opacity_steps[x] = Magick::OpaqueOpacity
30
- end
28
+ opacity_steps[x] = Magick::OpaqueOpacity if opacity_steps[x] < Magick::OpaqueOpacity
31
29
  end
32
30
 
33
31
  # Get each row of pixels from the mono image.
@@ -35,13 +33,13 @@ end
35
33
  # Store the pixels back.
36
34
  rows.times do |y|
37
35
  pixels = grayrocks.get_pixels(0, y, cols, 1)
38
- pixels.each_with_index { |p,x| p.opacity = opacity_steps[x] }
36
+ pixels.each_with_index { |p, x| p.opacity = opacity_steps[x] }
39
37
  grayrocks.store_pixels(0, y, cols, 1, pixels)
40
38
  end
41
39
 
42
40
  # Composite the mono version of the image over the color version.
43
41
  grayrocks.matte = true
44
42
  combine = rocks.composite(grayrocks, Magick::CenterGravity, Magick::OverCompositeOp)
45
- #combine.display
43
+ # combine.display
46
44
  combine.write 'get_pixels.jpg'
47
45
  exit