Merging in svg back end work. All but save_doc is done.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# 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_
|
||||
@@ -0,0 +1,32 @@
|
||||
require 'squib'
|
||||
|
||||
# Our SVGs are auto-saved after each step using the configuration parameters
|
||||
Squib::Deck.new(config: 'backend-config.yml') do
|
||||
|
||||
# These are all supported by the SVG backend
|
||||
background color: :white
|
||||
text str: "Hello, world!", y: 500, width: 825, font: 'Sans bold 72', align: :center
|
||||
rect x: 10, y: 10, width: 20, height: 20
|
||||
circle x: 40, y: 40, radius: 25
|
||||
triangle x1: 50, y1: 15, x2: 60, y2: 25, x3: 75, y3: 25
|
||||
line x1: 100, y1: 620, x2: 720, y2: 620, stroke_width: 15.0
|
||||
svg file: 'spanner.svg', x: 100, y: 20
|
||||
svg file: 'glass-heart.svg', x: 100, y: 200, width: 100, height: 100, mask: :sangria
|
||||
png file: 'shiny-purse.png', x: 250, y: 20
|
||||
png file: 'shiny-purse.png', x: 250, y: 200, mask: :red
|
||||
|
||||
# We can still rasterize whenever we want
|
||||
save_png prefix: 'backend_'
|
||||
|
||||
# And our PDFs will be vectorized.
|
||||
save_pdf file: 'backend_vectorized.pdf'
|
||||
|
||||
# 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
|
||||
@@ -0,0 +1,11 @@
|
||||
require 'cairo'
|
||||
require 'pango'
|
||||
require 'rsvg2'
|
||||
|
||||
svg = RSVG::Handle.new_from_file('spanner.svg')
|
||||
pdf = Cairo::PDFSurface.new("_output/blahblah2.pdf",8.5*300, 11*300)
|
||||
cxt = Cairo::Context.new(pdf)
|
||||
cxt.translate(1900,500)
|
||||
cxt.render_rsvg_handle(svg, nil)
|
||||
cxt.translate(-500,0)
|
||||
cxt.render_rsvg_handle(svg, nil)
|
||||
Reference in New Issue
Block a user