Skip to content

Commit bb4e445

Browse files
authored
Update documents (#18)
1 parent 2f31aa5 commit bb4e445

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+271
-273
lines changed

arcs02.rb.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ <h1>arcs02.rb</h1>
1515

1616
Magick::RVG.dpi = 90
1717

18-
PathStyles = { fill: 'none', stroke: 'red', stroke_width: 6 }
19-
BaseEllipsesStyles = { font_size: 20, font_family: 'Verdana', fill: 'none', stroke: '#888', stroke_width: 2 }
18+
PATH_STYLES = { fill: 'none', stroke: 'red', stroke_width: 6 }
19+
BASE_ELLIPSES_STYLES = { font_size: 20, font_family: 'Verdana', fill: 'none', stroke: '#888', stroke_width: 2 }
2020

2121
rvg = Magick::RVG.new(12.cm, 5.25.cm).viewbox(0, 0, 1200, 525) do |canvas|
2222
canvas.title = 'Example arcs02 - arc options in paths'
@@ -27,7 +27,7 @@ <h1>arcs02.rb</h1>
2727
END_DESC
2828
canvas.background_fill = 'white'
2929

30-
base_ellipses = Magick::RVG::Group.new.styles(BaseEllipsesStyles) do |base|
30+
base_ellipses = Magick::RVG::Group.new.styles(BASE_ELLIPSES_STYLES) do |base|
3131
base.ellipse(100, 50, 125, 125)
3232
base.ellipse(100, 50, 225, 75)
3333
base.text(35, 70, 'Arc start')
@@ -43,28 +43,28 @@ <h1>arcs02.rb</h1>
4343
grp2.text(50, 210, 'large-arc-flag=0')
4444
grp2.text(50, 250, 'sweep-flag=0')
4545
grp2.use(base_ellipses)
46-
grp2.path('M 125,75 a100,50 0 0,0 100,50').styles(PathStyles)
46+
grp2.path('M 125,75 a100,50 0 0,0 100,50').styles(PATH_STYLES)
4747
end
4848

4949
grp.g.translate(800, 0) do |grp2|
5050
grp2.text(50, 210, 'large-arc-flag=0')
5151
grp2.text(50, 250, 'sweep-flag=1')
5252
grp2.use(base_ellipses)
53-
grp2.path('M 125,75 a100,50 0 0,1 100,50').styles(PathStyles)
53+
grp2.path('M 125,75 a100,50 0 0,1 100,50').styles(PATH_STYLES)
5454
end
5555

5656
grp.g.translate(400, 250) do |grp2|
5757
grp2.text(50, 210, 'large-arc-flag=1')
5858
grp2.text(50, 250, 'sweep-flag=0')
5959
grp2.use(base_ellipses)
60-
grp2.path('M 125,75 a100,50 0 1,0 100,50').styles(PathStyles)
60+
grp2.path('M 125,75 a100,50 0 1,0 100,50').styles(PATH_STYLES)
6161
end
6262

6363
grp.g.translate(800, 250) do |grp2|
6464
grp2.text(50, 210, 'large-arc-flag=1')
6565
grp2.text(50, 250, 'sweep-flag=1')
6666
grp2.use(base_ellipses)
67-
grp2.path('M 125,75 a100,50 0 1,1 100,50').styles(PathStyles)
67+
grp2.path('M 125,75 a100,50 0 1,1 100,50').styles(PATH_STYLES)
6868
end
6969
end
7070
end

colors.rb.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ <h1>colors.rb</h1>
1212
<div class="bodyfloat">
1313
<pre>
1414
require 'rmagick'
15-
include Magick
1615

1716
puts('Creating colors.miff. This may take a few seconds...')
1817

19-
colors = ImageList.new
18+
colors = Magick::ImageList.new
2019

2120
# Add a row of "null" colors so we'll have
2221
# room to add the title at the top.
@@ -26,7 +25,7 @@ <h1>colors.rb</h1>
2625

2726
# Create a 200x25 image for each named color.
2827
# Label with the name, RGB values, and compliance type.
29-
colors do |c|
28+
Magick.colors do |c|
3029
if c.name !~ /grey/ # omit SVG 'grays'
3130
colors.new_image(200, 25) do |options|
3231
options.background_color = c.color
@@ -45,7 +44,7 @@ <h1>colors.rb</h1>
4544
# There will be 16 images.
4645
montage = colors.montage do |options|
4746
options.geometry = '200x25+10+5'
48-
options.gravity = CenterGravity
47+
options.gravity = Magick::CenterGravity
4948
options.tile = '4x10'
5049
options.background_color = 'black'
5150
options.border_width = 1
@@ -55,22 +54,22 @@ <h1>colors.rb</h1>
5554

5655
# Add the title at the top, over the 'null:'
5756
# tiles we added at the very beginning.
58-
title = Draw.new
57+
title = Magick::Draw.new
5958
title.annotate(montage, 0, 0, 0, 20, 'Named Colors') do |options|
6059
options.fill = 'white'
6160
options.stroke = 'transparent'
6261
options.pointsize = 32
63-
options.font_weight = BoldWeight
64-
options.gravity = NorthGravity
62+
options.font_weight = Magick::BoldWeight
63+
options.gravity = Magick::NorthGravity
6564
end
6665

6766
puts("\tWriting ./colors.miff")
68-
montage.each { |f| f.compression = ZipCompression }
67+
montage.each { |f| f.compression = Magick::ZipCompression }
6968
montage.write('colors.miff')
7069

7170
# Make a small sample of the full montage to display in the HTML file.
7271
sample = montage[8].crop(55, 325, 495, 110)
73-
sample.page = Rectangle.new(495, 110)
72+
sample.page = Magick::Rectangle.new(495, 110)
7473
sample.write('colors.gif')
7574

7675
exit

composite.rb.html

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,126 +15,125 @@ <h1>composite.rb</h1>
1515
# Based on ImageMagick's composite test.
1616

1717
require 'rmagick'
18-
include Magick
1918

2019
ROWS = 70
2120
COLS = 70
2221
COLOR_A = '#999966'
2322
COLOR_B = '#990066'
2423

25-
img = Image.new(COLS, ROWS)
26-
triangle = Draw.new
24+
img = Magick::Image.new(COLS, ROWS)
25+
triangle = Magick::Draw.new
2726
triangle.fill(COLOR_A)
2827
triangle.stroke('transparent')
2928
triangle.polygon(0, 0, COLS, 0, 0, ROWS, 0, 0)
3029
triangle.draw(img)
31-
image_a = img.transparent('white', alpha: TransparentAlpha)
30+
image_a = img.transparent('white', alpha: Magick::TransparentAlpha)
3231
image_a['Label'] = 'A'
3332

34-
img = Image.new(COLS, ROWS)
35-
triangle = Draw.new
33+
img = Magick::Image.new(COLS, ROWS)
34+
triangle = Magick::Draw.new
3635
triangle.fill(COLOR_B)
3736
triangle.stroke('transparent')
3837
triangle.polygon(0, 0, COLS, ROWS, COLS, 0, 0, 0)
3938
triangle.draw(img)
40-
image__b = img.transparent('white', alpha: TransparentAlpha)
39+
image__b = img.transparent('white', alpha: Magick::TransparentAlpha)
4140
image__b['Label'] = 'B'
4241

43-
list = ImageList.new
44-
null = Image.read('xc:white') { |options| options.size = Geometry.new(COLS, ROWS) }
45-
null = null.first.transparent('white', alpha: TransparentAlpha)
42+
list = Magick::ImageList.new
43+
null = Magick::Image.read('xc:white') { |options| options.size = Magick::Geometry.new(COLS, ROWS) }
44+
null = null.first.transparent('white', alpha: Magick::TransparentAlpha)
4645
null.border_color = 'transparent'
47-
granite = Image.read('granite:')
46+
granite = Magick::Image.read('granite:')
4847

4948
list &lt;&lt; null.copy
5049
list &lt;&lt; image_a
5150
list &lt;&lt; image__b
5251
list &lt;&lt; null.copy
5352

54-
list &lt;&lt; image__b.composite(image_a, CenterGravity, OverCompositeOp)
53+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::OverCompositeOp)
5554
list.cur_image['Label'] = 'A over B'
56-
list &lt;&lt; image_a.composite(image__b, CenterGravity, OverCompositeOp)
55+
list &lt;&lt; image_a.composite(image__b, Magick::CenterGravity, Magick::OverCompositeOp)
5756
list.cur_image['Label'] = 'B over A'
5857

59-
list &lt;&lt; image__b.composite(image_a, CenterGravity, InCompositeOp)
58+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::InCompositeOp)
6059
list.cur_image['Label'] = 'A in B'
61-
list &lt;&lt; image_a.composite(image__b, CenterGravity, InCompositeOp)
60+
list &lt;&lt; image_a.composite(image__b, Magick::CenterGravity, Magick::InCompositeOp)
6261
list.cur_image['Label'] = 'B in A'
6362

64-
list &lt;&lt; image__b.composite(image_a, CenterGravity, OutCompositeOp)
63+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::OutCompositeOp)
6564
list.cur_image['Label'] = 'A out B'
66-
list &lt;&lt; image_a.composite(image__b, CenterGravity, OutCompositeOp)
65+
list &lt;&lt; image_a.composite(image__b, Magick::CenterGravity, Magick::OutCompositeOp)
6766
list.cur_image['Label'] = 'B out A'
6867

69-
list &lt;&lt; image__b.composite(image_a, CenterGravity, AtopCompositeOp)
68+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::AtopCompositeOp)
7069
list.cur_image['Label'] = 'A atop B'
71-
list &lt;&lt; image_a.composite(image__b, CenterGravity, AtopCompositeOp)
70+
list &lt;&lt; image_a.composite(image__b, Magick::CenterGravity, Magick::AtopCompositeOp)
7271
list.cur_image['Label'] = 'B atop A'
7372

74-
list &lt;&lt; image__b.composite(image_a, CenterGravity, XorCompositeOp)
73+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::XorCompositeOp)
7574
list.cur_image['Label'] = 'A xor B'
7675

77-
list &lt;&lt; image__b.composite(image_a, CenterGravity, MultiplyCompositeOp)
76+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::MultiplyCompositeOp)
7877
list.cur_image['Label'] = 'A multiply B'
7978

80-
list &lt;&lt; image__b.composite(image_a, CenterGravity, ScreenCompositeOp)
79+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::ScreenCompositeOp)
8180
list.cur_image['Label'] = 'A screen B'
8281

83-
list &lt;&lt; image__b.composite(image_a, CenterGravity, DarkenCompositeOp)
82+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::DarkenCompositeOp)
8483
list.cur_image['Label'] = 'A darken B'
8584

86-
list &lt;&lt; image__b.composite(image_a, CenterGravity, LightenCompositeOp)
85+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::LightenCompositeOp)
8786
list.cur_image['Label'] = 'A lighten B'
8887

89-
list &lt;&lt; image__b.composite(image_a, CenterGravity, PlusCompositeOp)
88+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::PlusCompositeOp)
9089
list.cur_image['Label'] = 'A plus B'
9190

92-
list &lt;&lt; image__b.composite(image_a, CenterGravity, MinusDstCompositeOp)
91+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::MinusDstCompositeOp)
9392
list.cur_image['Label'] = 'A minus B'
9493

95-
list &lt;&lt; image__b.composite(image_a, CenterGravity, ModulusAddCompositeOp)
94+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::ModulusAddCompositeOp)
9695
list.cur_image['Label'] = 'A add B'
9796

98-
list &lt;&lt; image__b.composite(image_a, CenterGravity, ModulusSubtractCompositeOp)
97+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::ModulusSubtractCompositeOp)
9998
list.cur_image['Label'] = 'A subtract B'
10099

101-
list &lt;&lt; image__b.composite(image_a, CenterGravity, DifferenceCompositeOp)
100+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::DifferenceCompositeOp)
102101
list.cur_image['Label'] = 'A difference B'
103102

104-
list &lt;&lt; image__b.composite(image_a, CenterGravity, HueCompositeOp)
103+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::HueCompositeOp)
105104
list.cur_image['Label'] = 'A hue B'
106105

107-
list &lt;&lt; image__b.composite(image_a, CenterGravity, SaturateCompositeOp)
106+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::SaturateCompositeOp)
108107
list.cur_image['Label'] = 'A saturate B'
109108

110-
list &lt;&lt; image__b.composite(image_a, CenterGravity, LuminizeCompositeOp)
109+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::LuminizeCompositeOp)
111110
list.cur_image['Label'] = 'A luminize B'
112111

113-
list &lt;&lt; image__b.composite(image_a, CenterGravity, ColorizeCompositeOp)
112+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::ColorizeCompositeOp)
114113
list.cur_image['Label'] = 'A colorize B'
115114

116-
list &lt;&lt; image__b.composite(image_a, CenterGravity, BumpmapCompositeOp)
115+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::BumpmapCompositeOp)
117116
list.cur_image['Label'] = 'A bumpmap B'
118117

119-
list &lt;&lt; image__b.composite(image_a, CenterGravity, DissolveCompositeOp)
118+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::DissolveCompositeOp)
120119
list.cur_image['Label'] = 'A dissolve B'
121120

122-
list &lt;&lt; image__b.composite(image_a, CenterGravity, ThresholdCompositeOp)
121+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::ThresholdCompositeOp)
123122
list.cur_image['Label'] = 'A threshold B'
124123

125-
list &lt;&lt; image__b.composite(image_a, CenterGravity, ModulateCompositeOp)
124+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::ModulateCompositeOp)
126125
list.cur_image['Label'] = 'A modulate B'
127126

128-
list &lt;&lt; image_a.composite(image__b, CenterGravity, ModulateCompositeOp)
127+
list &lt;&lt; image_a.composite(image__b, Magick::CenterGravity, Magick::ModulateCompositeOp)
129128
list.cur_image['Label'] = 'B modulate A'
130129

131-
list &lt;&lt; image__b.composite(image_a, CenterGravity, OverlayCompositeOp)
130+
list &lt;&lt; image__b.composite(image_a, Magick::CenterGravity, Magick::OverlayCompositeOp)
132131
list.cur_image['Label'] = 'A overlay B'
133132

134133
montage = list.montage do |options|
135-
options.geometry = Geometry.new(COLS, ROWS, 3, 3)
134+
options.geometry = Magick::Geometry.new(COLS, ROWS, 3, 3)
136135
rows = (list.size + 3) / 4
137-
options.tile = Geometry.new(4, rows)
136+
options.tile = Magick::Geometry.new(4, rows)
138137
options.texture = granite[0]
139138
options.fill = 'white'
140139
options.stroke = 'transparent'

crop_with_gravity.rb.html

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,27 @@ <h1>crop_with_gravity.rb</h1>
1919
# Demo the use of the GravityType argument to Image#crop.
2020

2121
require 'rmagick'
22-
include Magick
2322

24-
shorts = Image.read('images/Shorts.jpg').first
23+
shorts = Magick::Image.read('images/Shorts.jpg').first
2524

2625
regwidth = shorts.columns / 2
2726
regheight = shorts.rows / 2
2827

29-
mask = Image.new(regwidth, regheight) { |info| info.background_color = 'white' }
28+
mask = Magick::Image.new(regwidth, regheight) { |info| info.background_color = 'white' }
3029
mask.alpha(Magick::ActivateAlphaChannel)
31-
mask.quantum_operator(SetQuantumOperator, 0.50 * QuantumRange, AlphaChannel)
30+
mask.quantum_operator(Magick::SetQuantumOperator, 0.50 * Magick::QuantumRange, Magick::AlphaChannel)
3231

33-
black = Image.new(shorts.columns, shorts.rows) { |info| info.background_color = 'black' }
34-
pairs = ImageList.new
32+
black = Magick::Image.new(shorts.columns, shorts.rows) { |info| info.background_color = 'black' }
33+
pairs = Magick::ImageList.new
3534

3635
[
37-
NorthWestGravity, NorthGravity, NorthEastGravity,
38-
WestGravity, CenterGravity, EastGravity,
39-
SouthWestGravity, SouthGravity, SouthEastGravity
36+
Magick::NorthWestGravity, Magick::NorthGravity, Magick::NorthEastGravity,
37+
Magick::WestGravity, Magick::CenterGravity, Magick::EastGravity,
38+
Magick::SouthWestGravity, Magick::SouthGravity, Magick::SouthEastGravity
4039
].each do |gravity|
41-
pattern = shorts.composite(mask, gravity, OverCompositeOp)
40+
pattern = shorts.composite(mask, gravity, Magick::OverCompositeOp)
4241
cropped = shorts.crop(gravity, regwidth, regheight)
43-
result = black.composite(cropped, gravity, OverCompositeOp)
42+
result = black.composite(cropped, gravity, Magick::OverCompositeOp)
4443
result.border_color = 'white'
4544
pairs &lt;&lt; pattern
4645
pairs &lt;&lt; result

cubic01.rb.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ <h1>cubic01.rb</h1>
1515

1616
Magick::RVG.dpi = 90
1717

18-
Border = { fill: 'none', stroke: 'blue', stroke_width: 1 }
19-
Connect = { fill: 'none', stroke: '#888', stroke_width: 2 }
20-
SamplePath = { fill: 'none', stroke: 'red', stroke_width: 5 }
21-
EndPoint = { fill: 'none', stroke: '#888', stroke_width: 2 }
22-
CtlPoint = { fill: '#888', stroke: 'none' }
23-
AutoCtlPoint = { fill: 'none', stroke: 'blue', stroke_width: 4 }
24-
Label = { font_size: 22, font_family: 'Verdana', font_weight: 'normal', font_style: 'normal' }
18+
BORDER = { fill: 'none', stroke: 'blue', stroke_width: 1 }
19+
CONNECT = { fill: 'none', stroke: '#888', stroke_width: 2 }
20+
SAMPLE_PATH = { fill: 'none', stroke: 'red', stroke_width: 5 }
21+
END_POINT = { fill: 'none', stroke: '#888', stroke_width: 2 }
22+
CTL_POINT = { fill: '#888', stroke: 'none' }
23+
AUTO_CTL_POINT = { fill: 'none', stroke: 'blue', stroke_width: 4 }
24+
LABEL = { font_size: 22, font_family: 'Verdana', font_weight: 'normal', font_style: 'normal' }
2525

2626
rvg = Magick::RVG.new(5.cm, 4.cm).viewbox(0, 0, 500, 400) do |canvas|
2727
canvas.title = 'Example cubic01 - cubic Bezier commands in path data'
@@ -32,25 +32,25 @@ <h1>cubic01.rb</h1>
3232
END_DESC
3333

3434
canvas.background_fill = 'white'
35-
canvas.rect(496, 395, 1, 1).styles(Border)
35+
canvas.rect(496, 395, 1, 1).styles(BORDER)
3636

37-
canvas.polyline(100, 200, 100, 100).styles(Connect)
38-
canvas.polyline(250, 100, 250, 200).styles(Connect)
39-
canvas.polyline(250, 200, 250, 300).styles(Connect)
40-
canvas.polyline(400, 300, 400, 200).styles(Connect)
37+
canvas.polyline(100, 200, 100, 100).styles(CONNECT)
38+
canvas.polyline(250, 100, 250, 200).styles(CONNECT)
39+
canvas.polyline(250, 200, 250, 300).styles(CONNECT)
40+
canvas.polyline(400, 300, 400, 200).styles(CONNECT)
4141

42-
canvas.path('M100,200 C100,100 250,100 250,200 S400,300 400,200').styles(SamplePath)
42+
canvas.path('M100,200 C100,100 250,100 250,200 S400,300 400,200').styles(SAMPLE_PATH)
4343

44-
canvas.circle(10, 100, 200).styles(EndPoint)
45-
canvas.circle(10, 250, 200).styles(EndPoint)
46-
canvas.circle(10, 400, 200).styles(EndPoint)
47-
canvas.circle(10, 100, 100).styles(CtlPoint)
48-
canvas.circle(10, 250, 100).styles(CtlPoint)
49-
canvas.circle(10, 400, 300).styles(CtlPoint)
50-
canvas.circle(9, 250, 300).styles(AutoCtlPoint)
44+
canvas.circle(10, 100, 200).styles(END_POINT)
45+
canvas.circle(10, 250, 200).styles(END_POINT)
46+
canvas.circle(10, 400, 200).styles(END_POINT)
47+
canvas.circle(10, 100, 100).styles(CTL_POINT)
48+
canvas.circle(10, 250, 100).styles(CTL_POINT)
49+
canvas.circle(10, 400, 300).styles(CTL_POINT)
50+
canvas.circle(9, 250, 300).styles(AUTO_CTL_POINT)
5151

52-
canvas.text(25, 70, 'M100,200 C100,100 250,100 250,200').styles(Label)
53-
canvas.text(225, 350, 'S400,300 400,200').styles(Label)
52+
canvas.text(25, 70, 'M100,200 C100,100 250,100 250,200').styles(LABEL)
53+
canvas.text(225, 350, 'S400,300 400,200').styles(LABEL)
5454
end
5555

5656
rvg.draw.write('cubic01.gif')

0 commit comments

Comments
 (0)