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/polyline01.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 polyline01 - increasingly larger bars'
|
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.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(:
|
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')
|
data/doc/ex/posterize.rb
CHANGED
File without changes
|
data/doc/ex/qbezierpath.rb
CHANGED
@@ -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'
|
data/doc/ex/quad01.rb
CHANGED
@@ -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
|
-
|
10
|
+
END_DESC
|
11
11
|
canvas.background_fill = 'white'
|
12
|
-
canvas.rect(1195, 592, 1, 1).styles(:
|
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
|
-
|
15
|
+
.styles(fill: 'none', stroke: 'red', stroke_width: 5)
|
16
16
|
|
17
17
|
# End points
|
18
|
-
canvas.g.styles(:
|
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(:
|
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
|
-
|
31
|
+
.styles(fill: 'none', stroke: '#888', stroke_width: 2)
|
32
32
|
end
|
33
33
|
|
34
34
|
rvg.draw.write('quad01.gif')
|
data/doc/ex/quantize-m.rb
CHANGED
@@ -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')
|
data/doc/ex/rect01.rb
CHANGED
@@ -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(:
|
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(:
|
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')
|
data/doc/ex/rect02.rb
CHANGED
@@ -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(:
|
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(:
|
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(:
|
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
|
|
data/doc/ex/rectangle.rb
CHANGED
@@ -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
|
data/doc/ex/reduce_noise.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/remap.rb
CHANGED
File without changes
|
data/doc/ex/resize_to_fill.rb
CHANGED
File without changes
|
data/doc/ex/resize_to_fit.rb
CHANGED
File without changes
|
data/doc/ex/roll.rb
CHANGED
data/doc/ex/rotate.rb
CHANGED
@@ -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(
|
28
|
-
gc.line(
|
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')
|
data/doc/ex/rotate_f.rb
CHANGED
data/doc/ex/roundrect.rb
CHANGED
@@ -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')
|
data/doc/ex/rubyname.rb
CHANGED
@@ -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
|
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
|
data/doc/ex/rvg_clippath.rb
CHANGED
@@ -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(:
|
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')
|
data/doc/ex/rvg_linecap.rb
CHANGED
@@ -3,12 +3,12 @@ require 'rvg/rvg'
|
|
3
3
|
|
4
4
|
Magick::RVG.dpi = 90
|
5
5
|
|
6
|
-
BUTT = {:
|
7
|
-
ROUND = {:
|
8
|
-
SQUARE = {:
|
9
|
-
THIN = {:
|
10
|
-
TEXT = {:
|
11
|
-
CIRCLE = {:
|
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(:
|
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')
|
data/doc/ex/rvg_linejoin.rb
CHANGED
@@ -2,12 +2,12 @@ require 'rvg/rvg'
|
|
2
2
|
|
3
3
|
Magick::RVG.dpi = 90
|
4
4
|
|
5
|
-
MITER = {:
|
6
|
-
ROUND = {:
|
7
|
-
BEVEL = {:
|
8
|
-
THIN = {:
|
9
|
-
TEXT = {:
|
10
|
-
CIRCLE = {:
|
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(:
|
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')
|
data/doc/ex/rvg_opacity.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
require 'rvg/rvg'
|
3
3
|
|
4
|
-
FONT_STYLES = {:
|
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(:
|
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(:
|
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(:
|
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(:
|
15
|
+
canvas.rect(449, 149).styles(fill: 'none', stroke: 'blue')
|
16
16
|
end
|
17
17
|
|
18
18
|
rvg.draw.write('rvg_opacity.gif')
|