Skip to content

Instantly share code, notes, and snippets.

@andymeneely
Last active April 12, 2016 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andymeneely/7b4a3acd0e758aedf87ba549e2025a11 to your computer and use it in GitHub Desktop.
Save andymeneely/7b4a3acd0e758aedf87ba549e2025a11 to your computer and use it in GitHub Desktop.
Squib samples
# To configure for using SVG as our backend, we need to set this option
# This will create a series of SVG files that get updated with Squib command
backend: svg
# They are auto-saved with this background
prefix: backend_vectors_
require 'squib'
# Our SVGs are auto-saved after each step using the configuration parameters
Squib::Deck.new(cards: 2, config: '_backend-config.yml') do
# These are all supported by the SVG backend
background color: :gray
text str: 'Hello, world!', y: 500, width: 825, font: 'Sans bold 72', align: :center
rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
circle x: 100, y: 400, radius: 25
triangle x1: 100, y1: 425, x2: 125, y2: 475, x3: 75, y3: 475
line x1: 100, y1: 620, x2: 720, y2: 620, stroke_width: 15.0
svg file: 'spanner.svg', x: 100, y: 75
png file: 'shiny-purse.png', x: 250, y: 75 # raster can still be used too
png file: 'shiny-purse.png', x: 250, y: 250, mask: :red # still renders as raster
# We can still rasterize whenever we want
save_png prefix: 'backend_'
# 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
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment