Exemple #1
0
    def parse_root(self, root):
        self._paths = []

        wm = root.get("width", '0')
        hm = root.get("height", '0')

        self.x = 0
        self.y = 0

        self.width = parse_float(wm)
        self.height = parse_float(hm)

        self.preserve_aspect_ratio = root.get('preserveAspectRatio', 'none')

        if self.root.get("viewBox"):
            x, y, w, h = (parse_float(x) for x in parse_list(root.get("viewBox")))
            self.x = x
            self.y = y
            self.height = h
            self.width = w

        self.opacity = 1.0
        for e in root.getchildren():
            try:
                self._parse_element(e)
            except Exception as ex:
                print 'Exception while parsing element', e
                raise
Exemple #2
0
    def __init__(self, svg, element, parent):
        SVGRenderableElement.__init__(self, svg, element, parent)
        self.svg = svg
        self.target = element.get(XLINK_NS + "href", None)
        self.x = parse_float(element.get('x', '0'))
        self.y = parse_float(element.get('y', '0'))

        self.transform = self.transform * Matrix.translation(self.x, self.y)

        #clip off "#"
        if self.target:
            self.target = self.target[1:]
Exemple #3
0
    def __init__(self, svg, element, parent):
        SVGRenderableElement.__init__(self, svg, element, parent)

        self.units = element.get('markerUnits', 'strokeWidth')
        self.marker_width = parse_float(element.get('markerWidth', '3'))
        self.marker_height = parse_float(element.get('markerHeight', '3'))
        self.orient = element.get('orient', 'auto')
        self.ref_x = parse_float(element.get('refX', '0'))
        self.ref_y = parse_float(element.get('refY', '0'))

        vb = element.get('viewBox', None)

        if vb:
            x, y, w, h = (parse_float(x) for x in parse_list(element.get("viewBox")))
            self.vb_x, self.vb_y, self.vb_w, self.vb_h = x, y, w, h
        else:
            self.vb_x = 0
            self.vb_y = 0
            self.vb_w = 1
            self.vb_h = 1