svg-path-commander 0.1.11-alpha4 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/svg-path-commander.esm.js +657 -627
- package/dist/svg-path-commander.esm.min.js +2 -2
- package/dist/svg-path-commander.js +685 -651
- package/dist/svg-path-commander.min.js +2 -2
- package/package.json +1 -1
- package/src/convert/pathToAbsolute.js +43 -59
- package/src/convert/pathToCurve.js +16 -11
- package/src/convert/pathToRelative.js +51 -57
- package/src/convert/pathToString.js +1 -1
- package/src/options/options.js +5 -6
- package/src/parser/finalizeSegment.js +4 -0
- package/src/parser/isPathCommand.js +1 -1
- package/src/parser/paramsCount.js +0 -3
- package/src/parser/paramsParser.js +8 -0
- package/src/parser/parsePathString.js +5 -2
- package/src/parser/pathParser.js +1 -0
- package/src/parser/scanFlag.js +1 -1
- package/src/parser/scanSegment.js +1 -0
- package/src/process/clonePath.js +2 -7
- package/src/process/fixArc.js +2 -3
- package/src/process/fixPath.js +7 -6
- package/src/process/getSVGMatrix.js +12 -12
- package/src/process/normalizePath.js +9 -11
- package/src/process/normalizeSegment.js +10 -6
- package/src/process/optimizePath.js +47 -16
- package/src/process/reverseCurve.js +5 -5
- package/src/process/reversePath.js +17 -13
- package/src/process/roundPath.js +16 -32
- package/src/process/segmentToCubic.js +19 -17
- package/src/process/shortenSegment.js +23 -22
- package/src/process/shorthandToQuad.js +1 -1
- package/src/process/transformPath.js +2 -4
- package/src/svg-path-commander.js +65 -38
- package/src/util/createPath.js +1 -1
- package/src/util/getPathArea.js +2 -2
- package/src/util/getPathBBox.js +5 -4
- package/src/util/getPathLength.js +0 -1
- package/src/util/getPointAtLength.js +1 -3
- package/src/util/isAbsoluteArray.js +2 -2
- package/src/util/isCurveArray.js +2 -3
- package/src/util/isNormalizedArray.js +3 -7
- package/src/util/isPathArray.js +1 -1
- package/src/util/isRelativeArray.js +2 -2
- package/src/util/shapeToPath.js +11 -11
- package/src/util/util.js +5 -4
- package/types/index.d.ts +99 -110
- package/types/modules.d.ts +1076 -0
- package/types/more/modules.ts +75 -0
- package/types/more/svg.d.ts +183 -0
- package/types/convert/pathToAbsolute.d.ts +0 -1
- package/types/convert/pathToCurve.d.ts +0 -1
- package/types/convert/pathToRelative.d.ts +0 -1
- package/types/convert/pathToString.d.ts +0 -1
- package/types/math/epsilon.d.ts +0 -2
- package/types/math/midPoint.d.ts +0 -1
- package/types/math/rotateVector.d.ts +0 -4
- package/types/options/options.d.ts +0 -6
- package/types/parser/finalizeSegment.d.ts +0 -1
- package/types/parser/invalidPathValue.d.ts +0 -2
- package/types/parser/isArcCommand.d.ts +0 -1
- package/types/parser/isDigit.d.ts +0 -1
- package/types/parser/isDigitStart.d.ts +0 -1
- package/types/parser/isPathCommand.d.ts +0 -1
- package/types/parser/isSpace.d.ts +0 -1
- package/types/parser/paramsCount.d.ts +0 -4
- package/types/parser/parsePathString.d.ts +0 -1
- package/types/parser/pathParser.d.ts +0 -12
- package/types/parser/scanFlag.d.ts +0 -1
- package/types/parser/scanParam.d.ts +0 -1
- package/types/parser/scanSegment.d.ts +0 -1
- package/types/parser/skipSpaces.d.ts +0 -1
- package/types/process/arcToCubic.d.ts +0 -1
- package/types/process/clonePath.d.ts +0 -1
- package/types/process/fixArc.d.ts +0 -1
- package/types/process/fixPath.d.ts +0 -1
- package/types/process/getSVGMatrix.d.ts +0 -2
- package/types/process/lineToCubic.d.ts +0 -1
- package/types/process/normalizePath.d.ts +0 -1
- package/types/process/normalizeSegment.d.ts +0 -1
- package/types/process/optimizePath.d.ts +0 -1
- package/types/process/projection2d.d.ts +0 -1
- package/types/process/quadToCubic.d.ts +0 -1
- package/types/process/reverseCurve.d.ts +0 -1
- package/types/process/reversePath.d.ts +0 -1
- package/types/process/roundPath.d.ts +0 -1
- package/types/process/segmentToCubic.d.ts +0 -1
- package/types/process/shortenSegment.d.ts +0 -1
- package/types/process/shorthandToCubic.d.ts +0 -4
- package/types/process/shorthandToQuad.d.ts +0 -4
- package/types/process/splitPath.d.ts +0 -1
- package/types/process/transformEllipse.d.ts +0 -5
- package/types/process/transformPath.d.ts +0 -1
- package/types/svg-path-commander.d.ts +0 -18
- package/types/util/getCubicSize.d.ts +0 -1
- package/types/util/getDrawDirection.d.ts +0 -1
- package/types/util/getPathArea.d.ts +0 -1
- package/types/util/getPathBBox.d.ts +0 -1
- package/types/util/getPathLength.d.ts +0 -1
- package/types/util/getPointAtLength.d.ts +0 -1
- package/types/util/getPointAtSegLength.d.ts +0 -4
- package/types/util/getSegCubicLength.d.ts +0 -1
- package/types/util/isAbsoluteArray.d.ts +0 -1
- package/types/util/isCurveArray.d.ts +0 -1
- package/types/util/isNormalizedArray.d.ts +0 -1
- package/types/util/isPathArray.d.ts +0 -1
- package/types/util/isRelativeArray.d.ts +0 -1
- package/types/util/isValidPath.d.ts +0 -1
- package/types/util/shapeToPath.d.ts +0 -6
- package/types/util/util.d.ts +0 -63
- package/types/util/version.d.ts +0 -2
package/README.md
CHANGED
|
@@ -55,17 +55,17 @@ For developer guidelines, head over to the [wiki pages](https://github.com/thedn
|
|
|
55
55
|
|
|
56
56
|
* converting and optimizing *SVGPathElement* for use in third party application; our [KUTE.js](https://github.com/thednp/kute.js) animation engine is using it to process *SVGPathElement* coordinates for [SVG morphing](https://thednp.github.io/kute.js/svgMorph.html) and [SVG cubic morphing](https://thednp.github.io/kute.js/svgCubicMorph.html);
|
|
57
57
|
* animators that work with SVGs and need tools for performing specific path command processing;
|
|
58
|
-
* font-icon creators can use it in both Node.js and web applications to process and test their creations.
|
|
58
|
+
* font-icon creators can use it in both Node.js and web applications to process, optimize and test their creations.
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
# Technical Considerations
|
|
62
62
|
|
|
63
|
-
* the `optimize()` instance method will not merge path segments (for instance
|
|
64
|
-
* all tools processing path segments will
|
|
63
|
+
* the `optimize()` instance method will not merge path segments (for instance two or more cubic-bezier segments into one or more arc segments); however, the script will try to provide shorthand notations where possible, pick the shortest string for each segment, and generally try to deliver the best possible outcome;
|
|
64
|
+
* all tools processing path segments will never round float values, however `pathToString`, `optimizePath` and especially `roundPath` will always round values to the default of 4 decimals; EG: 0.56676 => 0.567, 0.50 => 0.5; you can change the default option with `SVGPathCommander.options.round = 2` or remove the value rounding all together with `SVGPathCommander.options.round = false`; you can also control this feature via instance options;
|
|
65
65
|
* the `getSVGMatrix` utility we developed will always compute the matrix by applying the transform functions in the following order: `translate`, `rotate`, `skew` and `scale`, which is the default composition/recomposition order specified in the W3C draft;
|
|
66
|
-
* all 3d transformations as well as skews will convert `A` (arc) path commands to `C` (cubic bezier) due to the lack of resources
|
|
67
|
-
* most tools included with **SVGPathCommander** should work in your Node.js apps, but
|
|
68
|
-
* other path commands like `R` (catmulRomBezier), `O`, `U` (ellipse and shorthand ellipse) are not present in the current draft and
|
|
66
|
+
* all 3d transformations as well as skews will convert `A` (arc) path commands to `C` (cubic bezier) due to the lack of resources;
|
|
67
|
+
* most tools included with **SVGPathCommander** should work in your Node.js apps, but feel free to report any issue;
|
|
68
|
+
* other path commands like `R` (catmulRomBezier), `O`, `U` (ellipse and shorthand ellipse) are not present in the current draft and are not supported;
|
|
69
69
|
* normalization can mean many things to many people and our library is developed to convert path command values to absolute and shorthand to non-shorthand commands to provide a solid foundation for the main processing tools of our library.
|
|
70
70
|
|
|
71
71
|
|