Path¶

class
svgwrite.path.
Path
(d=None, **extra)¶ The <path> element represent the outline of a shape which can be filled, stroked, used as a clipping path, or any combination of the three.

Path.
__init__
(d=None, **extra)¶ Parameters:  d (iterable) – coordinates, length and commands
 attribs (dict) – additional SVG attributes
 extra – additional SVG attributs as keywordarguments
Methods¶

Path.
push
(*elements)¶ Push commands and coordinats onto the command stack.
Parameters: elements (iterable) – coordinates, length and commands

Path.
push_arc
(target, rotation, r, large_arc=True, angle_dir='+', absolute=False)¶ Helper function for the ellipticalarc command.
see SVGReference: http://www.w3.org/TR/SVG11/paths.html#PathData
Parameters:  target (2tuple) – coordinate of the arc end point
 rotation (number) – xaxisrotation of the ellipse in degrees
 r (number2tuple) – radii rx, ry when r is a 2tuple or rx=ry=r if r is a number
 large_arc (bool) – draw the arc sweep of greater than or equal to 180 degrees (largearcflag)
 angle_dir –
'+'
'+'
means the arc will be drawn in a “positiveangle” direction (sweepflag)  absolute (bool) – indicates that target coordinates are absolute else they are relative to the current point
Parent Classes¶
Path Commands¶
Uppercase commands indicates absolute coordinates, lowercase commands indicates relative coordinates
horizontalline ‘h’, ‘H’ x+
Draws a horizontal line from the current point (cpx, cpy) to (x, cpy).
verticalline ‘v’, ‘V’ y+
Draws a vertical line from the current point (cpx, cpy) to (cpx, y).
line ‘l’, ‘L’ (x y)+
Draw a line from the current point to the given (x,y) coordinate.
moveto ‘m’, ‘M’ (x y)+
Start a new subpath at the given (x,y) coordinate. If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands. Hence, implicit lineto commands will be relative if the moveto is relative, and absolute if the moveto is absolute. If a relative moveto (m) appears as the first element of the path, then it is treated as a pair of absolute coordinates. In this case, subsequent pairs of coordinates are treated as relative even though the initial moveto is interpreted as an absolute moveto.
cubicbeziercurve ‘c’, ‘C’ (x1 y1 x2 y2 x y)+
Draws a cubic Bézier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve.
smoothcubicbeziercurve ‘s’, ‘S’ (x2 y2 x y)+
Draws a cubic Bézier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve).
quadraticbeziercurve ‘q’, ‘Q’ (x1 y1 x y)+
Draws a quadratic Bézier curve from the current point to (x,y) using (x1,y1) as the control point.
smoothquadraticbeziercurve ‘t’, ‘T’ (x y)+
Draws a quadratic Bézier curve from the current point to (x,y). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not a Q, q, T or t, assume the control point is coincident with the current point.)
ellipticalarc ‘a’, ‘A’ (rx ry xaxisrotation largearcflag sweepflag x y)+
Draws an elliptical arc from the current point to (x, y). The size and orientation of the ellipse are defined by two radii (rx, ry) and an xaxisrotation, which indicates how the ellipse as a whole is rotated relative to the current coordinate system. The center (cx, cy) of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. largearcflag and sweepflag contribute to the automatic calculations and help determine how the arc is drawn.
‘z’, ‘Z’
close current subpath
SVG Attributes¶
class – string
assigns one or more cssclassnames to an element
style – string
allows perelement cssstyle rules to be specified directly on a given element
externalResourcesRequired – bool
False: if document rendering can proceed even if external resources are unavailable else: True
transform – use
svgwrite.mixins.Transform
methodspathLength – <number>
the pathLength attribute can be used to provide the author’s computation of the total length of the path so that the user agent can scale distancealongapath computations by the ratio of ‘pathLength’ to the user agent’s own computed value for total path length. A “moveto” operation within a ‘path’ element is defined to have zero length.
d – string
The definition of the outline of a shape, use pushmethod to add commands and coordinates