Streamlined fork of mathandy/svgpathtools. Focuses on providing complete working support SVG path manipulations without document support. Input/output functionalities are limited to the parsing and pretty-printing of paths.
Main classes:
Path
objects correspond to general SVG paths, made up of one more connectedSubpath
sSubpath
objects correspond to continuous (connected) SVG paths; each subpath can be topologically closed or not, and subpaths that are geometrically closed are not necessarily topologically closed (i.e., just because the subpath ends where it starts does not mean thatZ
property has been set)Segment
is the parent class of the constituent segments that make up subpaths; each segment is either anArc
or aBezierCurve
Arc
afore-mentioned instance ofSegment
BezierCurve
instance ofSegment
, parent class ofLine
,QuadraticBezier
andCubicBezier
CubicBezier
instance ofBezierCurve
(andSegment
)QuadraticBezier
instance ofBezierCurve
(andSegment
)Line
instance ofBezierCurve
(andSegment
)Curve
base class from which all the above inherit
Thus:
- a
Path
is a container ofSubpath
s - a
Subpath
is a container ofSegment
s - each
Segment
is either anArc
or aBezierCurve
- the atomic
Segment
types areArc
,Line
,QuadraticBezier
andCubicBezier
, with the latter 3 inheriting fromBezierCurve
- besides the inheritances described above, all objects also inherit from
Curve
, where operations common to all objects such.length
or.transform
are implemented
Note Path
and Subpaths
present much the same API and
are often interchangeable objects.
- parse and pretty-print paths
- parse and pretty-print SVG transforms, navigating between three format types: transform
string
, list of tokens (["translate", 0, 10, "scale", 2.3]
), and numpynd.array
- apply transforms to paths
- compute tangent vectors and (right-hand rule) normal vectors
- compute curvature
- compute intersections between paths and/or segments
- compute bounding boxes of paths, subpaths and segments
- reverse segment/subpath/path orientation
- crop and split paths and segments
- offset and stroke paths
- take path unions
- compute enclosed area
- compute arc length
- compute inverse arc length
- convert between path, subpath and segment parameterizations (see notes on
Address
object below) - convert Arc segments to CubicBezier segments
- convert Bézier path segments to numpy.poly1d (polynomial) objects
- convert polynomials (in standard form) to their Bézier form
- some HTML color manipulation convenience functions (conversion from rgb tuples to hexadecimal strings and back, named html color table)
While positions on paths, subpaths and segments are specified
parameterically, this easily leads to "parameter ambiguity".
(I.e., does the given real number represent a segment, path or subpath
parameter?) To counter the tendency for confusion, the module wraps parameter
values inside of a larger Address
object that disambiguates the
type of the parameter. Address
objects can be substituted at all
points in the API for parameter values, and the module will check that the
right type of Address
object is used in the right place.
- numpy
This module is under a MIT License.