TreePlotTransform¶
An SVG writer.
-
exception
cpip.plot.SVGWriter.
ExceptionSVGWriter
¶ Exception class for SVGWriter.
-
class
cpip.plot.SVGWriter.
SVGCircle
(theXmlStream, thePoint, theRadius, attrs=None)¶ A circle in SVG. See: http://www.w3.org/TR/2003/REC-SVG11-20030114/shapes.html#CircleElement
-
__init__
(theXmlStream, thePoint, theRadius, attrs=None)¶ Initialise the circle with a stream, a
cpip.plot.Coord.Pt
and acpip.plot.Coord.Dim
objects.Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - ptFrom (
cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])
) – Starting point. - theRadius – X radius.
- attrs (
dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGElipse
(theXmlStream, ptFrom, theRadX, theRadY, attrs=None)¶ An elipse in SVG. See: http://www.w3.org/TR/2003/REC-SVG11-20030114/shapes.html#EllipseElement
-
__init__
(theXmlStream, ptFrom, theRadX, theRadY, attrs=None)¶ Initialise the elipse with a stream, a
cpip.plot.Coord.Pt
and acpip.plot.Coord.Dim
objects.Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - ptFrom (
cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])
) – Starting point. - theRadX – X radius.
- theRadY – Y radius.
- attrs (
dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGGroup
(theXmlStream, attrs=None)¶ See: http://www.w3.org/TR/2003/REC-SVG11-20030114/struct.html#GElement
-
__init__
(theXmlStream, attrs=None)¶ Initialise the group with a stream.
Sadly we can’t use
**kwargs
because of Python restrictions on keyword names. For examplestroke-width
that is not a valid keyword argument (althoughstroke_width
would be). So instead we pass in an optional dictionary {string : string, ...}Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - attrs (
dict({str : [<class 'str'>, str]}), dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGLine
(theXmlStream, ptFrom, ptTo, attrs=None)¶ A line in SVG. See: http://www.w3.org/TR/2003/REC-SVG11-20030114/shapes.html#LineElement
-
__init__
(theXmlStream, ptFrom, ptTo, attrs=None)¶ Initialise the line with a stream, and two
cpip.plot.Coord.Pt
objects.Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - ptFrom (
cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])
) – Starting point. - ptTo (
cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])
) – Ending point. - attrs (
dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGPointList
(theXmlStream, name, pointS, attrs)¶ An abstract class that takes a list of points, derived by polyline and polygon.
-
__init__
(theXmlStream, name, pointS, attrs)¶ Initialise the element with a stream, a name, and a list of
cpip.plot.Coord.Pt
objects.NOTE: The units of the points are ignored, it is up to the caller to convert them to the User Coordinate System.
Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - name (
NoneType, str
) – Element name. - pointS – List of points
- attrs (
dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGPolygon
(theXmlStream, pointS, attrs=None)¶ A polygon in SVG. See: http://www.w3.org/TR/2003/REC-SVG11-20030114/shapes.html#PolygonElement
-
__init__
(theXmlStream, pointS, attrs=None)¶ Initialise the polygon with a stream, and a list of
cpip.plot.Coord.Pt
objects.NOTE: The units of the points are ignored, it is up to the caller to convert them to the User Coordinate System.
Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - pointS – List of points
- attrs (
dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGPolyline
(theXmlStream, pointS, attrs=None)¶ A polyline in SVG. See: http://www.w3.org/TR/2003/REC-SVG11-20030114/shapes.html#PolylineElement
-
__init__
(theXmlStream, pointS, attrs=None)¶ Initialise the polyline with a stream, and a list of
cpip.plot.Coord.Pt
objects.NOTE: The units of the points are ignored, it is up to the caller to convert them to the User Coordinate System.
Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - pointS – List of points
- attrs (
dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGRect
(theXmlStream, thePoint, theBox, attrs=None)¶ See: http://www.w3.org/TR/2003/REC-SVG11-20030114/shapes.html#RectElement
-
__init__
(theXmlStream, thePoint, theBox, attrs=None)¶ Initialise the rectangle with a stream, a
cpip.plot.Coord.Pt
and acpip.plot.Coord.Box
objects.Typical attributes:
{'fill' : "blue", 'stroke' : "black", 'stroke-width' : "2", }
<insert documentation for function>
Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - thePoint (
cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])
) – Starting point. - theBox (
cpip.plot.Coord.Box([cpip.plot.Coord.Dim([float, str]), <class 'cpip.plot.Coord.Dim'>]), cpip.plot.Coord.Box([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])]), cpip.plot.Coord.Box([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([int, <class 'str'>])]), cpip.plot.Coord.Box([cpip.plot.Coord.Dim([int, str]), cpip.plot.Coord.Dim([int, <class 'str'>])])
) – The box. - attrs (
dict({str : [<class 'str'>, str]}), dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGText
(theXmlStream, thePoint, theFont, theSize, attrs=None)¶ Text in SVG. See: http://www.w3.org/TR/2003/REC-SVG11-20030114/text.html#TextElement
-
__init__
(theXmlStream, thePoint, theFont, theSize, attrs=None)¶ Initialise the text with a stream, a
cpip.plot.Coord.Pt
and font as a string and size as an integer. If thePoint isNone
then no location will be specified (for example for use inside a<defs>
element.Parameters: - theXmlStream (
cpip.plot.SVGWriter.SVGWriter
) – The SVG stream. - thePoint (
cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])
) – Place to write the text. - theFont (
NoneType, str
) – Font. - theSize (
NoneType, int
) – Size - attrs (
dict({str : [str]})
) – Element attributes.
Returns: NoneType
- theXmlStream (
-
-
class
cpip.plot.SVGWriter.
SVGWriter
(theFile, theViewPort, rootAttrs=None, mustIndent=True)¶ An XML writer specialised for writing SVG.
-
__enter__
()¶ Context management.
Returns: cpip.plot.SVGWriter.SVGWriter
– <insert documentation for return values>
-
__init__
(theFile, theViewPort, rootAttrs=None, mustIndent=True)¶ Initialise the stream with a file and Coord.Box() object. The view port units must be the same for width and depth.
Parameters: - theFile (
_io.TextIOWrapper
) – Output file. - theViewPort (
cpip.plot.Coord.Box([cpip.plot.Coord.Dim([int, str]), cpip.plot.Coord.Dim([int, <class 'str'>])])
) – Viewport. - rootAttrs (
dict({str : [str]})
) – Root element attributes. - mustIndent (
bool
) – Indent elements or write them inline.
Returns: NoneType
- theFile (
-
-
cpip.plot.SVGWriter.
dimToTxt
(theDim)¶ Converts a Coord.Dim() object to text for SVG units.
Examples:
(2.0 / 3.0, 'in')
becomes'0.667in'
(2.0 / 3.0, 'mm')
becomes'0.7mm'
(23.123, 'px')
becomes'23px'
Parameters: theDim ( cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([int, str])
) – The dimensionReturns: str
– Text suitable for writing SVG, for example ‘0.667in’.