SVG scaling is now supported!
This commit is contained in:
@@ -8,11 +8,14 @@ module Squib
|
||||
cc.paint(alpha)
|
||||
end
|
||||
|
||||
def svg(file, x, y)
|
||||
require 'rsvg2'
|
||||
def svg(file, x, y, width, height)
|
||||
svg = RSVG::Handle.new_from_file(file)
|
||||
tmp = Cairo::ImageSurface.new(svg.width, svg.height)
|
||||
width = svg.width if width == :native
|
||||
height = svg.height if height == :native
|
||||
puts "Width and height #{width} #{height}, svg was #{svg.width} #{svg.height}"
|
||||
tmp = Cairo::ImageSurface.new(width, height)
|
||||
tmp_cc = Cairo::Context.new(tmp)
|
||||
tmp_cc.scale(width.to_f / svg.width.to_f, height.to_f / svg.height.to_f)
|
||||
tmp_cc.render_rsvg_handle(svg)
|
||||
cairo_context.set_source(tmp, x, y)
|
||||
cairo_context.paint
|
||||
|
||||
Reference in New Issue
Block a user