Browse Source

Finish regression testing of star

dev
Andy Meneely 11 years ago
parent
commit
0853b6a708
  1. 1
      lib/squib/graphics/shapes.rb
  2. 22
      spec/data/samples/draw_shapes.rb.txt
  3. 2
      spec/samples/samples_regression_spec.rb
  4. 3
      spec/spec_helper.rb

1
lib/squib/graphics/shapes.rb

@ -106,7 +106,6 @@ module Squib
# @api private # @api private
def star(x, y, n, angle, inner_radius, outer_radius, fill_color, stroke_color, stroke_width) def star(x, y, n, angle, inner_radius, outer_radius, fill_color, stroke_color, stroke_width)
use_cairo do |cc| use_cairo do |cc|
cc.new_path
cc.translate(x, y) cc.translate(x, y)
cc.rotate(angle) cc.rotate(angle)
cc.translate(-x, -y) cc.translate(-x, -y)

22
spec/data/samples/draw_shapes.rb.txt

@ -61,4 +61,26 @@ cairo: stroke_preserve([])
cairo: set_source_color([:burgundy]) cairo: set_source_color([:burgundy])
cairo: fill([]) cairo: fill([])
cairo: restore([]) cairo: restore([])
cairo: save([])
cairo: translate([300, 1000])
cairo: rotate([0])
cairo: translate([-300, -1000])
cairo: move_to([325, 1000])
cairo: line_to([325.0, 1000.0])
cairo: line_to([308.09016994374946, 1005.8778525229247])
cairo: line_to([307.7254248593737, 1023.7764129073788])
cairo: line_to([296.90983005625054, 1009.5105651629515])
cairo: line_to([279.7745751406263, 1014.6946313073119])
cairo: line_to([290.0, 1000.0])
cairo: line_to([279.7745751406263, 985.3053686926881])
cairo: line_to([296.90983005625054, 990.4894348370485])
cairo: line_to([307.7254248593737, 976.2235870926212])
cairo: line_to([308.09016994374946, 994.1221474770753])
cairo: line_to([325.0, 1000.0])
cairo: set_source_color([:cyan])
cairo: set_line_width([1])
cairo: fill_preserve([])
cairo: set_source_color([:burgundy])
cairo: stroke([])
cairo: restore([])
surface: write_to_png(["_output/shape_00.png"]) surface: write_to_png(["_output/shape_00.png"])

2
spec/samples/samples_regression_spec.rb

@ -73,7 +73,7 @@ describe "Squib samples" do
log = StringIO.new log = StringIO.new
mock_cairo(log) mock_cairo(log)
load sample load sample
overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log # overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log
test_file_str = File.open(sample_regression_file(sample), 'r:UTF-8').read test_file_str = File.open(sample_regression_file(sample), 'r:UTF-8').read
expect(log.string).to eq(test_file_str) expect(log.string).to eq(test_file_str)
end end

3
spec/spec_helper.rb

@ -103,7 +103,8 @@ def mock_cairo(strio)
update_pango_layout width height show_pango_layout rounded_rectangle update_pango_layout width height show_pango_layout rounded_rectangle
set_line_width stroke fill set_source scale render_rsvg_handle circle set_line_width stroke fill set_source scale render_rsvg_handle circle
triangle line_to operator= show_page clip transform mask rectangle triangle line_to operator= show_page clip transform mask rectangle
reset_clip antialias= curve_to matrix= pango_layout_path stroke_preserve).each do |m| reset_clip antialias= curve_to matrix= pango_layout_path stroke_preserve
fill_preserve).each do |m|
allow(cxt).to receive(m) { |*args| strio << scrub_hex("cairo: #{m}(#{args})\n") } allow(cxt).to receive(m) { |*args| strio << scrub_hex("cairo: #{m}(#{args})\n") }
end end

Loading…
Cancel
Save