-
-
Notifications
You must be signed in to change notification settings - Fork 23
JavaScript API
thednp edited this page Jan 7, 2021
·
25 revisions
The SVGPathCommander construct comes with instance methods you can call, intuitive and easy to use:
- .toAbsolute() - will convert all path commands of a SVGPathElement with or without sub-path to absolute values; the absolute path is used by all other tools for specific processing;
- .toRelative() - will convert all path commands of a shape with or without sub-path to relative values;
-
.reverse(onlySubpath) - will reverse the shape draw direction by changing the order of all path segments and their coordinates; when the
onlySubpath
option is true, it will only reverse the draw direction of subpath shapes -
.normalize() - will convert path command values to absolute and convert shorthand
S
,T
,H
,V
toC
,Q
andL
respectivelly; -
.optimize() - will compute two
pathArray
s one with absolute and the other with relative values, then update thepathArray
segments using the values that convert to shortest string; - .transform(transformObject) - will normalize all path commands and apply a 2D transformation matrix to all path commands;
-
.flipX() - will call the above
transform()
method to apply a 180deg rotation on the X axis; -
.flipY() - will call the above
transform()
method to apply a 180deg rotation on the Y axis; -
.toString() - will return the
pathString
of the currentpathArray
stored in theinstance.segments
object.