10.1.3.2.1. SvgFile¶
This modules implements the SVG file format.
Import Algorithm:
- text is informative, connect text to path
- short lines or polygon are sewing markers
- line with a small polygon at extremities is a grainline
- expect pieces are delimited by a path
- check for paths sharing vertexes and stroke style
-
class
Patro.FileFormat.Svg.SvgFile.
RenderState
(item=None)[source]¶ Bases:
object
-
STATES
= ['alignment_baseline', 'baseline_shift', 'clip', 'clip_path', 'clip_rule', 'color', 'color_interpolation', 'color_interpolation_filters', 'color_profile', 'color_rendering', 'cursor', 'direction', 'display', 'dominant_baseline', 'enable_background', 'fill', 'fill_opacity', 'fill_rule', 'flood_color', 'flood_opacity', 'font_family', 'font_size', 'font_size_adjust', 'font_stretch', 'font_style', 'font_variant', 'font_weight', 'glyph_orientation_horizontal', 'glyph_orientation_vertical', 'image_rendering', 'kerning', 'letter_spacing', 'lighting_color', 'marker_end', 'marker_mid', 'marker_start', 'mask', 'opacity', 'overflow', 'paint_order', 'pointer_events', 'shape_rendering', 'stop_color', 'stop_opacity', 'stroke', 'stroke_dasharray', 'stroke_dashoffset', 'stroke_linecap', 'stroke_linejoin', 'stroke_miterlimit', 'stroke_opacity', 'stroke_width', 'style', 'text_anchor', 'text_decoration', 'text_rendering', 'transform', 'unicode_bidi', 'vector_effect', 'visibility', 'word_spacing', 'writing_mode']¶
-
-
class
Patro.FileFormat.Svg.SvgFile.
SvgDispatcher
(reader)[source]¶ Bases:
object
Class to dispatch XML to Python class.
-
__TAGS_TO_READ__
= ['circle', 'ellipse', 'line', 'path', 'polyline', 'polygon', 'rect']¶
-
__TAGS__
= {'a': <class 'Patro.FileFormat.Svg.SvgFormat.Anchor'>, 'altGlyph': <class 'Patro.FileFormat.Svg.SvgFormat.AltGlyph'>, 'altGlyphDef': <class 'Patro.FileFormat.Svg.SvgFormat.AltGlyphDef'>, 'altGlyphItem': <class 'Patro.FileFormat.Svg.SvgFormat.AltGlyphItem'>, 'animate': <class 'Patro.FileFormat.Svg.SvgFormat.Animate'>, 'animateMotion': <class 'Patro.FileFormat.Svg.SvgFormat.AnimateMotion'>, 'animateTransform': <class 'Patro.FileFormat.Svg.SvgFormat.AnimateTransform'>, 'circle': <class 'Patro.FileFormat.Svg.SvgFormat.Circle'>, 'clipPath': <class 'Patro.FileFormat.Svg.SvgFormat.ClipPath'>, 'color-profile': <class 'Patro.FileFormat.Svg.SvgFormat.ColorProfile'>, 'cursor': <class 'Patro.FileFormat.Svg.SvgFormat.Cursor'>, 'defs': <class 'Patro.FileFormat.Svg.SvgFormat.Defs'>, 'desc': <class 'Patro.FileFormat.Svg.SvgFormat.Desc'>, 'ellipse': <class 'Patro.FileFormat.Svg.SvgFormat.Ellipse'>, 'feBlend': <class 'Patro.FileFormat.Svg.SvgFormat.FeBlend'>, 'g': <class 'Patro.FileFormat.Svg.SvgFormat.Group'>, 'image': <class 'Patro.FileFormat.Svg.SvgFormat.Image'>, 'line': <class 'Patro.FileFormat.Svg.SvgFormat.Line'>, 'linearGradient': <class 'Patro.FileFormat.Svg.SvgFormat.LinearGradient'>, 'marker': <class 'Patro.FileFormat.Svg.SvgFormat.Marker'>, 'mask': <class 'Patro.FileFormat.Svg.SvgFormat.Mask'>, 'path': <class 'Patro.FileFormat.Svg.SvgFormat.Path'>, 'pattern': <class 'Patro.FileFormat.Svg.SvgFormat.Pattern'>, 'polyline': <class 'Patro.FileFormat.Svg.SvgFormat.Polygon'>, 'radialGradient': <class 'Patro.FileFormat.Svg.SvgFormat.RadialGradient'>, 'rect': <class 'Patro.FileFormat.Svg.SvgFormat.Rect'>, 'stop': <class 'Patro.FileFormat.Svg.SvgFormat.Stop'>, 'svg': <class 'Patro.FileFormat.Svg.SvgFormat.Svg'>, 'text': <class 'Patro.FileFormat.Svg.SvgFormat.Text'>, 'textspan': <class 'Patro.FileFormat.Svg.SvgFormat.TextSpan'>, 'tref': <class 'Patro.FileFormat.Svg.SvgFormat.TextRef'>, 'use': <class 'Patro.FileFormat.Svg.SvgFormat.Use'>}¶
-
_logger
= <Logger Patro.FileFormat.Svg.SvgFile.SvgDispatcher (WARNING)>¶
-
cls
¶ alias of
Patro.FileFormat.Svg.SvgFormat.Use
-
cls_name
= 'Use'¶
-
state
¶
-
-
class
Patro.FileFormat.Svg.SvgFile.
SvgFileInternal
(path, data=None)[source]¶ Bases:
Patro.Common.Xml.XmlFile.XmlFileMixin
,Patro.FileFormat.Svg.SvgFile.SvgFileMixin
Class to read/write SVG file.
-
__dispatcher_cls__
¶ alias of
SvgDispatcher
-
_logger
= <Logger Patro.FileFormat.Svg.SvgFile.SvgFile (WARNING)>¶
-
height
¶
-
view_box
¶
-
width
¶
-
-
class
Patro.FileFormat.Svg.SvgFile.
SvgFileMixin
[source]¶ Bases:
object
-
SVG_DOCTYPE
= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'¶
-
SVG_version
= '1.1'¶
-
SVG_xmlns
= 'http://www.w3.org/2000/svg'¶
-
SVG_xmlns_xlink
= 'http://www.w3.org/1999/xlink'¶
-
-
class
Patro.FileFormat.Svg.SvgFile.
SvgFileWriter
(path, paper, root_tree, transformation=None)[source]¶ Bases:
Patro.FileFormat.Svg.SvgFile.SvgFileMixin
Class to write a SVF file.
-
COMMENT
= 'Pattern created with Patro (https://github.com/FabriceSalvaire/Patro)'¶
-
__init__
(path, paper, root_tree, transformation=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
_logger
= <Logger Patro.FileFormat.Svg.SvgFile.SvgFileWriter (WARNING)>¶
-