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
@@ -7,15 +7,15 @@ rvg = Magick::RVG.new(12.cm, 4.cm).viewbox(0, 0, 1200, 400) do |canvas|
7
7
  canvas.desc = 'Example polyline01 - increasingly larger bars'
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.polyline(50,375,
13
- 150,375,150,325,250,325,250,375,
14
- 350,375,350,250,450,250,450,375,
15
- 550,375,550,175,650,175,650,375,
16
- 750,375,750,100,850,100,850,375,
17
- 950,375,950,25,1050,25,1050,375,
18
- 1150,375).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>10)
12
+ canvas.polyline(50, 375,
13
+ 150, 375, 150, 325, 250, 325, 250, 375,
14
+ 350, 375, 350, 250, 450, 250, 450, 375,
15
+ 550, 375, 550, 175, 650, 175, 650, 375,
16
+ 750, 375, 750, 100, 850, 100, 850, 375,
17
+ 950, 375, 950, 25, 1050, 25, 1050, 375,
18
+ 1150, 375).styles(fill: 'none', stroke: 'blue', stroke_width: 10)
19
19
  end
20
20
 
21
21
  rvg.draw.write('polyline01.gif')
File without changes
@@ -2,7 +2,7 @@
2
2
  require 'rmagick'
3
3
 
4
4
  imgl = Magick::ImageList.new
5
- imgl.new_image(500, 300, Magick::HatchFill.new('white','lightcyan2'))
5
+ imgl.new_image(500, 300, Magick::HatchFill.new('white', 'lightcyan2'))
6
6
 
7
7
  gc = Magick::Draw.new
8
8
 
@@ -17,36 +17,36 @@ gc.path 'M20,150 Q120,25 220,150 T420,150'
17
17
  gc.fill_opacity 1
18
18
  gc.stroke 'grey50'
19
19
  gc.stroke_width 1
20
- gc.circle 20,150, 23, 153
21
- gc.circle 220,150, 223, 153
22
- gc.circle 420,150, 423, 153
20
+ gc.circle 20, 150, 23, 153
21
+ gc.circle 220, 150, 223, 153
22
+ gc.circle 420, 150, 423, 153
23
23
 
24
24
  # Show control points
25
25
  gc.fill 'black'
26
26
  gc.stroke 'transparent'
27
- gc.circle 120,25, 123, 28
28
- gc.circle 320,275, 323, 278
27
+ gc.circle 120, 25, 123, 28
28
+ gc.circle 320, 275, 323, 278
29
29
 
30
30
  # Show connector lines
31
- gc.line 20,150, 120,25
32
- gc.line 120,25, 320,275
33
- gc.line 320,275, 420,150
31
+ gc.line 20, 150, 120, 25
32
+ gc.line 120, 25, 320, 275
33
+ gc.line 320, 275, 420, 150
34
34
 
35
35
  # Add labels
36
36
  gc.font_weight Magick::NormalWeight
37
37
  gc.font_style Magick::NormalStyle
38
38
 
39
39
  # Add end point labels
40
- gc.text 30,155, "'20,150'"
41
- gc.text 230,155, "'220,150'"
42
- gc.text 430,155, "'420,150'"
40
+ gc.text 30, 155, "'20,150'"
41
+ gc.text 230, 155, "'220,150'"
42
+ gc.text 430, 155, "'420,150'"
43
43
 
44
44
  # Add control point labels
45
- gc.text 130,30, "'120,25'"
46
- gc.text 330,280, "'320,275'"
45
+ gc.text 130, 30, "'120,25'"
46
+ gc.text 330, 280, "'320,275'"
47
47
 
48
48
  gc.draw imgl
49
49
 
50
- imgl.border!(1,1, 'lightcyan2')
51
- #imgl.display
50
+ imgl.border!(1, 1, 'lightcyan2')
51
+ # imgl.display
52
52
  imgl.write 'qbezierpath.gif'
@@ -7,28 +7,28 @@ rvg = Magick::RVG.new(12.cm, 6.cm).viewbox(0, 0, 1200, 600) do |canvas|
7
7
  canvas.desc = <<-END_DESC
8
8
  Picture showing a "Q" a "T" command, along with annotations showing the
9
9
  control points and end points
10
- END_DESC
10
+ END_DESC
11
11
  canvas.background_fill = 'white'
12
- canvas.rect(1195, 592, 1, 1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>1)
12
+ canvas.rect(1195, 592, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 1)
13
13
 
14
14
  canvas.path('M200,300 Q400,50 600,300 T1000,300')
15
- .styles(:fill=>'none', :stroke=>'red', :stroke_width=>5)
15
+ .styles(fill: 'none', stroke: 'red', stroke_width: 5)
16
16
 
17
17
  # End points
18
- canvas.g.styles(:fill=>'black') do |grp|
18
+ canvas.g.styles(fill: 'black') do |grp|
19
19
  grp.circle(10, 200, 300)
20
20
  grp.circle(10, 600, 300)
21
21
  grp.circle(10, 1000, 300)
22
22
  end
23
23
 
24
24
  # Control points and lines from end points to control points
25
- canvas.g.styles(:fill=>'#888') do |grp|
25
+ canvas.g.styles(fill: '#888') do |grp|
26
26
  grp.circle(10, 400, 50)
27
27
  grp.circle(10, 800, 550)
28
28
  end
29
29
 
30
30
  canvas.path('M200,300 L400,50 L600,300 L800,550 L1000,300')
31
- .styles(:fill=>'none', :stroke=>'#888', :stroke_width=>2)
31
+ .styles(fill: 'none', stroke: '#888', stroke_width: 2)
32
32
  end
33
33
 
34
34
  rvg.draw.write('quad01.gif')
@@ -4,10 +4,10 @@
4
4
 
5
5
  require 'rmagick'
6
6
 
7
- snapshots = Magick::ImageList.new 'images/Ballerina.jpg','images/Gold_Statue.jpg','images/Shorts.jpg'
7
+ snapshots = Magick::ImageList.new 'images/Ballerina.jpg', 'images/Gold_Statue.jpg', 'images/Shorts.jpg'
8
8
 
9
9
  # Quantize all 3 images to a single set of 16 colors in the RGB colorspace
10
- $stdout.sync=true
10
+ $stdout.sync = true
11
11
  printf 'Quantizing... Please be patient, this may take a couple of seconds... '
12
12
  quant = snapshots.quantize 16
13
13
  puts 'Done.'
@@ -6,7 +6,7 @@ require 'rmagick'
6
6
 
7
7
  img = Magick::Image.read('images/Flower_Hat.jpg').first
8
8
 
9
- geom = Magick::Geometry.new(Magick::QuantumRange/2)
9
+ geom = Magick::Geometry.new(Magick::QuantumRange / 2)
10
10
  img2 = img.random_threshold_channel(geom, Magick::RedChannel)
11
11
 
12
12
  img2.write('random_threshold_channel.jpg')
@@ -6,9 +6,9 @@ rvg = Magick::RVG.new(12.cm, 4.cm) do |canvas|
6
6
  canvas.background_fill = 'white'
7
7
  canvas.desc = 'Example rect01 - rectangle with sharp corners'
8
8
  # Show outline of canvas using 'rect' element
9
- canvas.rect(1195, 395, 1, 1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>2)
9
+ canvas.rect(1195, 395, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 2)
10
10
 
11
- canvas.rect(400, 200, 400, 100).styles(:fill=>'yellow', :stroke=>'navy', :stroke_width=>10)
11
+ canvas.rect(400, 200, 400, 100).styles(fill: 'yellow', stroke: 'navy', stroke_width: 10)
12
12
  end
13
13
 
14
14
  rvg.draw.write('rect01.gif')
@@ -8,12 +8,12 @@ rvg = Magick::RVG.new(12.cm, 4.cm) do |canvas|
8
8
  canvas.desc = 'Example rect02 - rounded rectangles'
9
9
 
10
10
  # Show outline of canvas using 'rect' method
11
- canvas.rect(1195, 395, 1, 1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>2)
11
+ canvas.rect(1195, 395, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 2)
12
12
 
13
- canvas.rect(400, 200, 100, 100).round(50).styles(:fill=>'green')
13
+ canvas.rect(400, 200, 100, 100).round(50).styles(fill: 'green')
14
14
 
15
15
  canvas.g.translate(700, 210).rotate(-30) do |grp|
16
- grp.rect(400, 200, 0, 0).round(50).styles(:fill=>'none', :stroke=>'purple', :stroke_width=>30)
16
+ grp.rect(400, 200, 0, 0).round(50).styles(fill: 'none', stroke: 'purple', stroke_width: 30)
17
17
  end
18
18
  end
19
19
 
@@ -2,7 +2,7 @@
2
2
  require 'rmagick'
3
3
 
4
4
  imgl = Magick::ImageList.new
5
- imgl.new_image(300, 200, Magick::HatchFill.new('white','lightcyan2'))
5
+ imgl.new_image(300, 200, Magick::HatchFill.new('white', 'lightcyan2'))
6
6
 
7
7
  gc = Magick::Draw.new
8
8
 
@@ -11,12 +11,12 @@ gc.stroke('red')
11
11
  gc.stroke_width(3)
12
12
 
13
13
  # Draw rectangle
14
- gc.rectangle(20,20, 280, 180)
14
+ gc.rectangle(20, 20, 280, 180)
15
15
 
16
16
  # Outline corners
17
17
  gc.stroke_width(1)
18
18
  gc.stroke('gray50')
19
- gc.circle(20,20, 23,23)
19
+ gc.circle(20, 20, 23, 23)
20
20
  gc.circle(280, 180, 283, 183)
21
21
 
22
22
  # Annotate
@@ -24,11 +24,11 @@ gc.font_weight(Magick::NormalWeight)
24
24
  gc.font_style(Magick::NormalStyle)
25
25
  gc.fill('black')
26
26
  gc.stroke('transparent')
27
- gc.text(30,35, "'20,20'")
28
- gc.text(230,175, "'280,180'")
27
+ gc.text(30, 35, "'20,20'")
28
+ gc.text(230, 175, "'280,180'")
29
29
 
30
30
  gc.draw(imgl)
31
- imgl.border!(1,1, 'lightcyan2')
31
+ imgl.border!(1, 1, 'lightcyan2')
32
32
 
33
33
  imgl.write('rectangle.gif')
34
34
  exit
@@ -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!(eimg.columns/2, 0, eimg.columns/2, eimg.rows)
16
+ eimg.crop!(eimg.columns / 2, 0, 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.
File without changes
File without changes
File without changes
@@ -3,7 +3,7 @@ require 'rmagick'
3
3
 
4
4
  img = Magick::Image.read('images/Flower_Hat.jpg').first
5
5
 
6
- img = img.roll(img.columns/4, img.rows/4)
6
+ img = img.roll(img.columns / 4, img.rows / 4)
7
7
 
8
8
  img.write('roll.jpg')
9
9
  exit
@@ -2,14 +2,14 @@
2
2
  require 'rmagick'
3
3
 
4
4
  imgl = Magick::ImageList.new
5
- imgl.new_image(200, 200, Magick::HatchFill.new('white','lightcyan2'))
5
+ imgl.new_image(200, 200, Magick::HatchFill.new('white', 'lightcyan2'))
6
6
 
7
7
  gc = Magick::Draw.new
8
8
 
9
9
  # Move the origin to the center.
10
10
  gc.translate(100, 100)
11
- max_x = imgl.columns/2
12
- max_y = imgl.rows/2
11
+ max_x = imgl.columns / 2
12
+ max_y = imgl.rows / 2
13
13
 
14
14
  # Rotate 45 degrees
15
15
  gc.rotate(45)
@@ -19,13 +19,13 @@ gc.stroke_width(3)
19
19
 
20
20
  # Draw down-pointing arrow
21
21
  gc.line(0, -max_y, 0, max_y)
22
- gc.line(0, max_y, 10, max_y-10)
23
- gc.line(0, max_y, -10, max_y-10)
22
+ gc.line(0, max_y, 10, max_y - 10)
23
+ gc.line(0, max_y, -10, max_y - 10)
24
24
 
25
25
  # Draw right-pointing arrow
26
26
  gc.line(-max_x, 0, max_x, 0)
27
- gc.line( max_x, 0, max_x-10, -10)
28
- gc.line( max_x, 0, max_x-10, 10)
27
+ gc.line(max_x, 0, max_x - 10, -10)
28
+ gc.line(max_x, 0, max_x - 10, 10)
29
29
 
30
30
  # Add labels
31
31
  gc.font_weight(Magick::NormalWeight)
@@ -39,6 +39,6 @@ gc.text(12, 115, 'y')
39
39
 
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('rotate.gif')
@@ -8,7 +8,7 @@ img = Magick::Image.read('images/Flower_Hat.jpg').first
8
8
  img.rotate!(45)
9
9
 
10
10
  # Make the corners transparent
11
- img = img.matte_replace(0,0)
11
+ img = img.matte_replace(0, 0)
12
12
 
13
13
  img.write('rotate_f.jpg')
14
14
  exit
@@ -2,7 +2,7 @@
2
2
  require 'rmagick'
3
3
 
4
4
  imgl = Magick::ImageList.new
5
- imgl.new_image(300, 200, Magick::HatchFill.new('white','LightCyan2'))
5
+ imgl.new_image(300, 200, Magick::HatchFill.new('white', 'LightCyan2'))
6
6
 
7
7
  gc = Magick::Draw.new
8
8
 
@@ -11,23 +11,23 @@ gc.stroke('red')
11
11
  gc.stroke_width(3)
12
12
 
13
13
  # Draw rounded rectangle
14
- gc.roundrectangle(20,20, 280,180, 8, 8)
14
+ gc.roundrectangle(20, 20, 280, 180, 8, 8)
15
15
 
16
16
  gc.stroke('gray50')
17
17
  gc.stroke_width(1)
18
18
 
19
- gc.circle(20,20, 23,23)
20
- gc.circle(280,180, 283,183)
19
+ gc.circle(20, 20, 23, 23)
20
+ gc.circle(280, 180, 283, 183)
21
21
 
22
22
  # Annotate
23
23
  gc.font_weight(Magick::NormalWeight)
24
24
  gc.font_style(Magick::NormalStyle)
25
25
  gc.fill('black')
26
26
  gc.stroke('transparent')
27
- gc.text(30,35, "'20,20'")
27
+ gc.text(30, 35, "'20,20'")
28
28
  gc.text(230, 175, "'280,180'")
29
29
 
30
30
  gc.draw(imgl)
31
- imgl.border!(1,1, 'lightcyan2')
31
+ imgl.border!(1, 1, 'lightcyan2')
32
32
 
33
33
  imgl.write('roundrect.gif')
@@ -13,18 +13,18 @@ text = Magick::Draw.new
13
13
  text.pointsize = 52
14
14
  text.gravity = Magick::CenterGravity
15
15
 
16
- text.annotate(canvas, 0,0,2,2, Text) do
16
+ text.annotate(canvas, 0, 0, 2, 2, Text) do
17
17
  self.fill = 'gray83'
18
18
  end
19
19
 
20
- text.annotate(canvas, 0,0,-1.5,-1.5, Text) do
20
+ text.annotate(canvas, 0, 0, -1.5, -1.5, Text) do
21
21
  self.fill = 'gray40'
22
22
  end
23
23
 
24
- text.annotate(canvas, 0,0,0,0, Text) do
24
+ text.annotate(canvas, 0, 0, 0, 0, Text) do
25
25
  self.fill = 'darkred'
26
26
  end
27
27
 
28
- #canvas.display
28
+ # canvas.display
29
29
  canvas.write('rubyname.gif')
30
30
  exit
@@ -3,10 +3,10 @@ require 'rvg/rvg'
3
3
  hat = Magick::Image.read('images/Flower_Hat.jpg').first
4
4
  rvg = Magick::RVG.new(hat.columns, hat.rows) do |canvas|
5
5
  keyhole = Magick::RVG::ClipPath.new do |path|
6
- path.circle(60, canvas.width/2, 80)
7
- path.polygon(canvas.width/2-10, 60, 40, 230, 160, 230, canvas.width/2+10, 60)
6
+ path.circle(60, canvas.width / 2, 80)
7
+ path.polygon(canvas.width / 2 - 10, 60, 40, 230, 160, 230, canvas.width / 2 + 10, 60)
8
8
  end
9
- canvas.image(hat, nil, nil, 20, 20).styles(:clip_path=>keyhole)
9
+ canvas.image(hat, nil, nil, 20, 20).styles(clip_path: keyhole)
10
10
  end
11
11
 
12
12
  rvg.draw.write('rvg_clippath.gif')
@@ -3,12 +3,12 @@ require 'rvg/rvg'
3
3
 
4
4
  Magick::RVG.dpi = 90
5
5
 
6
- BUTT = {:stroke=>'black', :stroke_width=>70, :stroke_linecap=>'butt'}
7
- ROUND = {:stroke=>'black', :stroke_width=>70, :stroke_linecap=>'round'}
8
- SQUARE = {:stroke=>'black', :stroke_width=>70, :stroke_linecap=>'square'}
9
- THIN = {:stroke=>'#ffcccc', :stroke_width=>5}
10
- TEXT = {:text_anchor=>'middle', :font_size=>50, :font_family=>'Verdana'}
11
- CIRCLE = {:fill=>'#ffcccc', :stroke=>'none'}
6
+ BUTT = { stroke: 'black', stroke_width: 70, stroke_linecap: 'butt' }
7
+ ROUND = { stroke: 'black', stroke_width: 70, stroke_linecap: 'round' }
8
+ SQUARE = { stroke: 'black', stroke_width: 70, stroke_linecap: 'square' }
9
+ THIN = { stroke: '#ffcccc', stroke_width: 5 }
10
+ TEXT = { text_anchor: 'middle', font_size: 50, font_family: 'Verdana' }
11
+ CIRCLE = { fill: '#ffcccc', stroke: 'none' }
12
12
 
13
13
  rvg = Magick::RVG.new(12.cm, 2.cm).viewbox(0, 0, 1200, 200) do |canvas|
14
14
  canvas.background_fill = 'white'
@@ -36,7 +36,7 @@ rvg = Magick::RVG.new(12.cm, 2.cm).viewbox(0, 0, 1200, 200) do |canvas|
36
36
  square.circle(8, 125, 0).styles(CIRCLE)
37
37
  square.text(0, 90, "'square' cap").styles(TEXT)
38
38
  end
39
- canvas.rect(1192, 195, 1, 1).styles(:stroke=>'blue', :fill=>'none')
39
+ canvas.rect(1192, 195, 1, 1).styles(stroke: 'blue', fill: 'none')
40
40
  end
41
41
 
42
42
  rvg.draw.write('rvg_linecap.gif')
@@ -2,12 +2,12 @@ require 'rvg/rvg'
2
2
 
3
3
  Magick::RVG.dpi = 90
4
4
 
5
- MITER = {:stroke=>'black', :stroke_width=>70, :fill=>'none', :stroke_linejoin=>'miter'}
6
- ROUND = {:stroke=>'black', :stroke_width=>70, :fill=>'none', :stroke_linejoin=>'round'}
7
- BEVEL = {:stroke=>'black', :stroke_width=>70, :fill=>'none', :stroke_linejoin=>'bevel'}
8
- THIN = {:stroke=>'#ffcccc', :stroke_width=>5, :fill=>'none'}
9
- TEXT = {:text_anchor=>'middle', :font_size=>50, :font_family=>'Verdana'}
10
- CIRCLE = {:fill=>'#ffcccc', :stroke=>'none'}
5
+ MITER = { stroke: 'black', stroke_width: 70, fill: 'none', stroke_linejoin: 'miter' }
6
+ ROUND = { stroke: 'black', stroke_width: 70, fill: 'none', stroke_linejoin: 'round' }
7
+ BEVEL = { stroke: 'black', stroke_width: 70, fill: 'none', stroke_linejoin: 'bevel' }
8
+ THIN = { stroke: '#ffcccc', stroke_width: 5, fill: 'none' }
9
+ TEXT = { text_anchor: 'middle', font_size: 50, font_family: 'Verdana' }
10
+ CIRCLE = { fill: '#ffcccc', stroke: 'none' }
11
11
 
12
12
  rvg = Magick::RVG.new(12.cm, 3.5.cm).viewbox(0, 0, 1200, 350) do |canvas|
13
13
  canvas.desc = 'Example linecap - demonstrates three stroke-linecap values'
@@ -34,7 +34,7 @@ rvg = Magick::RVG.new(12.cm, 3.5.cm).viewbox(0, 0, 1200, 350) do |canvas|
34
34
  bevel.text(0, 230, "'bevel' join").styles(TEXT)
35
35
  end
36
36
 
37
- canvas.rect(1192, 345, 1, 1).styles(:stroke=>'blue', :fill=>'none')
37
+ canvas.rect(1192, 345, 1, 1).styles(stroke: 'blue', fill: 'none')
38
38
  end
39
39
 
40
40
  rvg.draw.write('rvg_linejoin.gif')
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env ruby -w
2
2
  require 'rvg/rvg'
3
3
 
4
- FONT_STYLES = {:font_size=>20, :font_weight=>'bold', :fill=>'white'}
4
+ FONT_STYLES = { font_size: 20, font_weight: 'bold', fill: 'white' }
5
5
 
6
6
  rvg = Magick::RVG.new(450, 150) do |canvas|
7
7
  canvas.background_fill = 'white'
8
8
  canvas.rect(400, 50, 25, 50)
9
- canvas.circle(40, 100, 75).styles(:opacity=>0.25, :stroke=>'blue', :fill=>'#00ff00',:stroke_width=>8)
9
+ canvas.circle(40, 100, 75).styles(opacity: 0.25, stroke: 'blue', fill: '#00ff00', stroke_width: 8)
10
10
  canvas.text(83, 83, '0.25').styles(FONT_STYLES)
11
- canvas.circle(40, 225, 75).styles(:opacity=>0.50, :stroke=>'blue', :fill=>'#00ff00',:stroke_width=>8)
11
+ canvas.circle(40, 225, 75).styles(opacity: 0.50, stroke: 'blue', fill: '#00ff00', stroke_width: 8)
12
12
  canvas.text(208, 83, '0.50').styles(FONT_STYLES)
13
- canvas.circle(40, 350, 75).styles(:opacity=>0.75, :stroke=>'blue', :fill=>'#00ff00',:stroke_width=>8)
13
+ canvas.circle(40, 350, 75).styles(opacity: 0.75, stroke: 'blue', fill: '#00ff00', stroke_width: 8)
14
14
  canvas.text(333, 83, '0.75').styles(FONT_STYLES)
15
- canvas.rect(449,149).styles(:fill=>'none',:stroke=>'blue')
15
+ canvas.rect(449, 149).styles(fill: 'none', stroke: 'blue')
16
16
  end
17
17
 
18
18
  rvg.draw.write('rvg_opacity.gif')