def createPathNode( doc, pathObj, state ): pathNode = doc.createElement( "path" ) path_str = ifaint.to_svg_path( pathObj ) if len(path_str) == 0: # Fixme: Need a way to warn from save? print "Warning: Skipping empty path" return None pathNode.setAttributeNode( createAttr( doc, "d", ifaint.to_svg_path( pathObj ) ) ); style = SVGFillStyle( pathObj, state ) + SVGLineDashStyle( pathObj ) pathNode.setAttributeNode( createAttr( doc, "style", style ) ) return pathNode
def createSplineNode( doc, splineObj, state ): splineNode = doc.createElement( "path" ) splineNode.setAttributeNode( createAttr( doc, "d", ifaint.to_svg_path( splineObj ) ) ); splineNode.setAttributeNode( createAttr( doc, 'faint:type', 'spline') ) style = SVGLineStyle( splineObj, state ) + SVGLineDashStyle( splineObj ) + SVGNoFill(); splineNode.setAttributeNode( createAttr( doc, "style", style ) ); return splineNode
def createPathNode(doc, pathObj): pathNode = doc.createElement("path") pathNode.setAttributeNode(createAttr(doc, "d", ifaint.to_svg_path(pathObj))) style = SVGFillStyle(pathObj) + SVGLineDashStyle(pathObj) pathNode.setAttributeNode(createAttr(doc, "style", style)) return pathNode
def createEllipseNode( doc, ellipseObj, state ): ellipseNode = doc.createElement( "path" ) ellipseNode.setAttributeNode( createAttr( doc, "d", ifaint.to_svg_path( ellipseObj ) ) ) ellipseNode.setAttributeNode( createAttr( doc, "style", SVGFillStyle( ellipseObj, state ) + SVGLineDashStyle( ellipseObj ) ) ) ellipseNode.setAttributeNode( triAttr( doc, ellipseObj.tri() ) ) ellipseNode.setAttributeNode( createAttr( doc, "faint:type", "ellipse" ) ) return ellipseNode
def create_ellipse_path(obj, state): """Creates a path-element from a Faint ellipse. Marks it up as a Faint-ellipse to allow reloading.""" # Fixme: Save regular ellipses as ellipses element = ET.Element('path') element.set('d', ifaint.to_svg_path(obj)) style = svg_fill_style(obj, state) + svg_line_dash_style(obj) element.set('style', style) element.set(*tri_attr(obj.tri)) element.set('faint:type', 'ellipse') return element
def create_spline_path(obj, state): """Creates an SVG path element from a Faint Spline object. Marks it up as a faint:spline to allow reloading. """ element = ET.Element('path') element.set('d', ifaint.to_svg_path(obj)) element.set('faint:type', 'spline') style = (svg_line_style(obj, state) + svg_line_dash_style(obj) + svg_no_fill()) element.set('style', style) return element
def create_path(obj, state): """Creates an SVG <path> element from a Faint Path.""" path_str = ifaint.to_svg_path(obj) if len(path_str) == 0: # Fixme: Need a way to warn from save? print("Warning: Skipping empty path") return None element = ET.Element('path') element.set('d', path_str) style = (svg_fill_style(obj, state) + svg_line_dash_style(obj) + svg_line_join_style(obj)) element.set('style', style) return element