2
# -*- coding: utf-8 -*-
6
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
7
__licenses__ = ["LICENSE.LGPL"]
8
__description__ = "A CairoTexture from a SVG"
13
from cluttercairo import CairoTexture
18
class SVGImage(CairoTexture):
19
""" Creates a CairoTexture based on a given SVG """
21
def __init__(self, uri, width, height):
24
uri (str) -- source location (*.svg), standard uri format
25
width (int) -- width in pixels
26
height (int) -- height in pixels
29
CairoTexture.__init__(self, width, height)
35
if not os.path.exists(self.uri):
36
raise AttributeError, 'invalid source uri: %s' % self.uri
38
context = self.cairo_create()
39
svg = rsvg.Handle(self.uri)
40
matrix = cairo.Matrix((self.width * 1.0 / svg.props.width),0,0,(self.height * 1.0 / svg.props.height),0,0)
41
context.transform(matrix)
42
svg.render_cairo(context)