diff --git a/docs/dsl/showcase.rst b/docs/dsl/showcase.rst index f32ed44..bc585ae 100644 --- a/docs/dsl/showcase.rst +++ b/docs/dsl/showcase.rst @@ -63,3 +63,14 @@ file Examples -------- + +This sample `lives here `_. + +.. literalinclude:: ../../samples/saves/_showcase.rb + :language: ruby + :linenos: + +.. raw:: html + + + diff --git a/lib/squib/card.rb b/lib/squib/card.rb index 24836a2..5c671d8 100644 --- a/lib/squib/card.rb +++ b/lib/squib/card.rb @@ -52,7 +52,11 @@ module Squib end def finish! - @cairo_surface.finish + begin + @cairo_surface.finish + rescue Cairo::SurfaceFinishedError + # do nothin - if it's already finished that's fine + end end ######################## diff --git a/lib/squib/graphics/showcase.rb b/lib/squib/graphics/showcase.rb index 65c2e17..ead17fd 100644 --- a/lib/squib/graphics/showcase.rb +++ b/lib/squib/graphics/showcase.rb @@ -33,7 +33,7 @@ module Squib # :nodoc: # @api private def trim_rounded(src, trim, radius) - trim_cc = Cairo::Context.new(Cairo::ImageSurface.new(src.width - 2.0 * trim, src.height - 2.0 * trim)) + trim_cc = Cairo::Context.new(Cairo::ImageSurface.new(@width - 2.0 * trim, @height - 2.0 * trim)) trim_cc.rounded_rectangle(0, 0, trim_cc.target.width, trim_cc.target.height, radius, radius) trim_cc.set_source(src, -1 * trim, -1 * trim) trim_cc.clip diff --git a/lib/squib/version.rb b/lib/squib/version.rb index 08a133f..8793c63 100644 --- a/lib/squib/version.rb +++ b/lib/squib/version.rb @@ -6,5 +6,5 @@ module Squib # Most of the time this is in the alpha of the next release. # e.g. v0.0.5a is on its way to becoming v0.0.5 # - VERSION = '0.12.0a' + VERSION = '0.12.0b' end diff --git a/samples/backend/_backend.rb b/samples/backend/_backend.rb index b9ef210..b012592 100644 --- a/samples/backend/_backend.rb +++ b/samples/backend/_backend.rb @@ -16,18 +16,11 @@ Squib::Deck.new(cards: 2, config: '_backend-config.yml') do # We can still rasterize whenever we want save_png prefix: 'backend_' + showcase file: 'showcase.png', fill_color: 'white' + # And our PDFs will be vectorized . save_pdf file: 'backend_vectorized.pdf', gap: 5 # This one is a known issue. Masking an SVG onto an SVG backend is still buggy. # svg file: 'glass-heart.svg', x: 100, y: 200, width: 100, height: 100, mask: :sangria - - # This one is, unfortunately, not possible with svg back ends - # Cairo lacks a perspective transform (currently), so we have to - # use a striping method, which assumes raster. Fortunately, Cairo - # has perspective transforms on its roadmap, - # so perhaps this can be done someday with all vectors. - # - # showcase file: 'showcase.png', fill_color: 'white' - end diff --git a/samples/backend/showcase_expected.png b/samples/backend/showcase_expected.png new file mode 100644 index 0000000..127ce2f Binary files /dev/null and b/samples/backend/showcase_expected.png differ