SVGBuilder
Module¶
build SVG files
-
class
knittingpattern.convert.SVGBuilder.
SVGBuilder
[source]¶ Bases:
object
This class builds an SVG to a file.
The class itself does not know what the objects look like. It offers a more convinient interface to build SVG files.
-
__weakref__
¶ list of weak references to the object (if defined)
-
bounding_box
¶ the bounding box of this SVG
(min_x, min_y, max_x, max_y)
.svg_builder10x10.bounding_box = (0, 0, 10, 10) assert svg_builder10x10.bounding_box == (0, 0, 10, 10)
viewBox
,width
andheight
are computed from this.If the bounding box was never set, the result is a tuple of four
None
.
-
insert_defs
(defs)[source]¶ Adds the defs to the SVG structure.
Parameters: defs¶ – a list of SVG dictionaries, which contain the defs, which should be added to the SVG structure.
-
place
(x, y, svg, layer_id)[source]¶ Place the
svg
content at(x, y)
position in the SVG, in a layer with the idlayer_id
.Parameters:
-
place_svg_dict
(x, y, svg_dict, layer_id, group=None)[source]¶ Same as
place()
but with a dictionary assvg_dict
.Parameters:
-
place_svg_use
(symbol_id, layer_id, group=None)[source]¶ Same as
place_svg_use_coords()
.With implicit x and y which are set to 0 in this method and then
place_svg_use_coords()
is called.
-
-
knittingpattern.convert.SVGBuilder.
SVG_FILE
= '\n<svg\n xmlns:ns="http://PURL.org/dc/elements/1.1/"\n xmlns:dc="http://purl.org/dc/elements/1.1/"\n xmlns:cc="http://creativecommons.org/ns#"\n xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n xmlns:svg="http://www.w3.org/2000/svg"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <title>knittingpattern</title>\n <defs></defs>\n</svg>\n'¶ an empty svg file as a basis