def _render_marker(self, a, b, marker, reverse=False): if marker.orient == 'auto': angle = (a - b).angle() else: angle = marker.orient if reverse: angle += math.pi sx = (marker.marker_width / marker.vb_w) * self.style.stroke_width sy = (marker.marker_height / marker.vb_h) * self.style.stroke_width rx = marker.ref_x ry = marker.ref_y with Matrix.transform(a.x, a.y, theta=angle): with Matrix.scale(sx, sy): with Matrix.translation(-rx, -ry): marker.render()
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:]
def __init__(self, svg, element, parent): #: The id of the element self.id = element.get('id', '') SVGContainer.__init__(self, parent) self.svg = svg #: Is this element a pattern? self.is_pattern = element.tag.endswith('pattern') #: Is this element a definition? self.is_def = False if parent: self.is_def = parent.is_def #: The element style (possibly with inherited traits from parent style) self.style = svg_style.SVGStyle( parent.style if isinstance(parent, SVGRenderableElement) else None) self.style.from_element(element) #: Optional element title self.title = element.findtext('{%s}title' % (XMLNS,)) #: Optional element description. Useful for embedding metadata. self.description = element.findtext('{%s}desc' % (XMLNS,)) #construct a matrix for each transform t_acc = Matrix.identity() transform_str = element.get('transform', None) if transform_str: transforms = get_fns(transform_str) for tstring in transforms: t_acc = t_acc * Matrix(tstring) #: Element transforms self.transform = t_acc #: Children elements self.children = [] #: XML tag this was originally. self.tag_type = element.tag