rmagick4j 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +84 -0
- data/LICENSE.txt +9 -0
- data/Manifest.txt +142 -0
- data/README.txt +25 -0
- data/Rakefile +109 -0
- data/lib/RMagick.rb +1861 -0
- data/lib/jhlabs-filters.jar +0 -0
- data/lib/magick4j.jar +0 -0
- data/lib/rmagick4j/constants.rb +21 -0
- data/lib/rmagick4j/draw.rb +86 -0
- data/lib/rmagick4j/enum.rb +120 -0
- data/lib/rmagick4j/gradient_fill.rb +14 -0
- data/lib/rmagick4j/image.rb +289 -0
- data/lib/rmagick4j/image_list.rb +21 -0
- data/lib/rmagick4j/pixel.rb +170 -0
- data/lib/rmagick4j/rmagick4j.rb +19 -0
- data/lib/rmagick4j/texture_fill.rb +14 -0
- data/lib/rmagick4j/type_metric.rb +8 -0
- data/lib/rmagick4j/version.rb +5 -0
- data/lib/rvg/clippath.rb +48 -0
- data/lib/rvg/container.rb +131 -0
- data/lib/rvg/deep_equal.rb +56 -0
- data/lib/rvg/describable.rb +53 -0
- data/lib/rvg/embellishable.rb +417 -0
- data/lib/rvg/misc.rb +739 -0
- data/lib/rvg/paint.rb +55 -0
- data/lib/rvg/pathdata.rb +131 -0
- data/lib/rvg/rvg.rb +283 -0
- data/lib/rvg/stretchable.rb +168 -0
- data/lib/rvg/stylable.rb +118 -0
- data/lib/rvg/text.rb +187 -0
- data/lib/rvg/transformable.rb +133 -0
- data/lib/rvg/units.rb +66 -0
- data/lib/svgsalamander.jar +0 -0
- data/test/RMagickTestSuite.rb +129 -0
- data/test/eyetests/bullseye.rb +150 -0
- data/test/eyetests/tests/draw_arc_basic.rb +16 -0
- data/test/eyetests/tests/draw_circle_affine.rb +19 -0
- data/test/eyetests/tests/draw_circle_basic.rb +16 -0
- data/test/eyetests/tests/draw_ellipse_affine.rb +19 -0
- data/test/eyetests/tests/draw_ellipse_basic.rb +16 -0
- data/test/eyetests/tests/draw_line_affine.rb +24 -0
- data/test/eyetests/tests/draw_line_basic.rb +20 -0
- data/test/eyetests/tests/draw_pattern_1.rb +35 -0
- data/test/eyetests/tests/draw_polygon_affine.rb +21 -0
- data/test/eyetests/tests/draw_polygon_basic.rb +19 -0
- data/test/eyetests/tests/draw_polyline_affine.rb +19 -0
- data/test/eyetests/tests/draw_polyline_basic.rb +18 -0
- data/test/eyetests/tests/draw_rectangle_affine.rb +16 -0
- data/test/eyetests/tests/draw_rectangle_basic.rb +16 -0
- data/test/eyetests/tests/draw_rmagick_test_01.rb +35 -0
- data/test/eyetests/tests/draw_rmagick_test_02.rb +40 -0
- data/test/eyetests/tests/draw_rmagick_test_03.rb +17 -0
- data/test/eyetests/tests/draw_rmagick_test_04.rb +21 -0
- data/test/eyetests/tests/draw_roundrectangle_affine.rb +19 -0
- data/test/eyetests/tests/draw_roundrectangle_basic.rb +16 -0
- data/test/eyetests/tests/gradient_fill_horizontal_diagonal_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_horizontal_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_point_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_vertical_diagonal_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_vertical_fill.rb +9 -0
- data/test/eyetests/tests/gruff_accumulator_bar.rb +29 -0
- data/test/eyetests/tests/gruff_area_1.rb +16 -0
- data/test/eyetests/tests/gruff_area_2.rb +27 -0
- data/test/eyetests/tests/gruff_bar_1.rb +29 -0
- data/test/eyetests/tests/gruff_bar_2.rb +19 -0
- data/test/eyetests/tests/gruff_line_1.rb +13 -0
- data/test/eyetests/tests/gruff_line_2.rb +20 -0
- data/test/eyetests/tests/gruff_net_1.rb +16 -0
- data/test/eyetests/tests/gruff_net_2.rb +16 -0
- data/test/eyetests/tests/gruff_pie_1.rb +21 -0
- data/test/eyetests/tests/gruff_pie_2.rb +22 -0
- data/test/eyetests/tests/gruff_scene_1.rb +14 -0
- data/test/eyetests/tests/gruff_scene_2.rb +14 -0
- data/test/eyetests/tests/gruff_sidebar.rb +32 -0
- data/test/eyetests/tests/gruff_sidestacked_bar_1.rb +26 -0
- data/test/eyetests/tests/gruff_sidestacked_bar_2.rb +26 -0
- data/test/eyetests/tests/gruff_spider_1.rb +22 -0
- data/test/eyetests/tests/gruff_spider_2.rb +15 -0
- data/test/eyetests/tests/gruff_stacked_bar_1.rb +23 -0
- data/test/eyetests/tests/gruff_stacked_bar_2.rb +26 -0
- data/test/eyetests/tests/hatch_fill.rb +9 -0
- data/test/eyetests/tests/image_list_flatten_images.rb +15 -0
- data/test/eyetests/tests/new_image.rb +24 -0
- data/test/eyetests/tests/path_a_command_01.rb +16 -0
- data/test/eyetests/tests/path_a_command_02.rb +19 -0
- data/test/eyetests/tests/path_c_command_01.rb +16 -0
- data/test/eyetests/tests/path_c_command_02.rb +16 -0
- data/test/eyetests/tests/path_complex_01.rb +16 -0
- data/test/eyetests/tests/path_espiral_01.rb +28 -0
- data/test/eyetests/tests/path_h_command_01.rb +16 -0
- data/test/eyetests/tests/path_h_command_02.rb +16 -0
- data/test/eyetests/tests/path_l_command_01.rb +16 -0
- data/test/eyetests/tests/path_l_command_02.rb +16 -0
- data/test/eyetests/tests/path_m_command_01.rb +16 -0
- data/test/eyetests/tests/path_m_command_02.rb +16 -0
- data/test/eyetests/tests/path_m_command_03.rb +16 -0
- data/test/eyetests/tests/path_q_command_01.rb +16 -0
- data/test/eyetests/tests/path_q_command_02.rb +16 -0
- data/test/eyetests/tests/path_q_command_03.rb +25 -0
- data/test/eyetests/tests/path_s_command_01.rb +16 -0
- data/test/eyetests/tests/path_s_command_02.rb +16 -0
- data/test/eyetests/tests/path_star_01.rb +16 -0
- data/test/eyetests/tests/path_t_command_01.rb +16 -0
- data/test/eyetests/tests/path_t_command_02.rb +16 -0
- data/test/eyetests/tests/path_v_command_01.rb +16 -0
- data/test/eyetests/tests/path_v_command_02.rb +16 -0
- data/test/eyetests/tests/store_pixel_smiley.rb +123 -0
- data/test/eyetests/tests/texture_fill.rb +11 -0
- data/test/gruff_tests/test/gruff_test_case.rb +120 -0
- data/test/gruff_tests/test/monkey_gruff.rb +7 -0
- data/test/gruff_tests/test/test_accumulator_bar.rb +50 -0
- data/test/gruff_tests/test/test_area.rb +134 -0
- data/test/gruff_tests/test/test_bar.rb +283 -0
- data/test/gruff_tests/test/test_base.rb +8 -0
- data/test/gruff_tests/test/test_bullet.rb +26 -0
- data/test/gruff_tests/test/test_legend.rb +71 -0
- data/test/gruff_tests/test/test_line.rb +493 -0
- data/test/gruff_tests/test/test_mini_bar.rb +32 -0
- data/test/gruff_tests/test/test_mini_pie.rb +20 -0
- data/test/gruff_tests/test/test_mini_side_bar.rb +37 -0
- data/test/gruff_tests/test/test_net.rb +230 -0
- data/test/gruff_tests/test/test_photo.rb +41 -0
- data/test/gruff_tests/test/test_pie.rb +154 -0
- data/test/gruff_tests/test/test_scene.rb +100 -0
- data/test/gruff_tests/test/test_side_bar.rb +12 -0
- data/test/gruff_tests/test/test_sidestacked_bar.rb +89 -0
- data/test/gruff_tests/test/test_spider.rb +216 -0
- data/test/gruff_tests/test/test_stacked_bar.rb +52 -0
- data/test/images/clown.jpg +0 -0
- data/test/images/texture.jpg +0 -0
- data/test/implemented_methods.rb +18 -0
- data/test/spec/draw_spec.rb +24 -0
- data/test/spec/image_constants.rb +76 -0
- data/test/spec/image_spec.rb +23 -0
- data/test/spec/pixel_spec.rb +84 -0
- data/test/spec/stories/geometry_runner.rb +13 -0
- data/test/spec/stories/geometry_steps.rb +24 -0
- data/test/spec/stories/geometry_story.rb +116 -0
- data/test/spec/stories/image_filling_runner.rb +13 -0
- data/test/spec/stories/image_filling_steps.rb +64 -0
- data/test/spec/stories/image_filling_story.rb +41 -0
- metadata +215 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'red'
|
8
|
+
draw.fill_opacity 0.0
|
9
|
+
|
10
|
+
draw.arc(40, 50, 250, 180, 0, 270)
|
11
|
+
|
12
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
13
|
+
|
14
|
+
draw.draw b
|
15
|
+
|
16
|
+
b.write('draw_arc_basic.jpg')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'LightCyan2'
|
8
|
+
draw.fill = 'LightCyan2'
|
9
|
+
draw.affine(2,0,0,3,0,0) # Scale 2x 3y
|
10
|
+
angle = 15*Math::PI/180
|
11
|
+
draw.affine(Math.cos(angle),-Math.sin(angle),Math.sin(angle),Math.cos(angle),0,0)
|
12
|
+
|
13
|
+
draw.circle(50,50, 50,70)
|
14
|
+
|
15
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
16
|
+
|
17
|
+
draw.draw b
|
18
|
+
|
19
|
+
b.write('draw_circle_affine.jpg')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'LightCyan2'
|
8
|
+
draw.fill = 'LightCyan2'
|
9
|
+
|
10
|
+
draw.circle(100,100, 200,180)
|
11
|
+
|
12
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
13
|
+
|
14
|
+
draw.draw b
|
15
|
+
|
16
|
+
b.write('draw_circle_basic.jpg')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'red'
|
8
|
+
draw.fill_opacity 0.0
|
9
|
+
draw.affine(2,0,0,3,0,0) # Scale 2x 3y
|
10
|
+
angle = 15*Math::PI/180
|
11
|
+
draw.affine(Math.cos(angle),-Math.sin(angle),Math.sin(angle),Math.cos(angle),0,0)
|
12
|
+
|
13
|
+
draw.ellipse(180,125, 150,75, 90, 270)
|
14
|
+
|
15
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
16
|
+
|
17
|
+
draw.draw b
|
18
|
+
|
19
|
+
b.write('draw_ellipse_affine.jpg')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'red'
|
8
|
+
draw.fill_opacity 0.0
|
9
|
+
|
10
|
+
draw.ellipse(180,125, 150,75, 90, 270)
|
11
|
+
|
12
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
13
|
+
|
14
|
+
draw.draw b
|
15
|
+
|
16
|
+
b.write('draw_ellipse_basic.jpg')
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'red'
|
8
|
+
draw.stroke_width 10.0
|
9
|
+
draw.line(50, 50, 50, 200)
|
10
|
+
|
11
|
+
draw.stroke('blue')
|
12
|
+
draw.affine(2,0,0,3,0,0) # Scale 2x 3y
|
13
|
+
draw.line(50, 200, 200, 200)
|
14
|
+
|
15
|
+
angle = 15*Math::PI/180
|
16
|
+
draw.affine(Math.cos(angle),-Math.sin(angle),Math.sin(angle),Math.cos(angle),0,0)
|
17
|
+
draw.stroke('green')
|
18
|
+
draw.line(200, 200, 50, 50)
|
19
|
+
|
20
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
21
|
+
|
22
|
+
draw.draw b
|
23
|
+
|
24
|
+
b.write('draw_line_affine.jpg')
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'red'
|
8
|
+
draw.stroke_width 10.0
|
9
|
+
|
10
|
+
draw.line(50, 50, 50, 200)
|
11
|
+
draw.stroke('blue')
|
12
|
+
draw.line(50, 200, 200, 200)
|
13
|
+
draw.stroke('green')
|
14
|
+
draw.line(200, 200, 50, 50)
|
15
|
+
|
16
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
17
|
+
|
18
|
+
draw.draw b
|
19
|
+
|
20
|
+
b.write('draw_line_basic.jpg')
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
gc = Magick::Draw.new
|
6
|
+
gc.pattern('green', 0, 0, 16, 16) do
|
7
|
+
gc.stroke('none')
|
8
|
+
gc.fill('DarkBlue')
|
9
|
+
gc.rectangle(0,0, 16,16)
|
10
|
+
gc.fill('yellow')
|
11
|
+
gc.stroke('red')
|
12
|
+
gc.polygon(0,0, 8,16, 16,0, 0,0)
|
13
|
+
end
|
14
|
+
|
15
|
+
gc.pattern('blue', 5, 5, 16, 16) do
|
16
|
+
gc.stroke('none')
|
17
|
+
gc.fill('yellow')
|
18
|
+
gc.rectangle(0, 0, 16, 16)
|
19
|
+
gc.fill('red')
|
20
|
+
gc.stroke('DarkBlue')
|
21
|
+
gc.polygon(0,16, 8,0, 16,16, 0,16)
|
22
|
+
end
|
23
|
+
|
24
|
+
gc.stroke('green')
|
25
|
+
gc.stroke_width(16)
|
26
|
+
gc.fill('blue')
|
27
|
+
gc.ellipse(150, 75, 130, 60, 0, 360)
|
28
|
+
|
29
|
+
img = Magick::Image.new(300, 150, Magick::HatchFill.new('white','LightCyan2',8))
|
30
|
+
gc.draw(img)
|
31
|
+
|
32
|
+
#img.border!(1,1, "LightCyan2")
|
33
|
+
|
34
|
+
img.write('draw_pattern_1.jpg')
|
35
|
+
exit
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'blue'
|
8
|
+
draw.stroke_width 5.0
|
9
|
+
draw.fill = 'red'
|
10
|
+
|
11
|
+
draw.affine(1,0,0,1,-60,100)
|
12
|
+
|
13
|
+
points = [350,75,379,161,469,161,397,215,423,301,350,250,277,301,303,215,231,161,321,161].collect { |x| x/2.round }
|
14
|
+
|
15
|
+
draw.polygon(*points)
|
16
|
+
|
17
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
18
|
+
|
19
|
+
draw.draw b
|
20
|
+
|
21
|
+
b.write('draw_polygon_affine.jpg')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'blue'
|
8
|
+
draw.stroke_width 5.0
|
9
|
+
draw.fill = 'red'
|
10
|
+
|
11
|
+
points = [350,75,379,161,469,161,397,215,423,301,350,250,277,301,303,215,231,161,321,161].collect { |x| x/2.round }
|
12
|
+
|
13
|
+
draw.polygon(*points)
|
14
|
+
|
15
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
16
|
+
|
17
|
+
draw.draw b
|
18
|
+
|
19
|
+
b.write('draw_polygon_basic.jpg')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'blue'
|
8
|
+
draw.stroke_width 5.0
|
9
|
+
draw.affine(1,0,0,1,-60,100)
|
10
|
+
|
11
|
+
points = [350,75,379,161,469,161,397,215,423,301,350,250,277,301,303,215,231,161,321,161].collect { |x| x/2.round }
|
12
|
+
|
13
|
+
draw.polyline(*points)
|
14
|
+
|
15
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
16
|
+
|
17
|
+
draw.draw b
|
18
|
+
|
19
|
+
b.write('draw_polyline_affine.jpg')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'blue'
|
8
|
+
draw.stroke_width 5.0
|
9
|
+
|
10
|
+
points = [350,75,379,161,469,161,397,215,423,301,350,250,277,301,303,215,231,161,321,161].collect { |x| x/2.round }
|
11
|
+
|
12
|
+
draw.polyline(*points)
|
13
|
+
|
14
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
15
|
+
|
16
|
+
draw.draw b
|
17
|
+
|
18
|
+
b.write('draw_polyline_basic.jpg')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'green'
|
8
|
+
draw.affine(2,0,0,3,50,20)
|
9
|
+
|
10
|
+
draw.rectangle(200,20, 80,180)
|
11
|
+
|
12
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
13
|
+
|
14
|
+
draw.draw b
|
15
|
+
|
16
|
+
b.write('draw_rectangle_affine.jpg')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'green'
|
8
|
+
draw.affine(2,0,0,3,0,0)
|
9
|
+
|
10
|
+
draw.rectangle(200,20, 80,180)
|
11
|
+
|
12
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
13
|
+
|
14
|
+
draw.draw b
|
15
|
+
|
16
|
+
b.write('draw_rectangle_basic.jpg')
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
canvas = Image.new(240, 300,
|
6
|
+
HatchFill.new('white','lightcyan2'))
|
7
|
+
gc = Draw.new
|
8
|
+
|
9
|
+
# Draw ellipse
|
10
|
+
gc.stroke('red')
|
11
|
+
gc.stroke_width(3)
|
12
|
+
gc.fill_opacity(0)
|
13
|
+
gc.ellipse(120, 150, 80, 120, 0, 270)
|
14
|
+
|
15
|
+
# Draw endpoints
|
16
|
+
gc.stroke('gray50')
|
17
|
+
gc.stroke_width(1)
|
18
|
+
gc.circle(120, 150, 124, 150)
|
19
|
+
gc.circle(200, 150, 204, 150)
|
20
|
+
gc.circle(120, 30, 124, 30)
|
21
|
+
|
22
|
+
# Draw lines
|
23
|
+
gc.line(120, 150, 200, 150)
|
24
|
+
gc.line(120, 150, 120, 30)
|
25
|
+
|
26
|
+
# Annotate (not yet implemented)
|
27
|
+
#gc.stroke('transparent')
|
28
|
+
#gc.fill('black')
|
29
|
+
#gc.text(130, 35, "End")
|
30
|
+
#gc.text(188, 135, "Start")
|
31
|
+
#gc.text(130, 95, "'Height=120'")
|
32
|
+
#gc.text(55, 155, "'Width=80'")
|
33
|
+
|
34
|
+
gc.draw(canvas)
|
35
|
+
canvas.write('draw_rmagick_test_01.jpg')
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
canvas = Image.new(300, 300,
|
6
|
+
HatchFill.new('white','lightcyan2'))
|
7
|
+
gc = Draw.new
|
8
|
+
|
9
|
+
# Draw curve
|
10
|
+
gc.stroke('blue')
|
11
|
+
gc.stroke_width(3)
|
12
|
+
gc.fill_opacity(0)
|
13
|
+
gc.bezier(45,150, 45,20, 195,280, 195,150)
|
14
|
+
|
15
|
+
# Draw endpoints
|
16
|
+
gc.stroke('gray50')
|
17
|
+
gc.stroke_width(1)
|
18
|
+
gc.circle(45,150, 49,150)
|
19
|
+
gc.circle(195,150, 199,150)
|
20
|
+
|
21
|
+
# Draw control points
|
22
|
+
gc.fill_opacity(1)
|
23
|
+
gc.fill('gray50')
|
24
|
+
gc.circle(45,17, 49,17)
|
25
|
+
gc.circle(195,280, 199,280)
|
26
|
+
|
27
|
+
# Connect the points
|
28
|
+
gc.line(45,150, 45,17)
|
29
|
+
gc.line(195,280, 195,150)
|
30
|
+
|
31
|
+
# Annotate
|
32
|
+
#gc.stroke('transparent').fill('black')
|
33
|
+
#gc.text(27, 175, "'45,150'")
|
34
|
+
#gc.text(175,138, "'195,150'")
|
35
|
+
#gc.text(55,22, "'45,20'")
|
36
|
+
#gc.text(143,285, "'195,280'")
|
37
|
+
|
38
|
+
gc.draw(canvas)
|
39
|
+
|
40
|
+
canvas.write('draw_rmagick_test_02.jpg')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
canvas = Image.new(300, 300,
|
6
|
+
HatchFill.new('white','lightcyan2'))
|
7
|
+
gc = Draw.new
|
8
|
+
|
9
|
+
gc.fill('red')
|
10
|
+
gc.stroke('blue')
|
11
|
+
gc.stroke_width(2)
|
12
|
+
gc.path('M120,150 h-75 a75,75 0 1, 0 75,-75 z')
|
13
|
+
gc.fill('yellow')
|
14
|
+
gc.path('M108.5,138.5 v-75 a75,75 0 0,0 -75,75 z')
|
15
|
+
gc.draw(canvas)
|
16
|
+
|
17
|
+
canvas.write('draw_rmagick_test_03.jpg')
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
canvas = Image.new(240, 300,
|
6
|
+
HatchFill.new('white','lightcyan2'))
|
7
|
+
gc = Draw.new
|
8
|
+
|
9
|
+
gc.stroke('#001aff')
|
10
|
+
gc.stroke_width(3)
|
11
|
+
gc.fill('#00ff00')
|
12
|
+
|
13
|
+
x = 120
|
14
|
+
y = 32.5
|
15
|
+
gc.polygon(x, y, x+29, y+86, x+109, y+86,
|
16
|
+
x+47, y+140, x+73, y+226, x, y+175,
|
17
|
+
x-73, y+226, x-47, y+140, x-109, y+86,
|
18
|
+
x-29, y+86)
|
19
|
+
|
20
|
+
gc.draw(canvas)
|
21
|
+
canvas.write('draw_rmagick_test_04.jpg')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'LightCyan2'
|
8
|
+
draw.fill 'LightCyan2'
|
9
|
+
draw.affine(2,0,0,3,50,20)
|
10
|
+
angle = 15*Math::PI/180
|
11
|
+
draw.affine(Math.cos(angle),-Math.sin(angle),Math.sin(angle),Math.cos(angle),0,0)
|
12
|
+
|
13
|
+
draw.roundrectangle(20,20, 280,180, 8, 8)
|
14
|
+
|
15
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
16
|
+
|
17
|
+
draw.draw b
|
18
|
+
|
19
|
+
b.write('draw_roundrectangle_affine.jpg')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.stroke = 'LightCyan2'
|
8
|
+
draw.fill 'LightCyan2'
|
9
|
+
|
10
|
+
draw.roundrectangle(20,20, 280,180, 8, 8)
|
11
|
+
|
12
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
13
|
+
|
14
|
+
draw.draw b
|
15
|
+
|
16
|
+
b.write('draw_roundrectangle_basic.jpg')
|