rmagick4j 0.3.4-java → 0.3.9-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.txt +84 -0
- data/LICENSE.txt +31 -0
- data/README.txt +25 -0
- data/Rakefile +65 -0
- data/lib/magick4j.jar +0 -0
- data/lib/{RMagick.rb → rmagick.rb} +574 -405
- data/lib/rmagick4j/constants.rb +34 -0
- data/lib/rmagick4j/draw.rb +124 -0
- data/lib/rmagick4j/enum.rb +120 -0
- data/lib/rmagick4j/gradient_fill.rb +14 -0
- data/lib/rmagick4j/image.rb +351 -0
- data/lib/rmagick4j/image_list.rb +25 -0
- data/lib/rmagick4j/pixel.rb +170 -0
- data/lib/rmagick4j/rmagick4j.rb +15 -430
- 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 +2 -2
- data/lib/rvg/container.rb +2 -2
- data/lib/rvg/describable.rb +2 -2
- data/lib/rvg/embellishable.rb +2 -2
- data/lib/rvg/misc.rb +3 -3
- data/lib/rvg/paint.rb +7 -2
- data/lib/rvg/pathdata.rb +2 -2
- data/lib/rvg/rvg.rb +3 -3
- data/lib/rvg/stretchable.rb +15 -3
- data/lib/rvg/stylable.rb +2 -2
- data/lib/rvg/text.rb +2 -2
- data/lib/rvg/transformable.rb +2 -2
- data/lib/rvg/units.rb +2 -2
- data/test/RMagickTestSuite.rb +129 -0
- data/test/eyetests/bullseye.rb +151 -0
- data/test/eyetests/doc.rb +79 -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_clip_path.rb +44 -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 +21 -0
- data/test/eyetests/tests/draw_multiline_type_metrics.rb +42 -0
- data/test/eyetests/tests/draw_pattern_1.rb +35 -0
- data/test/eyetests/tests/draw_polygon_affine.rb +22 -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_pop_push.rb +16 -0
- data/test/eyetests/tests/draw_pop_push_translate.rb +22 -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_rectangle_narrow.rb +18 -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_rotate_01.rb +33 -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/draw_scale_01.rb +33 -0
- data/test/eyetests/tests/draw_skewx_01.rb +34 -0
- data/test/eyetests/tests/draw_skewy_01.rb +33 -0
- data/test/eyetests/tests/draw_stroke_miterlimit.rb +21 -0
- data/test/eyetests/tests/effect_blur.rb +9 -0
- data/test/eyetests/tests/effect_charcoal.rb +9 -0
- data/test/eyetests/tests/effect_edge.rb +9 -0
- data/test/eyetests/tests/effect_implode.rb +9 -0
- data/test/eyetests/tests/effect_negate.rb +9 -0
- data/test/eyetests/tests/effect_negate_true.rb +9 -0
- data/test/eyetests/tests/effect_normalize.rb +9 -0
- data/test/eyetests/tests/effect_shade.rb +9 -0
- data/test/eyetests/tests/effect_solarize.rb +10 -0
- data/test/eyetests/tests/effect_wave.rb +9 -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_dot_1.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_area_1.rb +23 -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 +31 -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 +29 -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 +19 -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 +123 -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 +295 -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_dot.rb +273 -0
- data/test/gruff_tests/test/test_legend.rb +68 -0
- data/test/gruff_tests/test/test_line.rb +554 -0
- data/test/gruff_tests/test/test_mini_bar.rb +33 -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_area.rb +52 -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 +43 -0
- data/test/spec/features/step_definitions/geometry_steps.rb +22 -0
- data/test/spec/features/step_definitions/image_filling_steps.rb +49 -0
- data/test/spec/features/support/env.rb +3 -0
- data/test/spec/image_constants.rb +76 -0
- data/test/spec/image_spec.rb +83 -0
- data/test/spec/pixel_spec.rb +89 -0
- metadata +333 -45
- data/lib/RMagick.jar +0 -0
- data/lib/jhlabs-filters.jar +0 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'ftools'
|
3
|
+
|
4
|
+
if ARGV.size == 0
|
5
|
+
puts 'usage: ruby doc.rb directory'
|
6
|
+
exit
|
7
|
+
end
|
8
|
+
|
9
|
+
File.makedirs ARGV[0] unless File.exists?(ARGV[0]) && File.directory?(ARGV[0])
|
10
|
+
|
11
|
+
IMAGE_DIR = File.join(ARGV[0], 'img')
|
12
|
+
|
13
|
+
File.makedirs IMAGE_DIR unless File.exists?(IMAGE_DIR) && File.directory?(IMAGE_DIR)
|
14
|
+
|
15
|
+
TESTS= Dir[File.join(File.dirname(__FILE__),'tests','*.rb')].reject{|x| x=~ /new_image.rb$/ }
|
16
|
+
|
17
|
+
IMAGES = []
|
18
|
+
|
19
|
+
i = 0
|
20
|
+
size = TESTS.size
|
21
|
+
|
22
|
+
TESTS.each do |test|
|
23
|
+
i += 1
|
24
|
+
puts "Running #{test} in JRuby. #{i}/#{size}"
|
25
|
+
`jruby #{test} #{IMAGE_DIR}`
|
26
|
+
puts "Running #{test} in Ruby. #{i}/#{size}"
|
27
|
+
`sh -c 'ruby #{test} #{IMAGE_DIR}'`
|
28
|
+
IMAGES << test.split(/\//).last[0...-3]
|
29
|
+
end
|
30
|
+
|
31
|
+
template = %{
|
32
|
+
<html>
|
33
|
+
|
34
|
+
<head>
|
35
|
+
<title>RMagick4J Vs. RMagick</title>
|
36
|
+
</head>
|
37
|
+
|
38
|
+
<body>
|
39
|
+
These examples are supposed to show:<br/>
|
40
|
+
<ul>
|
41
|
+
<li>There are some bugs in RMagick4J<li>
|
42
|
+
<li>There are still a lot of features left in RMagick4J (I will continue working on this project after GSoC)</li>
|
43
|
+
<li>There are some bugs in ImageMagick and, therefore, in RMagick</li>
|
44
|
+
</ul>
|
45
|
+
<table>
|
46
|
+
<% i = 0 %>
|
47
|
+
<% IMAGES.sort.each do |img| %>
|
48
|
+
<% if i % 4 == 0 %>
|
49
|
+
<tr>
|
50
|
+
<td >RMagick4J</td>
|
51
|
+
<td>RMagick</td>
|
52
|
+
</tr>
|
53
|
+
<% end %>
|
54
|
+
<tr>
|
55
|
+
<td>
|
56
|
+
<img src="<%= File.join('img', img) %>.jruby.jpg"/>
|
57
|
+
</td>
|
58
|
+
<td>
|
59
|
+
<img src="<%= File.join('img', img) %>.mri.jpg"/>
|
60
|
+
</td>
|
61
|
+
</tr>
|
62
|
+
<% i += 1%>
|
63
|
+
<% end %>
|
64
|
+
</table>
|
65
|
+
</body>
|
66
|
+
|
67
|
+
</html>
|
68
|
+
}.gsub(/^ /, '')
|
69
|
+
|
70
|
+
puts 'Running template'
|
71
|
+
rhtml = ERB.new template
|
72
|
+
|
73
|
+
doc = rhtml.result binding
|
74
|
+
|
75
|
+
html = File.new(File.join(ARGV[0], 'index.html'), 'w')
|
76
|
+
|
77
|
+
html.write doc
|
78
|
+
|
79
|
+
html.close
|
@@ -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,44 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
points = [145, 65, 174,151, 264,151, 192,205,
|
6
|
+
218,291, 145,240, 72,291, 98,205,
|
7
|
+
26,151, 116,151]
|
8
|
+
|
9
|
+
pr = Draw.new
|
10
|
+
|
11
|
+
# Define a clip-path.
|
12
|
+
# The name of the clip-path is "example"
|
13
|
+
pr.define_clip_path('example') do
|
14
|
+
pr.polygon(*points)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Enable the clip-path
|
18
|
+
pr.push
|
19
|
+
pr.clip_path('example')
|
20
|
+
|
21
|
+
pr.stroke 'none'
|
22
|
+
|
23
|
+
pr.fill 'green'
|
24
|
+
pr.circle(150, 0, 150, 150)
|
25
|
+
|
26
|
+
pr.fill 'red'
|
27
|
+
pr.circle(0, 150, 150, 150)
|
28
|
+
|
29
|
+
pr.fill 'blue'
|
30
|
+
pr.circle(300, 150, 150, 150)
|
31
|
+
|
32
|
+
pr.fill 'orange'
|
33
|
+
pr.circle(150, 300, 150, 150)
|
34
|
+
|
35
|
+
pr.pop
|
36
|
+
|
37
|
+
# Create a canvas to draw on, a bit bigger than the star.
|
38
|
+
canvas = Image.new(300, 300, HatchFill.new('white', 'black'))
|
39
|
+
|
40
|
+
pr.draw(canvas)
|
41
|
+
|
42
|
+
canvas.write("draw_clip_path.jpg")
|
43
|
+
|
44
|
+
|
@@ -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,21 @@
|
|
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_linecap 'round'
|
9
|
+
draw.stroke_width 10.0
|
10
|
+
|
11
|
+
draw.line(50, 50, 50, 200)
|
12
|
+
draw.stroke('blue')
|
13
|
+
draw.line(50, 200, 200, 200)
|
14
|
+
draw.stroke('green')
|
15
|
+
draw.line(200, 200, 50, 50)
|
16
|
+
|
17
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
18
|
+
|
19
|
+
draw.draw b
|
20
|
+
|
21
|
+
b.write('draw_line_basic.jpg')
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
TEXT = 'get\nmultiline\ntype\nmetrics'
|
6
|
+
|
7
|
+
background = Image.new(200, 200)
|
8
|
+
gc = Draw.new
|
9
|
+
|
10
|
+
# Draw the text centered on the background
|
11
|
+
gc.annotate(background, 0, 0, 0, 0, TEXT) do
|
12
|
+
gc.font_family = 'Verdana'
|
13
|
+
gc.pointsize = 36
|
14
|
+
gc.gravity = CenterGravity
|
15
|
+
gc.stroke = 'none'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get the metrics
|
19
|
+
metrics = gc.get_multiline_type_metrics(background, TEXT)
|
20
|
+
|
21
|
+
# Compute the corners for a rectangle surrounding the text
|
22
|
+
x = (background.columns - metrics.width) / 2
|
23
|
+
y = (background.rows - metrics.height) / 2
|
24
|
+
|
25
|
+
# Draw 2 rectangles over the text.
|
26
|
+
gc = Draw.new
|
27
|
+
|
28
|
+
gc.stroke('red')
|
29
|
+
gc.stroke_width(5)
|
30
|
+
gc.stroke_linejoin('round')
|
31
|
+
gc.fill('cyan')
|
32
|
+
gc.fill_opacity(0.10)
|
33
|
+
gc.rectangle(x, y, x+metrics.width, y+metrics.height)
|
34
|
+
|
35
|
+
gc.stroke('white')
|
36
|
+
gc.stroke_width(1)
|
37
|
+
gc.fill('none')
|
38
|
+
gc.rectangle(x, y, x+metrics.width, y+metrics.height)
|
39
|
+
gc.draw(background)
|
40
|
+
|
41
|
+
|
42
|
+
background.write('draw_multiline_type_metrics.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,22 @@
|
|
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_linejoin 'round'
|
9
|
+
draw.stroke_width 5.0
|
10
|
+
draw.fill = 'red'
|
11
|
+
|
12
|
+
draw.affine(1,0,0,1,-60,100)
|
13
|
+
|
14
|
+
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 }
|
15
|
+
|
16
|
+
draw.polygon(*points)
|
17
|
+
|
18
|
+
b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
19
|
+
|
20
|
+
draw.draw b
|
21
|
+
|
22
|
+
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
|
+
clown = Image.load("clown.jpg").first
|
6
|
+
|
7
|
+
draw = Draw.new
|
8
|
+
draw.push
|
9
|
+
draw.stroke 'green'
|
10
|
+
draw.fill 'yellow'
|
11
|
+
draw.circle clown.columns/2, clown.rows/2, clown.columns/4, clown.rows/2
|
12
|
+
draw.pop
|
13
|
+
|
14
|
+
draw.draw clown
|
15
|
+
|
16
|
+
clown.write "draw_pop_push.jpg"
|