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.
- checksums.yaml +5 -5
- data/.appveyor.yml +19 -0
- data/.circleci/config.yml +56 -0
- data/.rubocop.yml +8 -335
- data/.rubocop_todo.yml +255 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -49
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +34 -0
- data/Gemfile +0 -6
- data/README.textile +11 -3
- data/Rakefile +23 -15
- data/before_install_linux.sh +12 -15
- data/doc/ex/InitialCoords.rb +4 -4
- data/doc/ex/NewCoordSys.rb +4 -4
- data/doc/ex/OrigCoordSys.rb +2 -2
- data/doc/ex/PreserveAspectRatio.rb +34 -34
- data/doc/ex/RotateScale.rb +7 -7
- data/doc/ex/Skew.rb +7 -7
- data/doc/ex/Use01.rb +1 -1
- data/doc/ex/Use02.rb +4 -4
- data/doc/ex/Use03.rb +2 -2
- data/doc/ex/ViewBox.rb +4 -4
- data/doc/ex/affine.rb +5 -5
- data/doc/ex/affine_transform.rb +3 -3
- data/doc/ex/arc.rb +9 -9
- data/doc/ex/arcpath.rb +2 -2
- data/doc/ex/arcs01.rb +6 -6
- data/doc/ex/arcs02.rb +8 -8
- data/doc/ex/axes.rb +11 -11
- data/doc/ex/baseline_shift01.rb +5 -5
- data/doc/ex/bilevel_channel.rb +1 -1
- data/doc/ex/blur_image.rb +1 -1
- data/doc/ex/border.rb +1 -1
- data/doc/ex/bounding_box.rb +11 -11
- data/doc/ex/cbezier1.rb +12 -12
- data/doc/ex/cbezier2.rb +13 -13
- data/doc/ex/cbezier3.rb +13 -13
- data/doc/ex/cbezier4.rb +13 -13
- data/doc/ex/cbezier5.rb +13 -13
- data/doc/ex/cbezier6.rb +19 -19
- data/doc/ex/channel.rb +2 -2
- data/doc/ex/chop.rb +2 -2
- data/doc/ex/circle.rb +7 -7
- data/doc/ex/circle01.rb +2 -2
- data/doc/ex/clip_path.rb +6 -6
- data/doc/ex/coalesce.rb +6 -6
- data/doc/ex/color_fill_to_border.rb +8 -8
- data/doc/ex/color_floodfill.rb +8 -8
- data/doc/ex/color_histogram.rb +2 -2
- data/doc/ex/color_reset.rb +2 -2
- data/doc/ex/colors.rb +4 -4
- data/doc/ex/compose_mask.rb +2 -2
- data/doc/ex/composite.rb +39 -39
- data/doc/ex/composite_layers.rb +1 -2
- data/doc/ex/contrast.rb +3 -3
- data/doc/ex/crop.rb +2 -2
- data/doc/ex/crop_with_gravity.rb +5 -5
- data/doc/ex/cubic01.rb +12 -12
- data/doc/ex/cubic02.rb +22 -22
- data/doc/ex/cycle_colormap.rb +3 -3
- data/doc/ex/dissolve.rb +0 -0
- data/doc/ex/drawcomp.rb +8 -9
- data/doc/ex/drop_shadow.rb +4 -4
- data/doc/ex/ellipse.rb +9 -9
- data/doc/ex/ellipse01.rb +3 -3
- data/doc/ex/enhance.rb +2 -2
- data/doc/ex/evenodd.rb +19 -19
- data/doc/ex/fill_pattern.rb +3 -3
- data/doc/ex/flatten_images.rb +1 -1
- data/doc/ex/font_styles.rb +13 -13
- data/doc/ex/fonts.rb +2 -6
- data/doc/ex/frame.rb +1 -1
- data/doc/ex/get_multiline_type_metrics.rb +3 -3
- data/doc/ex/get_pixels.rb +4 -6
- data/doc/ex/get_type_metrics.rb +26 -25
- data/doc/ex/gradientfill.rb +2 -2
- data/doc/ex/grav.rb +12 -12
- data/doc/ex/gravity.rb +14 -16
- data/doc/ex/group.rb +11 -11
- data/doc/ex/hatchfill.rb +2 -2
- data/doc/ex/image.rb +9 -9
- data/doc/ex/implode.rb +2 -2
- data/doc/ex/line.rb +10 -10
- data/doc/ex/line01.rb +7 -7
- data/doc/ex/mask.rb +0 -0
- data/doc/ex/matte_fill_to_border.rb +3 -3
- data/doc/ex/matte_floodfill.rb +2 -2
- data/doc/ex/matte_replace.rb +3 -3
- data/doc/ex/median_filter.rb +2 -2
- data/doc/ex/mono.rb +2 -2
- data/doc/ex/morph.rb +1 -1
- data/doc/ex/mosaic.rb +7 -5
- data/doc/ex/motion_blur.rb +1 -1
- data/doc/ex/negate_channel.rb +0 -0
- data/doc/ex/nested_rvg.rb +2 -2
- data/doc/ex/nonzero.rb +19 -19
- data/doc/ex/opacity.rb +9 -9
- data/doc/ex/path.rb +17 -17
- data/doc/ex/pattern1.rb +4 -4
- data/doc/ex/pattern2.rb +2 -2
- data/doc/ex/polaroid.rb +0 -1
- data/doc/ex/polygon.rb +7 -7
- data/doc/ex/polygon01.rb +7 -7
- data/doc/ex/polyline.rb +7 -7
- data/doc/ex/polyline01.rb +8 -8
- data/doc/ex/posterize.rb +0 -0
- data/doc/ex/qbezierpath.rb +16 -16
- data/doc/ex/quad01.rb +6 -6
- data/doc/ex/quantize-m.rb +2 -2
- data/doc/ex/random_threshold_channel.rb +1 -1
- data/doc/ex/rect01.rb +2 -2
- data/doc/ex/rect02.rb +3 -3
- data/doc/ex/rectangle.rb +6 -6
- data/doc/ex/reduce_noise.rb +2 -2
- data/doc/ex/remap.rb +0 -0
- data/doc/ex/resize_to_fill.rb +0 -0
- data/doc/ex/resize_to_fit.rb +0 -0
- data/doc/ex/roll.rb +1 -1
- data/doc/ex/rotate.rb +8 -8
- data/doc/ex/rotate_f.rb +1 -1
- data/doc/ex/roundrect.rb +6 -6
- data/doc/ex/rubyname.rb +4 -4
- data/doc/ex/rvg_clippath.rb +3 -3
- data/doc/ex/rvg_linecap.rb +7 -7
- data/doc/ex/rvg_linejoin.rb +7 -7
- data/doc/ex/rvg_opacity.rb +5 -5
- data/doc/ex/rvg_pattern.rb +8 -8
- data/doc/ex/rvg_stroke_dasharray.rb +2 -2
- data/doc/ex/sepiatone.rb +0 -0
- data/doc/ex/shadow.rb +6 -6
- data/doc/ex/shear.rb +2 -2
- data/doc/ex/skewx.rb +8 -8
- data/doc/ex/skewy.rb +9 -9
- data/doc/ex/smile.rb +5 -4
- data/doc/ex/sparse_color.rb +0 -4
- data/doc/ex/splice.rb +1 -1
- data/doc/ex/stegano.rb +4 -5
- data/doc/ex/stroke_dasharray.rb +10 -10
- data/doc/ex/stroke_fill.rb +2 -2
- data/doc/ex/stroke_linecap.rb +12 -12
- data/doc/ex/stroke_linejoin.rb +12 -12
- data/doc/ex/stroke_width.rb +11 -11
- data/doc/ex/swirl.rb +2 -2
- data/doc/ex/text.rb +6 -6
- data/doc/ex/text01.rb +4 -4
- data/doc/ex/text_align.rb +5 -5
- data/doc/ex/text_antialias.rb +2 -2
- data/doc/ex/text_styles.rb +8 -8
- data/doc/ex/text_undercolor.rb +4 -4
- data/doc/ex/texture_fill_to_border.rb +8 -8
- data/doc/ex/texture_floodfill.rb +8 -8
- data/doc/ex/texturefill.rb +2 -2
- data/doc/ex/threshold.rb +2 -2
- data/doc/ex/to_blob.rb +1 -1
- data/doc/ex/translate.rb +8 -8
- data/doc/ex/transparent.rb +6 -6
- data/doc/ex/transpose.rb +0 -0
- data/doc/ex/transverse.rb +0 -0
- data/doc/ex/tref01.rb +6 -6
- data/doc/ex/triangle01.rb +2 -2
- data/doc/ex/trim.rb +2 -2
- data/doc/ex/tspan01.rb +5 -5
- data/doc/ex/tspan02.rb +5 -5
- data/doc/ex/tspan03.rb +5 -5
- data/doc/ex/unsharp_mask.rb +3 -3
- data/doc/ex/viewex.rb +5 -5
- data/doc/ex/vignette.rb +0 -0
- data/doc/ex/watermark.rb +6 -6
- data/doc/ex/wet_floor.rb +2 -2
- data/doc/ex/writing_mode01.rb +12 -12
- data/doc/ex/writing_mode02.rb +12 -12
- data/examples/constitute.rb +1 -1
- data/examples/crop_with_gravity.rb +5 -5
- data/examples/demo.rb +6 -7
- data/examples/describe.rb +8 -10
- data/examples/find_similar_region.rb +3 -3
- data/examples/histogram.rb +192 -201
- data/examples/identify.rb +62 -73
- data/examples/image_opacity.rb +0 -1
- data/examples/import_export.rb +1 -1
- data/examples/pattern_fill.rb +3 -4
- data/examples/rotating_text.rb +5 -4
- data/examples/spinner.rb +5 -5
- data/examples/thumbnail.rb +3 -3
- data/examples/vignette.rb +5 -5
- data/ext/RMagick/extconf.rb +213 -230
- data/ext/RMagick/rmagick.c +1 -0
- data/ext/RMagick/rmagick.h +26 -29
- data/ext/RMagick/rmdraw.c +3 -38
- data/ext/RMagick/rmenum.c +36 -0
- data/ext/RMagick/rmimage.c +166 -10
- data/ext/RMagick/rminfo.c +7 -2
- data/ext/RMagick/rmkinfo.c +247 -0
- data/ext/RMagick/rmmain.c +96 -0
- data/ext/RMagick/rmutil.c +4 -0
- data/lib/rmagick/version.rb +3 -3
- data/lib/rmagick_internal.rb +226 -308
- data/lib/rvg/clippath.rb +2 -4
- data/lib/rvg/container.rb +25 -22
- data/lib/rvg/deep_equal.rb +11 -11
- data/lib/rvg/describable.rb +2 -2
- data/lib/rvg/embellishable.rb +60 -66
- data/lib/rvg/misc.rb +122 -128
- data/lib/rvg/pathdata.rb +15 -17
- data/lib/rvg/rvg.rb +41 -44
- data/lib/rvg/stretchable.rb +22 -28
- data/lib/rvg/stylable.rb +10 -10
- data/lib/rvg/text.rb +164 -165
- data/lib/rvg/transformable.rb +15 -15
- data/lib/rvg/units.rb +2 -2
- data/rmagick.gemspec +9 -33
- data/spec/rmagick/draw_spec.rb +5 -6
- data/spec/rmagick/image/blue_shift_spec.rb +1 -3
- data/spec/rmagick/image/channel_entropy_spec.rb +9 -0
- data/spec/rmagick/image/composite_spec.rb +2 -4
- data/spec/rmagick/image/constitute_spec.rb +2 -4
- data/spec/rmagick/image/dispatch_spec.rb +1 -3
- data/spec/rmagick/image/from_blob_spec.rb +1 -3
- data/spec/rmagick/image/ping_spec.rb +1 -3
- data/spec/rmagick/image/properties_spec.rb +0 -2
- data/spec/rmagick/image/read_spec.rb +28 -0
- data/spec/spec_helper.rb +7 -1
- data/spec/support/issue_200/app.rb +8 -0
- data/test/Image1.rb +70 -70
- data/test/Image2.rb +369 -361
- data/test/Image3.rb +64 -63
- data/test/ImageList1.rb +796 -792
- data/test/ImageList2.rb +43 -44
- data/test/Image_attributes.rb +26 -48
- data/test/Import_Export.rb +71 -77
- data/test/Info.rb +30 -31
- data/test/Magick.rb +47 -46
- data/test/Pixel.rb +24 -24
- data/test/Preview.rb +7 -6
- data/test/test_all_basic.rb +15 -7
- data/test/tmpnam_test.rb +3 -3
- metadata +57 -18
data/doc/ex/get_type_metrics.rb
CHANGED
@@ -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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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(
|
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')
|
data/doc/ex/gradientfill.rb
CHANGED
@@ -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
|
data/doc/ex/grav.rb
CHANGED
@@ -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(
|
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(
|
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(
|
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
|
data/doc/ex/gravity.rb
CHANGED
@@ -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
|
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
|
data/doc/ex/group.rb
CHANGED
@@ -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(:
|
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(:
|
11
|
-
fig.circle(42, 50, 50).styles(:
|
12
|
-
fig.polyline(30,40, 50,40, 45,60, 50,40, 65,40).styles(:
|
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
|
data/doc/ex/hatchfill.rb
CHANGED
@@ -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
|
data/doc/ex/image.rb
CHANGED
@@ -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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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')
|
data/doc/ex/implode.rb
CHANGED
@@ -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,
|
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,
|
25
|
+
legend.annotate(frames, 0, 0, 10, 20, format('% 4.2f', implosion))
|
26
26
|
frames.matte = false
|
27
27
|
end
|
28
28
|
|
data/doc/ex/line.rb
CHANGED
@@ -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')
|
data/doc/ex/line01.rb
CHANGED
@@ -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(:
|
10
|
+
canvas.rect(1195, 395, 1, 1).styles(fill: 'none', stroke: 'blue', stroke_width: 2)
|
11
11
|
|
12
|
-
canvas.g.styles(:
|
13
|
-
grp.line(100, 300, 300, 100).styles(:
|
14
|
-
grp.line(300, 300, 500, 100).styles(:
|
15
|
-
grp.line(500, 300, 700, 100).styles(:
|
16
|
-
grp.line(700, 300, 900, 100).styles(:
|
17
|
-
grp.line(900, 300, 1100, 100).styles(:
|
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
|
|