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/mask.rb
CHANGED
File without changes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rmagick'
|
4
4
|
|
5
|
-
img = Magick::Image.new(200,200)
|
5
|
+
img = Magick::Image.new(200, 200)
|
6
6
|
img.compression = Magick::LZWCompression
|
7
7
|
|
8
8
|
bg = Magick::Image.read('plasma:fractal') { self.size = '200x200' }
|
@@ -15,8 +15,8 @@ gc.fill('white')
|
|
15
15
|
gc.roundrectangle(0, 0, 199, 199, 8, 8)
|
16
16
|
|
17
17
|
gc.fill('black')
|
18
|
-
gc.circle(100,
|
19
|
-
gc.circle(
|
18
|
+
gc.circle(100, 45, 100, 25)
|
19
|
+
gc.circle(45, 100, 25, 100)
|
20
20
|
gc.circle(100, 155, 100, 175)
|
21
21
|
gc.circle(155, 100, 175, 100)
|
22
22
|
|
data/doc/ex/matte_floodfill.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rmagick'
|
4
4
|
|
5
|
-
img = Magick::Image.new(200,200)
|
5
|
+
img = Magick::Image.new(200, 200)
|
6
6
|
img.compression = Magick::LZWCompression
|
7
7
|
|
8
8
|
bg = Magick::Image.read('plasma:fractal') { self.size = '200x200' }
|
@@ -16,7 +16,7 @@ gc.roundrectangle(0, 0, 199, 199, 8, 8)
|
|
16
16
|
|
17
17
|
gc.fill('yellow')
|
18
18
|
gc.stroke('red')
|
19
|
-
gc.circle(100, 100, 100,
|
19
|
+
gc.circle(100, 100, 100, 25)
|
20
20
|
gc.draw(img)
|
21
21
|
|
22
22
|
img.write('matte_floodfill_before.gif')
|
data/doc/ex/matte_replace.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rmagick'
|
4
4
|
|
5
|
-
img = Magick::Image.new(200,200)
|
5
|
+
img = Magick::Image.new(200, 200)
|
6
6
|
img.compression = Magick::LZWCompression
|
7
7
|
|
8
8
|
bg = Magick::Image.read('plasma:fractal') { self.size = '200x200' }
|
@@ -15,8 +15,8 @@ gc.fill('white')
|
|
15
15
|
gc.roundrectangle(0, 0, 199, 199, 8, 8)
|
16
16
|
|
17
17
|
gc.fill('black')
|
18
|
-
gc.circle(100,
|
19
|
-
gc.circle(
|
18
|
+
gc.circle(100, 45, 100, 25)
|
19
|
+
gc.circle(45, 100, 25, 100)
|
20
20
|
gc.circle(100, 155, 100, 175)
|
21
21
|
gc.circle(155, 100, 175, 100)
|
22
22
|
|
data/doc/ex/median_filter.rb
CHANGED
@@ -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.
|
data/doc/ex/mono.rb
CHANGED
@@ -13,11 +13,11 @@ cheetah.scale!(0.33)
|
|
13
13
|
mono_cheetah = cheetah.quantize 256, Magick::GRAYColorspace
|
14
14
|
|
15
15
|
# Cut the top off the monochrome cheetah image.
|
16
|
-
mono_bottom = mono_cheetah.crop 0, mono_cheetah.rows/2, mono_cheetah.columns, mono_cheetah.rows/2
|
16
|
+
mono_bottom = mono_cheetah.crop 0, mono_cheetah.rows / 2, mono_cheetah.columns, mono_cheetah.rows / 2
|
17
17
|
|
18
18
|
# Composite the half-height mono cheetah onto the bottom of
|
19
19
|
# the original color cheetah.
|
20
|
-
before_after = cheetah.composite mono_bottom, 0, cheetah.rows/2, Magick::OverCompositeOp
|
20
|
+
before_after = cheetah.composite mono_bottom, 0, cheetah.rows / 2, Magick::OverCompositeOp
|
21
21
|
|
22
22
|
before_after.write 'mono.jpg'
|
23
23
|
exit
|
data/doc/ex/morph.rb
CHANGED
data/doc/ex/mosaic.rb
CHANGED
@@ -8,15 +8,13 @@ a = Magick::ImageList.new
|
|
8
8
|
letter = 'A'
|
9
9
|
26.times do
|
10
10
|
# 'M' is not the same size as the other letters.
|
11
|
-
if letter != 'M'
|
12
|
-
a.read('images/Button_'+letter+'.gif')
|
13
|
-
end
|
11
|
+
a.read('images/Button_' + letter + '.gif') if letter != 'M'
|
14
12
|
letter.succ!
|
15
13
|
end
|
16
14
|
|
17
15
|
# Make a copy of "a" with all the images quarter-sized
|
18
16
|
b = Magick::ImageList.new
|
19
|
-
page = Magick::Rectangle.new(0,0,0,0)
|
17
|
+
page = Magick::Rectangle.new(0, 0, 0, 0)
|
20
18
|
a.scene = 0
|
21
19
|
5.times do |i|
|
22
20
|
5.times do |j|
|
@@ -24,7 +22,11 @@ a.scene = 0
|
|
24
22
|
page.x = j * b.columns
|
25
23
|
page.y = i * b.rows
|
26
24
|
b.page = page
|
27
|
-
|
25
|
+
begin
|
26
|
+
(a.scene += 1)
|
27
|
+
rescue StandardError
|
28
|
+
a.scene = 0
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
data/doc/ex/motion_blur.rb
CHANGED
data/doc/ex/negate_channel.rb
CHANGED
File without changes
|
data/doc/ex/nested_rvg.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'rvg/rvg'
|
4
4
|
|
5
|
-
target = Magick::RVG.new.viewbox(0,0,200,200) do |targ|
|
6
|
-
targ.g.styles(:
|
5
|
+
target = Magick::RVG.new.viewbox(0, 0, 200, 200) do |targ|
|
6
|
+
targ.g.styles(stroke_width: 20, stroke: '#ff5600', fill: '#abd600') do |grp|
|
7
7
|
grp.circle(90, 100, 100)
|
8
8
|
grp.circle(60, 100, 100)
|
9
9
|
grp.circle(30, 100, 100)
|
data/doc/ex/nonzero.rb
CHANGED
@@ -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(:
|
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(:
|
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(:
|
16
|
+
canvas.g.styles(fill_rule: 'nonzero', 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
|
|
data/doc/ex/opacity.rb
CHANGED
@@ -4,33 +4,33 @@ require 'rmagick'
|
|
4
4
|
canvas = Magick::Image.new(260, 125)
|
5
5
|
gc = Magick::Draw.new
|
6
6
|
gc.fill('black')
|
7
|
-
gc.rectangle(10,20, 250,90)
|
7
|
+
gc.rectangle(10, 20, 250, 90)
|
8
8
|
|
9
9
|
gc.stroke('blue')
|
10
10
|
gc.fill('yellow')
|
11
11
|
gc.stroke_width(10)
|
12
12
|
|
13
13
|
gc.opacity('25%')
|
14
|
-
gc.roundrectangle(20,20, 60,90, 5,5)
|
14
|
+
gc.roundrectangle(20, 20, 60, 90, 5, 5)
|
15
15
|
|
16
16
|
gc.opacity('50%')
|
17
|
-
gc.roundrectangle(80,20, 120,90, 5,5)
|
17
|
+
gc.roundrectangle(80, 20, 120, 90, 5, 5)
|
18
18
|
|
19
19
|
gc.opacity(0.75)
|
20
|
-
gc.roundrectangle(140,20, 180,90, 5,5)
|
20
|
+
gc.roundrectangle(140, 20, 180, 90, 5, 5)
|
21
21
|
|
22
22
|
gc.opacity(1)
|
23
|
-
gc.roundrectangle(200,20, 240,90, 5,5)
|
23
|
+
gc.roundrectangle(200, 20, 240, 90, 5, 5)
|
24
24
|
|
25
25
|
gc.font_weight(Magick::NormalWeight)
|
26
26
|
gc.font_style(Magick::NormalStyle)
|
27
27
|
gc.stroke('transparent')
|
28
28
|
gc.fill('black')
|
29
29
|
gc.gravity(Magick::SouthGravity)
|
30
|
-
gc.text(-90,15, '"25%"')
|
31
|
-
gc.text(-30,15, '"50%"')
|
32
|
-
gc.text(
|
33
|
-
gc.text(
|
30
|
+
gc.text(-90, 15, '"25%"')
|
31
|
+
gc.text(-30, 15, '"50%"')
|
32
|
+
gc.text(30, 15, '"75%"')
|
33
|
+
gc.text(90, 15, '"100%"')
|
34
34
|
|
35
35
|
gc.draw(canvas)
|
36
36
|
canvas.write('opacity.png')
|
data/doc/ex/path.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'rmagick'
|
3
3
|
|
4
4
|
imgl = Magick::ImageList.new
|
5
|
-
imgl.new_image(390, 240, Magick::HatchFill.new('white','lightcyan2'))
|
5
|
+
imgl.new_image(390, 240, Magick::HatchFill.new('white', 'lightcyan2'))
|
6
6
|
|
7
7
|
gc = Magick::Draw.new
|
8
8
|
|
@@ -17,47 +17,47 @@ gc.path 'M20,120 C20,20 170,20 170,120 S320,220 320,120'
|
|
17
17
|
gc.fill_opacity 0
|
18
18
|
gc.stroke 'gray50'
|
19
19
|
gc.stroke_width 1
|
20
|
-
gc.circle
|
21
|
-
gc.circle 170,120, 173, 123
|
22
|
-
gc.circle 320,120, 323, 123
|
20
|
+
gc.circle 20, 120, 23, 123
|
21
|
+
gc.circle 170, 120, 173, 123
|
22
|
+
gc.circle 320, 120, 323, 123
|
23
23
|
|
24
24
|
# Show control points
|
25
25
|
gc.fill_opacity 1
|
26
|
-
gc.circle
|
26
|
+
gc.circle 20, 20, 23, 23
|
27
27
|
gc.circle 170, 20, 173, 23
|
28
|
-
gc.circle 320,220, 323, 223
|
28
|
+
gc.circle 320, 220, 323, 223
|
29
29
|
|
30
30
|
# Show connector lines
|
31
|
-
gc.line
|
32
|
-
gc.line 170, 20, 170,220
|
33
|
-
gc.line 320,220, 320,120
|
31
|
+
gc.line 20, 120, 20, 20
|
32
|
+
gc.line 170, 20, 170, 220
|
33
|
+
gc.line 320, 220, 320, 120
|
34
34
|
|
35
35
|
# Show auto control point
|
36
36
|
gc.fill_opacity 0
|
37
37
|
gc.stroke 'blue'
|
38
38
|
gc.stroke_width 3
|
39
|
-
gc.circle 170,220, 173,223
|
39
|
+
gc.circle 170, 220, 173, 223
|
40
40
|
|
41
41
|
# Add labels
|
42
42
|
gc.font_weight Magick::NormalWeight
|
43
43
|
gc.font_style Magick::NormalStyle
|
44
|
-
gc.stroke 'none'
|
44
|
+
gc.stroke 'none' # unset stroke color
|
45
45
|
gc.fill 'black'
|
46
46
|
|
47
47
|
# Add end point labels
|
48
|
-
gc.text
|
49
|
-
gc.text 180,125, "'170,120'"
|
50
|
-
gc.text 330,125, "'320,120'"
|
48
|
+
gc.text 30, 125, "'20,120'"
|
49
|
+
gc.text 180, 125, "'170,120'"
|
50
|
+
gc.text 330, 125, "'320,120'"
|
51
51
|
|
52
52
|
# Add control point labels
|
53
53
|
gc.text 30, 25, "'20,20'"
|
54
54
|
gc.text 180, 25, "'170,20'"
|
55
|
-
gc.text 330,225, "'320,220'"
|
55
|
+
gc.text 330, 225, "'320,220'"
|
56
56
|
|
57
57
|
# Add auto control point label
|
58
|
-
gc.text 180,225, "'auto ctl point'"
|
58
|
+
gc.text 180, 225, "'auto ctl point'"
|
59
59
|
|
60
60
|
gc.draw imgl
|
61
61
|
|
62
|
-
imgl.border!(1,1, 'lightcyan2')
|
62
|
+
imgl.border!(1, 1, 'lightcyan2')
|
63
63
|
imgl.write 'path.gif'
|
data/doc/ex/pattern1.rb
CHANGED
@@ -5,10 +5,10 @@ require 'rmagick'
|
|
5
5
|
gc = Magick::Draw.new
|
6
6
|
gc.pattern('triangles', 0, 0, 16, 16) do
|
7
7
|
gc.fill('darkblue')
|
8
|
-
gc.rectangle(0,0, 16,16)
|
8
|
+
gc.rectangle(0, 0, 16, 16)
|
9
9
|
gc.fill('yellow')
|
10
10
|
gc.stroke('red')
|
11
|
-
gc.polygon(0,0, 8,16, 16,0, 0,0)
|
11
|
+
gc.polygon(0, 0, 8, 16, 16, 0, 0, 0)
|
12
12
|
end
|
13
13
|
|
14
14
|
gc.stroke('triangles')
|
@@ -16,10 +16,10 @@ gc.stroke_width(16)
|
|
16
16
|
gc.fill('none')
|
17
17
|
gc.ellipse(150, 75, 130, 60, 0, 360)
|
18
18
|
|
19
|
-
img = Magick::Image.new(300, 150, Magick::HatchFill.new('white','lightcyan2',8))
|
19
|
+
img = Magick::Image.new(300, 150, Magick::HatchFill.new('white', 'lightcyan2', 8))
|
20
20
|
gc.draw(img)
|
21
21
|
|
22
|
-
img.border!(1,1, 'lightcyan2')
|
22
|
+
img.border!(1, 1, 'lightcyan2')
|
23
23
|
|
24
24
|
img.write('pattern1.gif')
|
25
25
|
exit
|
data/doc/ex/pattern2.rb
CHANGED
@@ -16,11 +16,11 @@ gc.fill('hat')
|
|
16
16
|
gc.ellipse(150, 75, 140, 70, 0, 360)
|
17
17
|
|
18
18
|
# Create a canvas to draw on
|
19
|
-
img = Magick::Image.new(300, 150, Magick::HatchFill.new('white','lightcyan2',8))
|
19
|
+
img = Magick::Image.new(300, 150, Magick::HatchFill.new('white', 'lightcyan2', 8))
|
20
20
|
|
21
21
|
# Draw the ellipse using the fill
|
22
22
|
gc.draw(img)
|
23
23
|
|
24
|
-
img.border!(1,1, 'lightcyan2')
|
24
|
+
img.border!(1, 1, 'lightcyan2')
|
25
25
|
img.write('pattern2.gif')
|
26
26
|
exit
|
data/doc/ex/polaroid.rb
CHANGED
@@ -18,7 +18,6 @@ begin
|
|
18
18
|
# Composite it on a white background so the result is opaque.
|
19
19
|
background = Magick::Image.new(picture.columns, picture.rows)
|
20
20
|
result = background.composite(picture, Magick::CenterGravity, Magick::OverCompositeOp)
|
21
|
-
|
22
21
|
rescue NotImplementedError
|
23
22
|
result = Magick::Image.read('images/notimplemented.gif').first
|
24
23
|
result.resize!(img.columns, img.rows)
|
data/doc/ex/polygon.rb
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
require 'rmagick'
|
3
3
|
|
4
4
|
imgl = Magick::ImageList.new
|
5
|
-
imgl.new_image(290, 200, Magick::HatchFill.new('white','lightcyan2'))
|
5
|
+
imgl.new_image(290, 200, Magick::HatchFill.new('white', 'lightcyan2'))
|
6
6
|
|
7
7
|
gc = Magick::Draw.new
|
8
8
|
gc.stroke('blue').stroke_width(3)
|
9
9
|
|
10
10
|
# Draw red 5-pointed star
|
11
11
|
gc.fill('red')
|
12
|
-
gc.polygon(
|
13
|
-
|
14
|
-
|
12
|
+
gc.polygon(75, 37.5, 89.5, 80.5, 134.5, 80.5, 98.5, 107.5,
|
13
|
+
111.5, 150.5, 75, 125, 38.5, 150.5, 51.5, 107.5,
|
14
|
+
15.5, 80.5, 60.5, 80.5)
|
15
15
|
# Draw green hexagon
|
16
16
|
gc.fill('lime')
|
17
|
-
gc.polygon(225,37.5, 279,68.75, 279,131.25,
|
18
|
-
225,162.5, 171,131.3, 171,68.75)
|
17
|
+
gc.polygon(225, 37.5, 279, 68.75, 279, 131.25,
|
18
|
+
225, 162.5, 171, 131.3, 171, 68.75)
|
19
19
|
|
20
20
|
gc.draw(imgl)
|
21
|
-
imgl.border!(1,1, 'lightcyan2')
|
21
|
+
imgl.border!(1, 1, 'lightcyan2')
|
22
22
|
|
23
23
|
imgl.write('polygon.gif')
|
data/doc/ex/polygon01.rb
CHANGED
@@ -7,15 +7,15 @@ rvg = Magick::RVG.new(12.cm, 4.cm).viewbox(0, 0, 1200, 400) do |canvas|
|
|
7
7
|
canvas.desc = 'Example polygon01 - star and hexagon'
|
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.polygon(350,75,379,161,469,161,397,215,
|
13
|
-
423,301,350,250,277,301,303,215,
|
14
|
-
231,161,321,161).styles(:
|
12
|
+
canvas.polygon(350, 75, 379, 161, 469, 161, 397, 215,
|
13
|
+
423, 301, 350, 250, 277, 301, 303, 215,
|
14
|
+
231, 161, 321, 161).styles(fill: 'red', stroke: 'blue', stroke_width: 10)
|
15
15
|
|
16
|
-
canvas.polygon(850,75,958,137.5,958,262.5,
|
17
|
-
850,325,742,262.6,742,137.5)
|
18
|
-
|
16
|
+
canvas.polygon(850, 75, 958, 137.5, 958, 262.5,
|
17
|
+
850, 325, 742, 262.6, 742, 137.5)
|
18
|
+
.styles(fill: 'lime', stroke: 'blue', stroke_width: 10)
|
19
19
|
end
|
20
20
|
|
21
21
|
rvg.draw.write('polygon01.gif')
|
data/doc/ex/polyline.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
require 'rmagick'
|
3
3
|
|
4
4
|
imgl = Magick::ImageList.new
|
5
|
-
imgl.new_image(300, 100, Magick::HatchFill.new('white','lightcyan2'))
|
5
|
+
imgl.new_image(300, 100, Magick::HatchFill.new('white', 'lightcyan2'))
|
6
6
|
|
7
|
-
points = [12,93.75, 37,93.75, 37,81.25,
|
8
|
-
62,93.75, 87,93.75, 87,62, 112,62,
|
9
|
-
137,93.75, 137,43.75, 162,43.75, 162,93.75,
|
10
|
-
187,93.75, 187,25, 212,25, 212,93.75, 237,93.75,
|
11
|
-
237,6.25, 262,6.25, 262,93.75, 287,93.75]
|
7
|
+
points = [12, 93.75, 37, 93.75, 37, 81.25, 62, 81.25,
|
8
|
+
62, 93.75, 87, 93.75, 87, 62, 112, 62, 112, 93.75,
|
9
|
+
137, 93.75, 137, 43.75, 162, 43.75, 162, 93.75,
|
10
|
+
187, 93.75, 187, 25, 212, 25, 212, 93.75, 237, 93.75,
|
11
|
+
237, 6.25, 262, 6.25, 262, 93.75, 287, 93.75]
|
12
12
|
|
13
13
|
gc = Magick::Draw.new
|
14
14
|
gc.stroke('blue').stroke_width(3)
|
@@ -17,6 +17,6 @@ gc.polyline(*points)
|
|
17
17
|
|
18
18
|
gc.draw(imgl)
|
19
19
|
|
20
|
-
imgl.border!(1,1, 'lightcyan2')
|
20
|
+
imgl.border!(1, 1, 'lightcyan2')
|
21
21
|
|
22
22
|
imgl.write('polyline.gif')
|