rmagick4j 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/History.txt +84 -0
  2. data/LICENSE.txt +9 -0
  3. data/Manifest.txt +142 -0
  4. data/README.txt +25 -0
  5. data/Rakefile +109 -0
  6. data/lib/RMagick.rb +1861 -0
  7. data/lib/jhlabs-filters.jar +0 -0
  8. data/lib/magick4j.jar +0 -0
  9. data/lib/rmagick4j/constants.rb +21 -0
  10. data/lib/rmagick4j/draw.rb +86 -0
  11. data/lib/rmagick4j/enum.rb +120 -0
  12. data/lib/rmagick4j/gradient_fill.rb +14 -0
  13. data/lib/rmagick4j/image.rb +289 -0
  14. data/lib/rmagick4j/image_list.rb +21 -0
  15. data/lib/rmagick4j/pixel.rb +170 -0
  16. data/lib/rmagick4j/rmagick4j.rb +19 -0
  17. data/lib/rmagick4j/texture_fill.rb +14 -0
  18. data/lib/rmagick4j/type_metric.rb +8 -0
  19. data/lib/rmagick4j/version.rb +5 -0
  20. data/lib/rvg/clippath.rb +48 -0
  21. data/lib/rvg/container.rb +131 -0
  22. data/lib/rvg/deep_equal.rb +56 -0
  23. data/lib/rvg/describable.rb +53 -0
  24. data/lib/rvg/embellishable.rb +417 -0
  25. data/lib/rvg/misc.rb +739 -0
  26. data/lib/rvg/paint.rb +55 -0
  27. data/lib/rvg/pathdata.rb +131 -0
  28. data/lib/rvg/rvg.rb +283 -0
  29. data/lib/rvg/stretchable.rb +168 -0
  30. data/lib/rvg/stylable.rb +118 -0
  31. data/lib/rvg/text.rb +187 -0
  32. data/lib/rvg/transformable.rb +133 -0
  33. data/lib/rvg/units.rb +66 -0
  34. data/lib/svgsalamander.jar +0 -0
  35. data/test/RMagickTestSuite.rb +129 -0
  36. data/test/eyetests/bullseye.rb +150 -0
  37. data/test/eyetests/tests/draw_arc_basic.rb +16 -0
  38. data/test/eyetests/tests/draw_circle_affine.rb +19 -0
  39. data/test/eyetests/tests/draw_circle_basic.rb +16 -0
  40. data/test/eyetests/tests/draw_ellipse_affine.rb +19 -0
  41. data/test/eyetests/tests/draw_ellipse_basic.rb +16 -0
  42. data/test/eyetests/tests/draw_line_affine.rb +24 -0
  43. data/test/eyetests/tests/draw_line_basic.rb +20 -0
  44. data/test/eyetests/tests/draw_pattern_1.rb +35 -0
  45. data/test/eyetests/tests/draw_polygon_affine.rb +21 -0
  46. data/test/eyetests/tests/draw_polygon_basic.rb +19 -0
  47. data/test/eyetests/tests/draw_polyline_affine.rb +19 -0
  48. data/test/eyetests/tests/draw_polyline_basic.rb +18 -0
  49. data/test/eyetests/tests/draw_rectangle_affine.rb +16 -0
  50. data/test/eyetests/tests/draw_rectangle_basic.rb +16 -0
  51. data/test/eyetests/tests/draw_rmagick_test_01.rb +35 -0
  52. data/test/eyetests/tests/draw_rmagick_test_02.rb +40 -0
  53. data/test/eyetests/tests/draw_rmagick_test_03.rb +17 -0
  54. data/test/eyetests/tests/draw_rmagick_test_04.rb +21 -0
  55. data/test/eyetests/tests/draw_roundrectangle_affine.rb +19 -0
  56. data/test/eyetests/tests/draw_roundrectangle_basic.rb +16 -0
  57. data/test/eyetests/tests/gradient_fill_horizontal_diagonal_fill.rb +9 -0
  58. data/test/eyetests/tests/gradient_fill_horizontal_fill.rb +9 -0
  59. data/test/eyetests/tests/gradient_fill_point_fill.rb +9 -0
  60. data/test/eyetests/tests/gradient_fill_vertical_diagonal_fill.rb +9 -0
  61. data/test/eyetests/tests/gradient_fill_vertical_fill.rb +9 -0
  62. data/test/eyetests/tests/gruff_accumulator_bar.rb +29 -0
  63. data/test/eyetests/tests/gruff_area_1.rb +16 -0
  64. data/test/eyetests/tests/gruff_area_2.rb +27 -0
  65. data/test/eyetests/tests/gruff_bar_1.rb +29 -0
  66. data/test/eyetests/tests/gruff_bar_2.rb +19 -0
  67. data/test/eyetests/tests/gruff_line_1.rb +13 -0
  68. data/test/eyetests/tests/gruff_line_2.rb +20 -0
  69. data/test/eyetests/tests/gruff_net_1.rb +16 -0
  70. data/test/eyetests/tests/gruff_net_2.rb +16 -0
  71. data/test/eyetests/tests/gruff_pie_1.rb +21 -0
  72. data/test/eyetests/tests/gruff_pie_2.rb +22 -0
  73. data/test/eyetests/tests/gruff_scene_1.rb +14 -0
  74. data/test/eyetests/tests/gruff_scene_2.rb +14 -0
  75. data/test/eyetests/tests/gruff_sidebar.rb +32 -0
  76. data/test/eyetests/tests/gruff_sidestacked_bar_1.rb +26 -0
  77. data/test/eyetests/tests/gruff_sidestacked_bar_2.rb +26 -0
  78. data/test/eyetests/tests/gruff_spider_1.rb +22 -0
  79. data/test/eyetests/tests/gruff_spider_2.rb +15 -0
  80. data/test/eyetests/tests/gruff_stacked_bar_1.rb +23 -0
  81. data/test/eyetests/tests/gruff_stacked_bar_2.rb +26 -0
  82. data/test/eyetests/tests/hatch_fill.rb +9 -0
  83. data/test/eyetests/tests/image_list_flatten_images.rb +15 -0
  84. data/test/eyetests/tests/new_image.rb +24 -0
  85. data/test/eyetests/tests/path_a_command_01.rb +16 -0
  86. data/test/eyetests/tests/path_a_command_02.rb +19 -0
  87. data/test/eyetests/tests/path_c_command_01.rb +16 -0
  88. data/test/eyetests/tests/path_c_command_02.rb +16 -0
  89. data/test/eyetests/tests/path_complex_01.rb +16 -0
  90. data/test/eyetests/tests/path_espiral_01.rb +28 -0
  91. data/test/eyetests/tests/path_h_command_01.rb +16 -0
  92. data/test/eyetests/tests/path_h_command_02.rb +16 -0
  93. data/test/eyetests/tests/path_l_command_01.rb +16 -0
  94. data/test/eyetests/tests/path_l_command_02.rb +16 -0
  95. data/test/eyetests/tests/path_m_command_01.rb +16 -0
  96. data/test/eyetests/tests/path_m_command_02.rb +16 -0
  97. data/test/eyetests/tests/path_m_command_03.rb +16 -0
  98. data/test/eyetests/tests/path_q_command_01.rb +16 -0
  99. data/test/eyetests/tests/path_q_command_02.rb +16 -0
  100. data/test/eyetests/tests/path_q_command_03.rb +25 -0
  101. data/test/eyetests/tests/path_s_command_01.rb +16 -0
  102. data/test/eyetests/tests/path_s_command_02.rb +16 -0
  103. data/test/eyetests/tests/path_star_01.rb +16 -0
  104. data/test/eyetests/tests/path_t_command_01.rb +16 -0
  105. data/test/eyetests/tests/path_t_command_02.rb +16 -0
  106. data/test/eyetests/tests/path_v_command_01.rb +16 -0
  107. data/test/eyetests/tests/path_v_command_02.rb +16 -0
  108. data/test/eyetests/tests/store_pixel_smiley.rb +123 -0
  109. data/test/eyetests/tests/texture_fill.rb +11 -0
  110. data/test/gruff_tests/test/gruff_test_case.rb +120 -0
  111. data/test/gruff_tests/test/monkey_gruff.rb +7 -0
  112. data/test/gruff_tests/test/test_accumulator_bar.rb +50 -0
  113. data/test/gruff_tests/test/test_area.rb +134 -0
  114. data/test/gruff_tests/test/test_bar.rb +283 -0
  115. data/test/gruff_tests/test/test_base.rb +8 -0
  116. data/test/gruff_tests/test/test_bullet.rb +26 -0
  117. data/test/gruff_tests/test/test_legend.rb +71 -0
  118. data/test/gruff_tests/test/test_line.rb +493 -0
  119. data/test/gruff_tests/test/test_mini_bar.rb +32 -0
  120. data/test/gruff_tests/test/test_mini_pie.rb +20 -0
  121. data/test/gruff_tests/test/test_mini_side_bar.rb +37 -0
  122. data/test/gruff_tests/test/test_net.rb +230 -0
  123. data/test/gruff_tests/test/test_photo.rb +41 -0
  124. data/test/gruff_tests/test/test_pie.rb +154 -0
  125. data/test/gruff_tests/test/test_scene.rb +100 -0
  126. data/test/gruff_tests/test/test_side_bar.rb +12 -0
  127. data/test/gruff_tests/test/test_sidestacked_bar.rb +89 -0
  128. data/test/gruff_tests/test/test_spider.rb +216 -0
  129. data/test/gruff_tests/test/test_stacked_bar.rb +52 -0
  130. data/test/images/clown.jpg +0 -0
  131. data/test/images/texture.jpg +0 -0
  132. data/test/implemented_methods.rb +18 -0
  133. data/test/spec/draw_spec.rb +24 -0
  134. data/test/spec/image_constants.rb +76 -0
  135. data/test/spec/image_spec.rb +23 -0
  136. data/test/spec/pixel_spec.rb +84 -0
  137. data/test/spec/stories/geometry_runner.rb +13 -0
  138. data/test/spec/stories/geometry_steps.rb +24 -0
  139. data/test/spec/stories/geometry_story.rb +116 -0
  140. data/test/spec/stories/image_filling_runner.rb +13 -0
  141. data/test/spec/stories/image_filling_steps.rb +64 -0
  142. data/test/spec/stories/image_filling_story.rb +41 -0
  143. metadata +215 -0
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__),'..','lib','magick4j')
2
+ require File.join(File.dirname(__FILE__),'..','lib','rmagick4j','constants')
3
+ require File.join(File.dirname(__FILE__),'..','lib','rmagick4j','image')
4
+ require File.join(File.dirname(__FILE__),'spec','image_constants.rb')
5
+
6
+ include Magick
7
+
8
+ @image = Image.read(File.join(File.dirname(__FILE__),'clown.jpg'))
9
+
10
+ puts 'Image class'
11
+
12
+ num_implemented_methods = 0
13
+
14
+ IMAGE_METHODS.each do |method|
15
+ num_implemented_methods += 1 if @image.respond_to? method.to_sym
16
+ end
17
+
18
+ puts "Implemented #{num_implemented_methods}/#{IMAGE_METHODS_SIZE} (#{100.0*num_implemented_methods.to_f/IMAGE_METHODS_SIZE.to_f}%)."
@@ -0,0 +1,24 @@
1
+ require File.join(File.dirname(__FILE__),'..','..','lib','RMagick')
2
+
3
+ include Magick
4
+
5
+ describe Draw do
6
+
7
+ it "should save the state when calling push and recover it after pop" do
8
+ a = Draw.new
9
+ a.line(5, 5, 10, 10)
10
+ b = a.clone
11
+ b.push
12
+ b.stroke('blue')
13
+ a.inspect.should != b.inspect
14
+ b.pop
15
+ a.inspect.should == b.inspect
16
+ end
17
+
18
+ it "should add one line per primitive" do
19
+ a = Draw.new
20
+ a.path 'M150,150
21
+ l50,50'
22
+ a.inspect.split('\n').size.should == 1
23
+ end
24
+ end
@@ -0,0 +1,76 @@
1
+ IMAGE_METHODS = ["<", "<=", "<=>", "==", "===", "=~", ">", ">=", "[]", "[]=",
2
+ "__display__", "__id__", "__send__", "_dump", "adaptive_blur",
3
+ "adaptive_blur_channel", "adaptive_resize", "adaptive_sharpen",
4
+ "adaptive_sharpen_channel", "adaptive_threshold", "add_noise",
5
+ "add_noise_channel", "add_profile", "affine_transform", "annotate",
6
+ "auto_orient", "auto_orient!", "background_color", "background_color=",
7
+ "base_columns", "base_filename", "base_rows", "between?", "bias",
8
+ "bias=", "bilevel_channel", "black_point_compensation",
9
+ "black_point_compensation=", "black_threshold", "blend", "blur",
10
+ "blur=", "blur_channel", "blur_image", "border", "border!",
11
+ "border_color", "border_color=", "bounding_box", "change_geometry",
12
+ "change_geometry!", "changed?", "channel", "channel_compare",
13
+ "channel_depth", "channel_extrema", "channel_mean", "channel_threshold",
14
+ "charcoal", "chop", "chromaticity", "chromaticity=", "class",
15
+ "class_type", "class_type=", "clone", "color_fill_to_border",
16
+ "color_flood_fill", "color_floodfill", "color_histogram",
17
+ "color_point", "color_profile", "color_profile=", "color_reset!",
18
+ "colorize", "colormap", "colors", "colorspace", "colorspace=",
19
+ "columns", "compare_channel", "compose", "compose=", "composite",
20
+ "composite!", "composite_affine", "composite_channel",
21
+ "composite_channel!", "compress_colormap!", "compression", "compression=",
22
+ "contrast", "contrast_stretch_channel", "convolve", "convolve_channel",
23
+ "copy", "crop", "crop!", "crop_resized", "crop_resized!", "cur_image",
24
+ "cycle_colormap", "delay", "delay=", "delete_profile", "density",
25
+ "density=", "depth", "despeckle", "difference", "directory", "dispatch",
26
+ "displace", "display", "dispose", "dispose=", "dissolve",
27
+ "distortion_channel", "dup", "each_iptc_dataset", "each_profile", "edge",
28
+ "emboss", "endian", "endian=", "enhance", "eql?", "equal?", "equalize",
29
+ "erase!", "export_pixels", "export_pixels_to_str", "extend",
30
+ "extract_info", "extract_info=", "filename", "filesize", "filter",
31
+ "filter=", "find_similar_region", "flip", "flip!", "flop", "flop!",
32
+ "format", "format=", "frame", "freeze", "frozen?", "fuzz", "fuzz=", "gamma",
33
+ "gamma=", "gamma_channel", "gamma_correct", "gaussian_blur",
34
+ "gaussian_blur_channel", "gem", "geometry", "geometry=",
35
+ "get_exif_by_entry", "get_exif_by_number", "get_iptc_dataset", "get_pixels",
36
+ "gray?", "grayscale_pseudo_class", "grey?", "hash", "id", "image_type",
37
+ "image_type=", "implode", "import_pixels", "inspect", "instance_eval",
38
+ "instance_of?", "instance_variable_defined?", "instance_variable_get",
39
+ "instance_variable_set", "instance_variables", "interlace", "interlace=",
40
+ "iptc_profile", "iptc_profile=", "is_a?", "iterations", "iterations=",
41
+ "kind_of?", "level", "level2", "level_channel", "linear_stretch",
42
+ "magnify", "magnify!", "map", "mask", "mask=", "matte", "matte=",
43
+ "matte_color", "matte_color=", "matte_fill_to_border", "matte_flood_fill",
44
+ "matte_floodfill", "matte_point", "matte_replace", "matte_reset!",
45
+ "mean_error_per_pixel", "median_filter", "method", "methods", "mime_type",
46
+ "minify", "minify!", "modulate", "monitor=", "monochrome?", "montage",
47
+ "montage=", "motion_blur", "negate", "negate_channel", "nil?", "normalize",
48
+ "normalize_channel", "normalized_maximum_error", "normalized_mean_error",
49
+ "number_colors", "object_id", "offset", "offset=", "oil_paint", "opacity=",
50
+ "opaque", "opaque?", "ordered_dither", "orientation", "orientation=",
51
+ "page", "page=", "palette?", "pixel_color", "pixel_interpolation_method",
52
+ "pixel_interpolation_method=", "polaroid", "posterize", "preview",
53
+ "private_methods", "profile!", "properties", "protected_methods",
54
+ "public_methods", "quality", "quantize", "quantum_depth",
55
+ "quantum_operator", "radial_blur", "radial_blur_channel",
56
+ "raise", "random_channel_threshold", "random_threshold_channel",
57
+ "recolor", "reduce_noise", "rendering_intent", "rendering_intent=",
58
+ "require", "resample", "resize", "resize!", "resize_to_fit",
59
+ "resize_to_fit!", "respond_to?", "roll", "rotate", "rotate!", "rows",
60
+ "sample", "sample!", "scale", "scale!", "scene", "segment", "send",
61
+ "sepiatone", "set_channel_depth", "shade", "shadow", "sharpen",
62
+ "sharpen_channel", "shave", "shave!", "shear", "sigmoidal_contrast_channel",
63
+ "signature", "singleton_methods", "sketch", "solarize", "splice", "spread",
64
+ "start_loop", "start_loop=", "statistics", "stegano", "stereo",
65
+ "store_pixels", "strip!", "swirl", "taint", "tainted?",
66
+ "texture_fill_to_border", "texture_flood_fill", "texture_floodfill",
67
+ "threshold", "thumbnail", "thumbnail!", "ticks_per_second",
68
+ "ticks_per_second=", "tile_info", "tile_info=", "tint", "to_a", "to_blob",
69
+ "to_color", "to_s", "total_colors", "transparent", "transparent_color",
70
+ "transparent_color=", "transpose", "transpose!", "transverse",
71
+ "transverse!", "trim", "trim!", "type", "unique_colors", "units", "units=",
72
+ "unsharp_mask", "unsharp_mask_channel", "untaint", "view", "vignette",
73
+ "virtual_pixel_method", "virtual_pixel_method=", "watermark", "wave",
74
+ "wet_floor", "white_threshold", "write", "x_resolution", "x_resolution=",
75
+ "y_resolution", "y_resolution="]
76
+ IMAGE_METHODS_SIZE = IMAGE_METHODS.size
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__),'..','..','lib','RMagick')
2
+ require File.join(File.dirname(__FILE__),"image_constants.rb")
3
+
4
+ include Magick
5
+
6
+ describe Image do
7
+
8
+ before(:each) do
9
+ @image = Image.read(File.join(File.dirname(__FILE__),'..','images','clown.jpg'))
10
+ end
11
+
12
+ it "should have the same methods as the standard RMagick" do
13
+ IMAGE_METHODS.each do |method|
14
+ # It fails, use test/implemented_methods instead (at least, until
15
+ # we got some more methods implemented, no just 13%
16
+ # @image.should respond_to? method.to_sym
17
+ end
18
+ end
19
+
20
+ it "should return a one-item array after reading an image" do
21
+ @image.should have(1).images
22
+ end
23
+ end
@@ -0,0 +1,84 @@
1
+ require File.join(File.dirname(__FILE__),'..','..','lib','RMagick')
2
+
3
+ include Magick
4
+
5
+ class IntConverter
6
+ def to_int
7
+ 1
8
+ end
9
+ end
10
+
11
+ describe Pixel do
12
+ Red = 233
13
+ Green = 234
14
+ Blue = 235
15
+ Opacity = 151
16
+ Color = ['AliceBlue', Pixel.new(240, 248, 255, 0)]
17
+
18
+ it "should allow limited or no parameters without error" do
19
+ Pixel.new
20
+ Pixel.new(1)
21
+ Pixel.new(1, 1)
22
+ Pixel.new(1, 1, 1)
23
+ Pixel.new(1, 1, 1, 1)
24
+ end
25
+
26
+ it "should accept float values and round down" do
27
+ Pixel.new(1.1).red.should == 1
28
+ Pixel.new(1.9).red.should == 1
29
+ end
30
+
31
+ it "should accept values greater than 256 using the modulo operator on them" do
32
+ Pixel.new(256).red.should == 256%256
33
+ Pixel.new(233, 266).green.should == 266%256
34
+ Pixel.new(233, 233, 276).blue.should == 276%256
35
+ Pixel.new(233, 233, 233, -56).opacity.should == (-56)%256
36
+ [-290, -256, -100, 0, 23, 256, 380].each do |x|
37
+ Pixel.new(x).red.should == x%256
38
+ end
39
+ end
40
+
41
+ it "should call to_int on pixel values" do
42
+ Pixel.new(IntConverter.new).red.should == 1
43
+ end
44
+
45
+ before(:each) do
46
+ @pixel = Pixel.new(Red, Green, Blue, Opacity)
47
+ end
48
+
49
+ it "should return the red value" do
50
+ @pixel.red.should eql(Red)
51
+ end
52
+
53
+ it "should return the green value" do
54
+ @pixel.green.should eql(Green)
55
+ end
56
+
57
+ it "should return the blue value" do
58
+ @pixel.blue.should eql(Blue)
59
+ end
60
+
61
+ it "should return the opacity value" do
62
+ @pixel.opacity.should eql(Opacity)
63
+ end
64
+
65
+ it "should not find the value and raise and exception" do
66
+ lambda {Pixel.from_color('mathematica')}.should raise_error(ArgumentError)
67
+ end
68
+
69
+ it "should find the right value for #{Color[0]}" do
70
+ lambda {
71
+ Pixel.from_color(Color[0]).should eql(Color[1])
72
+ }.should_not raise_error(ArgumentError)
73
+ end
74
+
75
+ it "should type error on invalud types to fcmp" do
76
+ lambda { @pixel.fcmp('a') }.should raise_error(TypeError)
77
+ end
78
+
79
+ it "should return the color name (#{Color[0]})" do
80
+ Color[1].to_color.should eql(Color[0])
81
+ end
82
+
83
+ end
84
+
@@ -0,0 +1,13 @@
1
+ require "rubygems"
2
+ require 'spec/story'
3
+
4
+ require File.join(File.dirname(__FILE__), '..', '..', '..','lib','RMagick')
5
+
6
+ include Magick
7
+
8
+ require File.join(File.dirname(__FILE__), 'geometry_steps.rb')
9
+
10
+
11
+ with_steps_for(:geometry) do
12
+ run File.join(File.dirname(__FILE__), 'geometry_story.rb')
13
+ end
@@ -0,0 +1,24 @@
1
+ steps_for(:geometry) do
2
+ Given("a new Image sized $width x $height") do |width, height|
3
+ @image = Image.new(width.to_i, height.to_i)
4
+ end
5
+
6
+ Given("a new Geometry from string $geometry") do |geometry|
7
+ @geometry = Geometry.from_s(geometry)
8
+ end
9
+
10
+ When("changing geometry") do
11
+ @image.change_geometry(@geometry) do |cols, rows, image|
12
+ @new_width = cols
13
+ @new_height = rows
14
+ end
15
+ end
16
+
17
+ Then("the new width should be $value") do |value|
18
+ @new_width.should eql(value.to_f)
19
+ end
20
+
21
+ Then("the new height should be $value") do |value|
22
+ @new_height.should eql(value.to_f)
23
+ end
24
+ end
@@ -0,0 +1,116 @@
1
+ Story: changing geometry
2
+ As a developer
3
+ I want to resize an image using a geometry
4
+ So that I can do some cool stuff.
5
+
6
+ Scenario: the geometry is a simple one, and the ratios are both >1
7
+ Given a new Image sized 600 x 300
8
+ And a new Geometry from string 300x200
9
+ When changing geometry
10
+ Then the new width should be 300
11
+ And the new height should be 150
12
+
13
+ Scenario: the geometry is a PercentGeometry, and the ratios are both >1
14
+ Given a new Image sized 600 x 300
15
+ And a new Geometry from string 100x70%
16
+ When changing geometry
17
+ Then the new width should be 600
18
+ And the new height should be 210
19
+
20
+ Scenario: the geometry is a AspectGeometry, and the ratios are both >1
21
+ Given a new Image sized 600 x 300
22
+ And a new Geometry from string 100x70!
23
+ When changing geometry
24
+ Then the new width should be 100
25
+ And the new height should be 70
26
+
27
+ Scenario: the geometry is a LessGeometry, and the ratios are both >1, (smaller)
28
+ Given a new Image sized 150 x 125
29
+ And a new Geometry from string 300x200<
30
+ When changing geometry
31
+ Then the new width should be 240
32
+ And the new height should be 200
33
+
34
+ Scenario: the geometry is a LessGeometry, and the ratios are both >1, (bigger)
35
+ Given a new Image sized 600 x 300
36
+ And a new Geometry from string 300x200<
37
+ When changing geometry
38
+ Then the new width should be 600
39
+ And the new height should be 300
40
+
41
+ Scenario: the geometry is a GreaterGeometry, and the ratios are both >1, (smaller)
42
+ Given a new Image sized 150 x 125
43
+ And a new Geometry from string 300x200>
44
+ When changing geometry
45
+ Then the new width should be 150
46
+ And the new height should be 125
47
+
48
+ Scenario: the geometry is a GreaterGeometry, and the ratios are both >1, (bigger)
49
+ Given a new Image sized 600 x 300
50
+ And a new Geometry from string 300x200>
51
+ When changing geometry
52
+ Then the new width should be 300
53
+ And the new height should be 150
54
+
55
+ Scenario: the geometry is a AreaGeometry, and the ratio is >1
56
+ Given a new Image sized 600 x 300
57
+ And a new Geometry from string 300@
58
+ When changing geometry
59
+ Then the new width should be 24
60
+ And the new height should be 12
61
+
62
+ Scenario: the geometry is a simple one, and the ratios are mixed
63
+ Given a new Image sized 300 x 600
64
+ And a new Geometry from string 300x200
65
+ When changing geometry
66
+ Then the new width should be 100
67
+ And the new height should be 200
68
+
69
+ Scenario: the geometry is a PercentGeometry, and the ratios are mixed
70
+ Given a new Image sized 300 x 600
71
+ And a new Geometry from string 100x70%
72
+ When changing geometry
73
+ Then the new width should be 300
74
+ And the new height should be 420
75
+
76
+ Scenario: the geometry is a AspectGeometry, and the ratios are mixed
77
+ Given a new Image sized 300 x 600
78
+ And a new Geometry from string 100x70!
79
+ When changing geometry
80
+ Then the new width should be 100
81
+ And the new height should be 70
82
+
83
+ Scenario: the geometry is a LessGeometry, and the ratios are mixed, (smaller)
84
+ Given a new Image sized 125 x 150
85
+ And a new Geometry from string 300x200<
86
+ When changing geometry
87
+ Then the new width should be 167
88
+ And the new height should be 200
89
+
90
+ Scenario: the geometry is a LessGeometry, and the ratios are mixed, (bigger)
91
+ Given a new Image sized 400 x 600
92
+ And a new Geometry from string 300x200<
93
+ When changing geometry
94
+ Then the new width should be 400
95
+ And the new height should be 600
96
+
97
+ Scenario: the geometry is a GreaterGeometry, and the ratios are mixed, (smaller)
98
+ Given a new Image sized 125 x 150
99
+ And a new Geometry from string 300x200>
100
+ When changing geometry
101
+ Then the new width should be 125
102
+ And the new height should be 150
103
+
104
+ Scenario: the geometry is a GreaterGeometry, and the ratios are mixed, (bigger)
105
+ Given a new Image sized 400 x 600
106
+ And a new Geometry from string 300x200>
107
+ When changing geometry
108
+ Then the new width should be 133
109
+ And the new height should be 200
110
+
111
+ Scenario: the geometry is a AreaGeometry, and the ratio is <1
112
+ Given a new Image sized 300 x 600
113
+ And a new Geometry from string 300@
114
+ When changing geometry
115
+ Then the new width should be 12
116
+ And the new height should be 24
@@ -0,0 +1,13 @@
1
+ require "rubygems"
2
+ require 'spec/story'
3
+
4
+ require File.join(File.dirname(__FILE__), '..', '..', '..','lib','RMagick')
5
+
6
+ include Magick
7
+
8
+ require File.join(File.dirname(__FILE__), 'image_filling_steps.rb')
9
+
10
+
11
+ with_steps_for(:image) do
12
+ run File.join(File.dirname(__FILE__), 'image_filling_story.rb')
13
+ end
@@ -0,0 +1,64 @@
1
+ steps_for(:image) do
2
+ Given("a new GradientFill with starting line $x1 $y1 $x2 $y2 with start color: $start_color and end color: $end_color") do |x1, y1, x2, y2, start_color, end_color|
3
+ @fill = GradientFill.new(x1.to_i, y1.to_i, x2.to_i, y2.to_i, '#'+start_color, '#'+end_color)
4
+ end
5
+
6
+ Given("a new GradientFill with starting point $x $y with start color: $start_color and end color: $end_color") do |x, y, start_color, end_color|
7
+ @fill = GradientFill.new(x.to_i, y.to_i, x.to_i, y.to_i, '#'+start_color, '#'+end_color)
8
+ end
9
+
10
+ Given("a new Image $image_name with extension $extension") do |image_name, extension|
11
+ @image = Image.read(File.join(File.dirname(__FILE__), '..', '..', 'images', image_name+'.'+extension))
12
+ end
13
+
14
+ Given("a new TextureFill from image") do
15
+ @fill = TextureFill.new(@image.first)
16
+ end
17
+
18
+ When("filling a new image sized $columns $rows with the Fill object") do |columns, rows|
19
+ begin
20
+ @image = Image.new(columns.to_i, rows.to_i, @fill)
21
+ rescue
22
+ @image = nil
23
+ end
24
+ end
25
+
26
+ Then("the new image should not be $value") do |value|
27
+ expected_value = case value
28
+ when 'nil': nil
29
+ when 'false': false
30
+ when 'true': true
31
+ when value.to_i.to_s: value.to_i
32
+ when value.to_f.to_s: value.to_f
33
+ else
34
+ value
35
+ end
36
+ @image.should_not be expected_value
37
+ end
38
+
39
+ Then("the new image should be $value") do |value|
40
+ expected_value = case value
41
+ when 'nil': nil
42
+ when 'false': false
43
+ when 'true': true
44
+ when value.to_i.to_s: value.to_i
45
+ when value.to_f.to_s: value.to_f
46
+ else
47
+ value
48
+ end
49
+ @image.should be expected_value
50
+ end
51
+
52
+ # TODO: Refactor... but how?
53
+ def parse_value(value)
54
+ case value
55
+ when 'nil': nil
56
+ when 'false': false
57
+ when 'true': true
58
+ when value.to_i.to_s: value.to_i
59
+ when value.to_f.to_s: value.to_f
60
+ else
61
+ value
62
+ end
63
+ end
64
+ end