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/rvg_pattern.rb
CHANGED
@@ -2,24 +2,24 @@ require 'rvg/rvg'
|
|
2
2
|
|
3
3
|
rvg = Magick::RVG.new(300, 300) do |canvas|
|
4
4
|
canvas.background_fill = 'white'
|
5
|
-
triangles = Magick::RVG::Pattern.new(16, 16).viewbox(0,0, 50,50) do |pat|
|
6
|
-
pat.rect(50, 50).styles(:
|
7
|
-
pat.polygon(0,0, 25,50, 50,0, 0,0).styles(:
|
5
|
+
triangles = Magick::RVG::Pattern.new(16, 16).viewbox(0, 0, 50, 50) do |pat|
|
6
|
+
pat.rect(50, 50).styles(fill: 'darkblue')
|
7
|
+
pat.polygon(0, 0, 25, 50, 50, 0, 0, 0).styles(fill: 'yellow', stroke: 'red')
|
8
8
|
end
|
9
9
|
|
10
|
-
canvas.ellipse(130, 60, 150, 75).styles(:
|
10
|
+
canvas.ellipse(130, 60, 150, 75).styles(stroke_width: 16, fill: 'none', stroke: triangles)
|
11
11
|
|
12
12
|
hat = Magick::Image.read('images/Flower_Hat.jpg').first
|
13
13
|
|
14
|
-
hats = Magick::RVG::Pattern.new(hat.columns/4.0, hat.rows/4.0) do |pat|
|
15
|
-
pat.image(hat, hat.columns/4.0, hat.rows/4.0)
|
14
|
+
hats = Magick::RVG::Pattern.new(hat.columns / 4.0, hat.rows / 4.0) do |pat|
|
15
|
+
pat.image(hat, hat.columns / 4.0, hat.rows / 4.0)
|
16
16
|
end
|
17
17
|
|
18
18
|
canvas.g.translate(0, 150) do |grp|
|
19
|
-
grp.ellipse(130, 60, 150, 75).styles(:
|
19
|
+
grp.ellipse(130, 60, 150, 75).styles(fill: hats)
|
20
20
|
end
|
21
21
|
|
22
|
-
canvas.rect(299, 299, 0, 0).styles(:
|
22
|
+
canvas.rect(299, 299, 0, 0).styles(fill: 'none', stroke: 'blue')
|
23
23
|
canvas.line(1, 150, 299, 150)
|
24
24
|
end
|
25
25
|
|
@@ -4,8 +4,8 @@ require 'rvg/rvg'
|
|
4
4
|
rvg = Magick::RVG.new(200, 100) do |canvas|
|
5
5
|
canvas.background_fill = 'white'
|
6
6
|
canvas.rect(150, 50, 25, 25).round(6)
|
7
|
-
|
8
|
-
canvas.rect(199, 99).styles(:
|
7
|
+
.styles(fill: 'none', stroke: 'purple', stroke_width: 10, stroke_dasharray: [10, 5])
|
8
|
+
canvas.rect(199, 99).styles(fill: 'none', stroke: 'blue')
|
9
9
|
end
|
10
10
|
|
11
11
|
rvg.draw.write('rvg_stroke_dasharray.gif')
|
data/doc/ex/sepiatone.rb
CHANGED
File without changes
|
data/doc/ex/shadow.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'rmagick'
|
2
2
|
|
3
3
|
# Draw a big red Bezier curve on a transparent background.
|
4
|
-
img = Magick::Image.new(340, 120) {self.background_color = 'none'}
|
4
|
+
img = Magick::Image.new(340, 120) { self.background_color = 'none' }
|
5
5
|
gc = Magick::Draw.new
|
6
6
|
gc.fill('none')
|
7
7
|
gc.stroke('red')
|
8
8
|
gc.stroke_linecap('round')
|
9
9
|
gc.stroke_width(10)
|
10
|
-
gc.bezier(20, 60, 20
|
10
|
+
gc.bezier(20, 60, 20, -90, 320, 210, 320, 60)
|
11
11
|
gc.draw(img)
|
12
12
|
|
13
13
|
# Composite it onto a white background, draw a border around the result,
|
14
14
|
# write it to the "before" file.
|
15
15
|
before = img.copy
|
16
|
-
bg = Magick::Image.new(before.columns, before.rows) {self.background_color='white'}
|
16
|
+
bg = Magick::Image.new(before.columns, before.rows) { self.background_color = 'white' }
|
17
17
|
before = bg.composite(before, Magick::CenterGravity, Magick::OverCompositeOp)
|
18
|
-
before.border!(1,1,'gray80')
|
18
|
+
before.border!(1, 1, 'gray80')
|
19
19
|
before.write('shadow_before.gif')
|
20
20
|
|
21
21
|
# Create the shadow.
|
@@ -23,8 +23,8 @@ shadow = img.shadow
|
|
23
23
|
# Composite the original image over the shadow, composite the result
|
24
24
|
# onto a white background, add a border, write it to the "after" file.
|
25
25
|
shadow = shadow.composite(img, Magick::NorthWestGravity, Magick::OverCompositeOp)
|
26
|
-
bg = Magick::Image.new(shadow.columns, shadow.rows) {self.background_color='white'}
|
26
|
+
bg = Magick::Image.new(shadow.columns, shadow.rows) { self.background_color = 'white' }
|
27
27
|
after = bg.composite(shadow, Magick::CenterGravity, Magick::OverCompositeOp)
|
28
|
-
after.border!(1,1,'gray80')
|
28
|
+
after.border!(1, 1, 'gray80')
|
29
29
|
|
30
30
|
after.write('shadow_after.gif')
|
data/doc/ex/shear.rb
CHANGED
data/doc/ex/skewx.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
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
|
|
9
9
|
# Move the origin to the center.
|
10
10
|
gc.translate(125, 125)
|
11
|
-
max_x = imgl.columns/2
|
12
|
-
max_y = imgl.rows/2 - 5
|
11
|
+
max_x = imgl.columns / 2
|
12
|
+
max_y = imgl.rows / 2 - 5
|
13
13
|
|
14
14
|
# Skew x 30 degrees
|
15
15
|
gc.skewx(30)
|
@@ -19,15 +19,15 @@ gc.fill('red')
|
|
19
19
|
gc.stroke('red')
|
20
20
|
gc.stroke_width(3)
|
21
21
|
gc.line(0, -max_y, 0, max_y)
|
22
|
-
gc.line(0, max_y, 7, max_y-7)
|
23
|
-
gc.line(0, max_y, -7, max_y-7)
|
22
|
+
gc.line(0, max_y, 7, max_y - 7)
|
23
|
+
gc.line(0, max_y, -7, max_y - 7)
|
24
24
|
|
25
25
|
# Draw right-pointing arrow
|
26
26
|
gc.stroke('gray50')
|
27
27
|
gc.stroke_width(1)
|
28
28
|
gc.line(-max_x, 0, max_x, 0)
|
29
|
-
gc.line(
|
30
|
-
gc.line(
|
29
|
+
gc.line(max_x, 0, max_x - 5, -5)
|
30
|
+
gc.line(max_x, 0, max_x - 5, 5)
|
31
31
|
|
32
32
|
gc.draw(imgl)
|
33
33
|
|
@@ -46,6 +46,6 @@ gc.text(0, 20, "'+y'")
|
|
46
46
|
|
47
47
|
gc.draw(imgl)
|
48
48
|
|
49
|
-
imgl.border!(1,1, 'lightcyan2')
|
49
|
+
imgl.border!(1, 1, 'lightcyan2')
|
50
50
|
|
51
51
|
imgl.write('skewx.gif')
|
data/doc/ex/skewy.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
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
|
|
9
9
|
# Move the origin to the center.
|
10
10
|
gc.translate(125, 125)
|
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
|
# Skew y 30 degrees
|
15
15
|
gc.skewy(30)
|
@@ -17,15 +17,15 @@ gc.skewy(30)
|
|
17
17
|
# Draw down-pointing arrow
|
18
18
|
gc.fill('gray50')
|
19
19
|
gc.line(0, -max_y, 0, max_y)
|
20
|
-
gc.line(0, max_y, 10, max_y-10)
|
21
|
-
gc.line(0, max_y, -10, max_y-10)
|
20
|
+
gc.line(0, max_y, 10, max_y - 10)
|
21
|
+
gc.line(0, max_y, -10, max_y - 10)
|
22
22
|
|
23
23
|
# Draw right-pointing arrow
|
24
24
|
gc.stroke('red')
|
25
25
|
gc.stroke_width(3)
|
26
|
-
gc.line(-max_x+10, 0, max_x-10,
|
27
|
-
gc.line(
|
28
|
-
gc.line(
|
26
|
+
gc.line(-max_x + 10, 0, max_x - 10, 0)
|
27
|
+
gc.line(max_x - 10, 0, max_x - 20, -10)
|
28
|
+
gc.line(max_x - 10, 0, max_x - 20, 10)
|
29
29
|
|
30
30
|
gc.draw(imgl)
|
31
31
|
|
@@ -43,5 +43,5 @@ gc.gravity(Magick::SouthGravity)
|
|
43
43
|
gc.text(10, 20, "'+y'")
|
44
44
|
gc.draw(imgl)
|
45
45
|
|
46
|
-
imgl.border!(1,1, 'lightcyan2')
|
46
|
+
imgl.border!(1, 1, 'lightcyan2')
|
47
47
|
imgl.write('skewy.gif')
|
data/doc/ex/smile.rb
CHANGED
@@ -99,18 +99,19 @@ SmileBits = [
|
|
99
99
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
100
100
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
101
101
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
102
|
-
0, 0, 0, 0
|
102
|
+
0, 0, 0, 0
|
103
|
+
]
|
103
104
|
|
104
105
|
img = Image.new(SmileWidth, SmileHeight)
|
105
106
|
|
106
|
-
q = []
|
107
|
+
q = [] # Create an array of pixels one
|
107
108
|
SmileWidth.times do # row long
|
108
|
-
q << Magick::Pixel.new(0,0,0,0)
|
109
|
+
q << Magick::Pixel.new(0, 0, 0, 0)
|
109
110
|
end
|
110
111
|
|
111
112
|
n = 0
|
112
113
|
SmileHeight.times do |y| # Store pixels a row at a time
|
113
|
-
SmileWidth.times do |x|
|
114
|
+
SmileWidth.times do |x| # Build a row of pixels
|
114
115
|
q[x].red = QuantumRange * SmileBits[n]
|
115
116
|
q[x].green = QuantumRange * SmileBits[n]
|
116
117
|
q[x].blue = QuantumRange * SmileBits[n]
|
data/doc/ex/sparse_color.rb
CHANGED
@@ -16,7 +16,6 @@ imgl = Magick::ImageList.new
|
|
16
16
|
img = Magick::Image.new(100, 100)
|
17
17
|
|
18
18
|
begin
|
19
|
-
|
20
19
|
img2 = img.sparse_color(Magick::VoronoiColorInterpolate, 30, 10, 'red',
|
21
20
|
10, 80, 'blue', 70, 60, 'lime', 80, 20, 'yellow')
|
22
21
|
img2['Label'] = 'Voroni'
|
@@ -44,11 +43,8 @@ begin
|
|
44
43
|
end
|
45
44
|
|
46
45
|
montage.write('sparse_color.png')
|
47
|
-
|
48
46
|
rescue NotImplementedError, NameError
|
49
|
-
|
50
47
|
img = Magick::Image.read('images/notimplemented.gif').first
|
51
48
|
img.resize!(240, 272)
|
52
49
|
img.write('sparse_color.png')
|
53
|
-
|
54
50
|
end
|
data/doc/ex/splice.rb
CHANGED
@@ -4,5 +4,5 @@ require 'rmagick'
|
|
4
4
|
# Demonstrate the splice method.
|
5
5
|
|
6
6
|
img = Magick::Image.read('images/Flower_Hat.jpg').first
|
7
|
-
spliced_img = img.splice(img.columns/2, img.rows/2, 20, 20, 'gray80')
|
7
|
+
spliced_img = img.splice(img.columns / 2, img.rows / 2, 20, 20, 'gray80')
|
8
8
|
spliced_img.write('splice.jpg')
|
data/doc/ex/stegano.rb
CHANGED
@@ -7,14 +7,14 @@ require 'rmagick'
|
|
7
7
|
# shrinking it and converting it to B&W.
|
8
8
|
begin
|
9
9
|
watermark = Magick::Image.read('images/Snake.wmf').first
|
10
|
-
watermark.scale!(64.0/watermark.rows)
|
10
|
+
watermark.scale!(64.0 / watermark.rows)
|
11
11
|
watermark = watermark.quantize(256, Magick::GRAYColorspace)
|
12
12
|
wmrows = watermark.rows
|
13
13
|
wmcols = watermark.columns
|
14
14
|
|
15
15
|
# Read the image in which we'll hide the watermark.
|
16
16
|
img = Magick::Image.read('images/Flower_Hat.jpg').first
|
17
|
-
img.scale!(250.0/img.rows)
|
17
|
+
img.scale!(250.0 / img.rows)
|
18
18
|
|
19
19
|
# Embed the watermark starting at offset 91.
|
20
20
|
puts 'Embedding watermark...'
|
@@ -31,8 +31,8 @@ begin
|
|
31
31
|
|
32
32
|
# This can take some time. Keep track of how far along we are.
|
33
33
|
|
34
|
-
monitor = proc do |
|
35
|
-
printf("Extracting watermark...%3.0f%% complete\n", ((1.0-(quantum/span.to_f))*100.0))
|
34
|
+
monitor = proc do |_text, quantum, span|
|
35
|
+
printf("Extracting watermark...%3.0f%% complete\n", ((1.0 - (quantum / span.to_f)) * 100.0))
|
36
36
|
true
|
37
37
|
end
|
38
38
|
|
@@ -47,7 +47,6 @@ begin
|
|
47
47
|
File.delete('img.miff')
|
48
48
|
|
49
49
|
stegano[0].write('stegano.gif')
|
50
|
-
|
51
50
|
rescue Magick::ImageMagickError
|
52
51
|
puts "#{$PROGRAM_NAME}: ImageMagickError - #{$ERROR_INFO}"
|
53
52
|
end
|
data/doc/ex/stroke_dasharray.rb
CHANGED
@@ -3,22 +3,22 @@
|
|
3
3
|
require 'rmagick'
|
4
4
|
|
5
5
|
imgl = Magick::ImageList.new
|
6
|
-
imgl.new_image(500,180, Magick::HatchFill.new('white','lightcyan2'))
|
6
|
+
imgl.new_image(500, 180, Magick::HatchFill.new('white', 'lightcyan2'))
|
7
7
|
gc = Magick::Draw.new
|
8
8
|
|
9
9
|
gc.stroke_width(5)
|
10
10
|
gc.fill('transparent')
|
11
11
|
|
12
|
-
gc.stroke_dasharray(30,10, 10,10)
|
12
|
+
gc.stroke_dasharray(30, 10, 10, 10)
|
13
13
|
gc.stroke('green')
|
14
14
|
gc.line(10, 20, 490, 20)
|
15
15
|
|
16
|
-
gc.stroke_dasharray(5,10,5)
|
16
|
+
gc.stroke_dasharray(5, 10, 5)
|
17
17
|
gc.stroke_dashoffset(10)
|
18
18
|
gc.stroke('blue')
|
19
19
|
gc.line(10, 80, 490, 80)
|
20
20
|
|
21
|
-
gc.stroke_dasharray(10,10)
|
21
|
+
gc.stroke_dasharray(10, 10)
|
22
22
|
gc.stroke_dashoffset(0)
|
23
23
|
gc.stroke('red')
|
24
24
|
gc.line(10, 140, 490, 140)
|
@@ -29,14 +29,14 @@ gc.font_weight(Magick::NormalWeight)
|
|
29
29
|
gc.font_style(Magick::NormalStyle)
|
30
30
|
|
31
31
|
gc.gravity(Magick::CenterGravity)
|
32
|
-
gc.text(
|
33
|
-
gc.text(
|
34
|
-
gc.text(
|
35
|
-
gc.text(
|
32
|
+
gc.text(0, -60, "'gc.stroke_dasharray(30, 10, 10, 10)'")
|
33
|
+
gc.text(0, 0, "'gc.stroke_dasharray(5, 10, 5)'")
|
34
|
+
gc.text(0, 12, "'gc.stroke_dashoffset(10)'")
|
35
|
+
gc.text(0, 60, "'gc.stroke_dasharray(10, 10)'")
|
36
36
|
|
37
37
|
gc.draw(imgl)
|
38
38
|
|
39
|
-
imgl.border!(1,1,'lightcyan2')
|
40
|
-
#imgl.display
|
39
|
+
imgl.border!(1, 1, 'lightcyan2')
|
40
|
+
# imgl.display
|
41
41
|
imgl.write('stroke_dasharray.gif')
|
42
42
|
exit
|
data/doc/ex/stroke_fill.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rvg/rvg'
|
|
3
3
|
|
4
4
|
rvg = Magick::RVG.new(150, 150) do |canvas|
|
5
5
|
canvas.background_fill = ''
|
6
|
-
canvas.circle(40, 75, 75).styles(:
|
7
|
-
canvas.rect(149,149).styles(:
|
6
|
+
canvas.circle(40, 75, 75).styles(stroke: 'blue', fill: '#00ff00', stroke_width: 8)
|
7
|
+
canvas.rect(149, 149).styles(fill: 'none', stroke: 'blue')
|
8
8
|
end
|
9
9
|
|
10
10
|
rvg.draw.write('stroke_fill.gif')
|
data/doc/ex/stroke_linecap.rb
CHANGED
@@ -9,25 +9,25 @@ gc.stroke('black').stroke_width(30)
|
|
9
9
|
|
10
10
|
# Draw thick line with "butt" linecap
|
11
11
|
gc.stroke_linecap('butt')
|
12
|
-
gc.line(25,50, 175,50)
|
12
|
+
gc.line(25, 50, 175, 50)
|
13
13
|
|
14
14
|
# Draw thick line with "round" linecap
|
15
15
|
gc.stroke_linecap('round')
|
16
|
-
gc.line(225,50, 375,50)
|
16
|
+
gc.line(225, 50, 375, 50)
|
17
17
|
|
18
18
|
# Draw thick line with "square" linecap
|
19
19
|
gc.stroke_linecap('square')
|
20
|
-
gc.line(425,50, 575,50)
|
20
|
+
gc.line(425, 50, 575, 50)
|
21
21
|
|
22
22
|
# Show line endpoints in pink
|
23
23
|
gc.fill('lightpink')
|
24
24
|
gc.stroke('lightpink').stroke_width(3)
|
25
|
-
gc.line(25,50, 175,50)
|
26
|
-
gc.circle(25,50, 27,52).circle(175,50,177,52)
|
27
|
-
gc.line(225,50, 375,50)
|
28
|
-
gc.circle(225,50, 227,52).circle(375,50,377,52)
|
29
|
-
gc.line(425,50, 575, 50)
|
30
|
-
gc.circle(425,50, 427,52).circle(575,50,577,52)
|
25
|
+
gc.line(25, 50, 175, 50)
|
26
|
+
gc.circle(25, 50, 27, 52).circle(175, 50, 177, 52)
|
27
|
+
gc.line(225, 50, 375, 50)
|
28
|
+
gc.circle(225, 50, 227, 52).circle(375, 50, 377, 52)
|
29
|
+
gc.line(425, 50, 575, 50)
|
30
|
+
gc.circle(425, 50, 427, 52).circle(575, 50, 577, 52)
|
31
31
|
|
32
32
|
# Annotate
|
33
33
|
gc.fill('black')
|
@@ -35,9 +35,9 @@ gc.stroke('transparent')
|
|
35
35
|
gc.pointsize(14)
|
36
36
|
gc.font_weight(Magick::BoldWeight)
|
37
37
|
|
38
|
-
gc.text(55,90, "\"'butt' cap\"")
|
39
|
-
gc.text(250,90, "\"'round' cap\"")
|
40
|
-
gc.text(450,90, "\"'square' cap\"")
|
38
|
+
gc.text(55, 90, "\"'butt' cap\"")
|
39
|
+
gc.text(250, 90, "\"'round' cap\"")
|
40
|
+
gc.text(450, 90, "\"'square' cap\"")
|
41
41
|
|
42
42
|
gc.draw(imgl)
|
43
43
|
|
data/doc/ex/stroke_linejoin.rb
CHANGED
@@ -12,36 +12,36 @@ gc.stroke_linecap('butt')
|
|
12
12
|
|
13
13
|
# Draw lines with miter join
|
14
14
|
gc.stroke_linejoin('miter')
|
15
|
-
gc.polyline(25,100, 75,25, 125,100)
|
15
|
+
gc.polyline(25, 100, 75, 25, 125, 100)
|
16
16
|
|
17
17
|
# Draw lines with round join
|
18
18
|
gc.stroke_linejoin('round')
|
19
|
-
gc.polyline(150,100, 200,25, 250,100)
|
19
|
+
gc.polyline(150, 100, 200, 25, 250, 100)
|
20
20
|
|
21
21
|
# Draw lines with bevel join
|
22
22
|
gc.stroke_linejoin('bevel')
|
23
|
-
gc.polyline(275,100, 325,25, 375,100)
|
23
|
+
gc.polyline(275, 100, 325, 25, 375, 100)
|
24
24
|
|
25
25
|
# Show line endpoints in pink
|
26
26
|
gc.fill('lightpink').fill_opacity(0)
|
27
27
|
gc.stroke('lightpink').stroke_width(2)
|
28
28
|
gc.stroke_linejoin('miter')
|
29
|
-
gc.polyline(25,100, 75,25, 125,100)
|
30
|
-
gc.polyline(150,100, 200,25, 250,100)
|
31
|
-
gc.polyline(275,100, 325,25, 375,100)
|
29
|
+
gc.polyline(25, 100, 75, 25, 125, 100)
|
30
|
+
gc.polyline(150, 100, 200, 25, 250, 100)
|
31
|
+
gc.polyline(275, 100, 325, 25, 375, 100)
|
32
32
|
gc.fill_opacity(1)
|
33
|
-
gc.circle(75,25, 76,26)
|
34
|
-
gc.circle(200,25, 201,26)
|
35
|
-
gc.circle(325,25, 326,26)
|
33
|
+
gc.circle(75, 25, 76, 26)
|
34
|
+
gc.circle(200, 25, 201, 26)
|
35
|
+
gc.circle(325, 25, 326, 26)
|
36
36
|
|
37
37
|
# Annotate
|
38
38
|
gc.fill('black')
|
39
39
|
gc.stroke('transparent')
|
40
40
|
gc.pointsize(14)
|
41
41
|
gc.font_weight(Magick::BoldWeight)
|
42
|
-
gc.text(35,120, "\"'miter' join\"")
|
43
|
-
gc.text(160,120, "\"'round' join\"")
|
44
|
-
gc.text(280,120, "\"'bevel' join\"")
|
42
|
+
gc.text(35, 120, "\"'miter' join\"")
|
43
|
+
gc.text(160, 120, "\"'round' join\"")
|
44
|
+
gc.text(280, 120, "\"'bevel' join\"")
|
45
45
|
|
46
46
|
gc.draw(imgl)
|
47
47
|
|
data/doc/ex/stroke_width.rb
CHANGED
@@ -3,47 +3,47 @@
|
|
3
3
|
require 'rmagick'
|
4
4
|
|
5
5
|
imgl = Magick::ImageList.new
|
6
|
-
imgl.new_image(500,80, Magick::HatchFill.new('white','lightcyan2'))
|
6
|
+
imgl.new_image(500, 80, Magick::HatchFill.new('white', 'lightcyan2'))
|
7
7
|
|
8
8
|
gc = Magick::Draw.new
|
9
9
|
|
10
10
|
# Draw 5-pixel wide line
|
11
11
|
gc.stroke('LightPink')
|
12
12
|
gc.stroke_width(5)
|
13
|
-
gc.line(10,30, 130,30)
|
13
|
+
gc.line(10, 30, 130, 30)
|
14
14
|
|
15
15
|
# Draw 10-pixel wide line
|
16
16
|
gc.stroke('LightSkyBlue2')
|
17
17
|
gc.stroke_width(10)
|
18
|
-
gc.line(130,30, 230,30)
|
18
|
+
gc.line(130, 30, 230, 30)
|
19
19
|
|
20
20
|
# Draw 20-pixel wide line
|
21
21
|
gc.stroke('GreenYellow')
|
22
22
|
gc.stroke_width(20)
|
23
|
-
gc.line(230,30,370,30)
|
23
|
+
gc.line(230, 30, 370, 30)
|
24
24
|
|
25
25
|
# Draw 40-pixel wide line
|
26
26
|
gc.stroke('MediumOrchid2')
|
27
27
|
gc.stroke_width(40)
|
28
|
-
gc.line(370,30,490,30)
|
28
|
+
gc.line(370, 30, 490, 30)
|
29
29
|
|
30
30
|
# Draw 1-pixel wide line through the center
|
31
31
|
gc.stroke('black')
|
32
32
|
gc.stroke_width(1)
|
33
|
-
gc.line(10,30,490,30)
|
33
|
+
gc.line(10, 30, 490, 30)
|
34
34
|
|
35
35
|
# Annotate
|
36
36
|
gc.font_weight(Magick::NormalWeight)
|
37
37
|
gc.font_style(Magick::NormalStyle)
|
38
38
|
gc.fill('black')
|
39
39
|
gc.stroke('transparent')
|
40
|
-
gc.text(60,70,"'5'")
|
41
|
-
gc.text(180,70,"'10'")
|
42
|
-
gc.text(300,70,"'20'")
|
43
|
-
gc.text(420,70,"'40'")
|
40
|
+
gc.text(60, 70, "'5'")
|
41
|
+
gc.text(180, 70, "'10'")
|
42
|
+
gc.text(300, 70, "'20'")
|
43
|
+
gc.text(420, 70, "'40'")
|
44
44
|
|
45
45
|
gc.draw(imgl)
|
46
|
-
imgl.border!(1,1,'lightcyan2')
|
46
|
+
imgl.border!(1, 1, 'lightcyan2')
|
47
47
|
|
48
48
|
imgl.write('stroke_width.gif')
|
49
49
|
exit
|