diff --git a/lib/squib/graphics/shapes.rb b/lib/squib/graphics/shapes.rb index 35b320b..d95f167 100644 --- a/lib/squib/graphics/shapes.rb +++ b/lib/squib/graphics/shapes.rb @@ -106,7 +106,6 @@ module Squib # @api private def star(x, y, n, angle, inner_radius, outer_radius, fill_color, stroke_color, stroke_width) use_cairo do |cc| - cc.new_path cc.translate(x, y) cc.rotate(angle) cc.translate(-x, -y) diff --git a/spec/data/samples/draw_shapes.rb.txt b/spec/data/samples/draw_shapes.rb.txt index aed053b..99b3027 100644 --- a/spec/data/samples/draw_shapes.rb.txt +++ b/spec/data/samples/draw_shapes.rb.txt @@ -61,4 +61,26 @@ cairo: stroke_preserve([]) cairo: set_source_color([:burgundy]) cairo: fill([]) 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"]) diff --git a/spec/samples/samples_regression_spec.rb b/spec/samples/samples_regression_spec.rb index 85d59ff..f8c9e14 100644 --- a/spec/samples/samples_regression_spec.rb +++ b/spec/samples/samples_regression_spec.rb @@ -73,7 +73,7 @@ describe "Squib samples" do log = StringIO.new mock_cairo(log) 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 expect(log.string).to eq(test_file_str) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 04d1302..1c143f2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -103,7 +103,8 @@ def mock_cairo(strio) update_pango_layout width height show_pango_layout rounded_rectangle set_line_width stroke fill set_source scale render_rsvg_handle circle 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") } end