Browse Source

showcase: use correct width&height vars

Fixes #179
dev
Andy Meneely 9 years ago
parent
commit
c9440ec57c
  1. 11
      docs/dsl/showcase.rst
  2. 6
      lib/squib/card.rb
  3. 2
      lib/squib/graphics/showcase.rb
  4. 2
      lib/squib/version.rb
  5. 11
      samples/backend/_backend.rb
  6. BIN
      samples/backend/showcase_expected.png

11
docs/dsl/showcase.rst

@ -63,3 +63,14 @@ file
Examples
--------
This sample `lives here <https://github.com/andymeneely/squib/tree/master/samples/saves>`_.
.. literalinclude:: ../../samples/saves/_showcase.rb
:language: ruby
:linenos:
.. raw:: html
<img src="../saves/showcase_expected.png" class="figure">
<img src="../saves/showcase2_expected.png" class="figure">

6
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
########################

2
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

2
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

11
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

BIN
samples/backend/showcase_expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Loading…
Cancel
Save