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,22 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
draw = Draw.new
|
6
|
+
|
7
|
+
draw.translate 100, 100
|
8
|
+
draw.circle 100,100, 100, 50
|
9
|
+
draw.stroke 'blue'
|
10
|
+
draw.fill 'white'
|
11
|
+
draw.push
|
12
|
+
draw.circle 100,100, 100, 50
|
13
|
+
draw.translate(-100, -100)
|
14
|
+
draw.fill 'green'
|
15
|
+
draw.pop
|
16
|
+
draw.circle 100, 100, 100, 50
|
17
|
+
|
18
|
+
b = Image.new(300, 300)
|
19
|
+
|
20
|
+
draw.draw b
|
21
|
+
|
22
|
+
b.write('draw_pop_push_translate.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,18 @@
|
|
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.rectangle(200,20, 200,180)
|
9
|
+
|
10
|
+
draw.stroke = 'blue'
|
11
|
+
draw.rectangle(200,180, 80,180)
|
12
|
+
|
13
|
+
# b = Image.new(300, 300, HatchFill.new('white', 'black'))
|
14
|
+
b = Image.new(300, 300)
|
15
|
+
|
16
|
+
draw.draw b
|
17
|
+
|
18
|
+
b.write('draw_rectangle_narrow.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,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
# Taken from RMagick documentation. Modified.
|
4
|
+
|
5
|
+
imgl = Magick::Image.new(200, 200, Magick::HatchFill.new('white','lightcyan2'))
|
6
|
+
|
7
|
+
gc = Magick::Draw.new
|
8
|
+
|
9
|
+
# Move the origin to the center.
|
10
|
+
gc.translate(100, 100)
|
11
|
+
max_x = imgl.columns/2
|
12
|
+
max_y = imgl.rows/2
|
13
|
+
|
14
|
+
# Rotate 45 degrees
|
15
|
+
gc.rotate(45)
|
16
|
+
|
17
|
+
gc.stroke('red')
|
18
|
+
gc.stroke_width(3)
|
19
|
+
|
20
|
+
# Draw down-pointing arrow
|
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)
|
24
|
+
|
25
|
+
# Draw right-pointing arrow
|
26
|
+
gc.line(-max_x, 0, max_x, 0)
|
27
|
+
gc.line( max_x, 0, max_x-10, -10)
|
28
|
+
gc.line( max_x, 0, max_x-10, 10)
|
29
|
+
|
30
|
+
|
31
|
+
gc.draw(imgl)
|
32
|
+
|
33
|
+
imgl.write("draw_rotate_01.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')
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
# Taken from RMagick documentation. Modified.
|
4
|
+
|
5
|
+
imgl = Magick::Image.new(200, 200, Magick::HatchFill.new('white','lightcyan2'))
|
6
|
+
|
7
|
+
gc = Magick::Draw.new
|
8
|
+
|
9
|
+
# Move the origin to the center.
|
10
|
+
gc.translate(100, 100)
|
11
|
+
max_x = imgl.columns/2
|
12
|
+
max_y = imgl.rows/2
|
13
|
+
|
14
|
+
# Scale by 0.5 and 1/3.
|
15
|
+
gc.scale(0.5, 1.0/3.0)
|
16
|
+
|
17
|
+
gc.stroke('red')
|
18
|
+
gc.stroke_width(3)
|
19
|
+
|
20
|
+
# Draw down-pointing arrow
|
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)
|
24
|
+
|
25
|
+
# Draw right-pointing arrow
|
26
|
+
gc.line(-max_x, 0, max_x, 0)
|
27
|
+
gc.line( max_x, 0, max_x-10, -10)
|
28
|
+
gc.line( max_x, 0, max_x-10, 10)
|
29
|
+
|
30
|
+
|
31
|
+
gc.draw(imgl)
|
32
|
+
|
33
|
+
imgl.write("draw_scale_01.jpg")
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
# Taken from RMagick documentation. Modified.
|
4
|
+
|
5
|
+
imgl = Magick::Image.new(250, 250, Magick::HatchFill.new('white','lightcyan2'))
|
6
|
+
|
7
|
+
gc = Magick::Draw.new
|
8
|
+
|
9
|
+
# Move the origin to the center.
|
10
|
+
gc.translate(125, 125)
|
11
|
+
max_x = imgl.columns/2
|
12
|
+
max_y = imgl.rows/2 - 5
|
13
|
+
|
14
|
+
# Skew x 30 degrees
|
15
|
+
gc.skewx(30)
|
16
|
+
|
17
|
+
# Draw down-pointing arrow
|
18
|
+
gc.fill('red')
|
19
|
+
gc.stroke('red')
|
20
|
+
gc.stroke_width(3)
|
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)
|
24
|
+
|
25
|
+
# Draw right-pointing arrow
|
26
|
+
gc.stroke('gray50')
|
27
|
+
gc.stroke_width(1)
|
28
|
+
gc.line(-max_x, 0, max_x, 0)
|
29
|
+
gc.line( max_x, 0, max_x-5, -5)
|
30
|
+
gc.line( max_x, 0, max_x-5, 5)
|
31
|
+
|
32
|
+
gc.draw(imgl)
|
33
|
+
|
34
|
+
imgl.write("draw_skewx_01.jpg")
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'new_image.rb')
|
2
|
+
|
3
|
+
# Taken from RMagick documentation. Modified.
|
4
|
+
|
5
|
+
imgl = Magick::Image.new(300, 300, Magick::HatchFill.new('white','lightcyan2'))
|
6
|
+
|
7
|
+
gc = Magick::Draw.new
|
8
|
+
|
9
|
+
# Move the origin to the center.
|
10
|
+
gc.translate(125, 125)
|
11
|
+
max_x = imgl.columns/2
|
12
|
+
max_y = imgl.rows/2
|
13
|
+
|
14
|
+
# Skew y 30 degrees
|
15
|
+
gc.skewy(30)
|
16
|
+
|
17
|
+
# Draw down-pointing arrow
|
18
|
+
gc.fill('gray50')
|
19
|
+
|
20
|
+
gc.line(0, -max_y, 0, max_y)
|
21
|
+
gc.line(0, max_y, 10, max_y-10)
|
22
|
+
gc.line(0, max_y, -10, max_y-10)
|
23
|
+
|
24
|
+
# Draw right-pointing arrow
|
25
|
+
gc.stroke('red')
|
26
|
+
gc.stroke_width(3)
|
27
|
+
gc.line(-max_x+10, 0, max_x-10, 0)
|
28
|
+
gc.line( max_x-10, 0, max_x-20, -10)
|
29
|
+
gc.line( max_x-10, 0, max_x-20, 10)
|
30
|
+
|
31
|
+
gc.draw(imgl)
|
32
|
+
|
33
|
+
imgl.write("draw_skewy_01.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 = 'blue'
|
8
|
+
draw.stroke_linejoin 'miter'
|
9
|
+
draw.stroke_miterlimit 5.0
|
10
|
+
draw.stroke_width 5.0
|
11
|
+
draw.fill = 'red'
|
12
|
+
|
13
|
+
points = [125,300,175,300,150,50]
|
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_stroke_miterlimit.jpg')
|