svg-path-commander 0.1.23 → 0.2.0-alpha1
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 -4
- package/dist/svg-path-commander.es5.js +3948 -0
- package/dist/svg-path-commander.es5.min.js +2 -0
- package/dist/svg-path-commander.esm.js +438 -411
- package/dist/svg-path-commander.esm.min.js +2 -2
- package/dist/svg-path-commander.js +1455 -1530
- package/dist/svg-path-commander.min.js +2 -2
- package/package.json +15 -2
- package/src/convert/pathToAbsolute.js +4 -4
- package/src/convert/pathToCurve.js +2 -2
- package/src/convert/pathToRelative.js +4 -4
- package/src/convert/pathToString.js +2 -2
- package/src/math/polygonLength.js +1 -2
- package/src/options/options.js +1 -1
- package/src/parser/error.js +2 -0
- package/src/parser/finalizeSegment.js +1 -1
- package/src/parser/isSpace.js +1 -1
- package/src/parser/paramsParser.js +1 -1
- package/src/parser/parsePathString.js +6 -11
- package/src/parser/pathParser.js +1 -1
- package/src/parser/scanFlag.js +3 -3
- package/src/parser/scanParam.js +7 -6
- package/src/parser/scanSegment.js +3 -2
- package/src/parser/skipSpaces.js +1 -1
- package/src/process/clonePath.js +1 -1
- package/src/process/fixArc.js +1 -1
- package/src/process/fixPath.js +2 -2
- package/src/process/getSVGMatrix.js +3 -2
- package/src/process/normalizePath.js +3 -3
- package/src/process/normalizeSegment.js +2 -2
- package/src/process/optimizePath.js +2 -2
- package/src/process/projection2d.js +2 -2
- package/src/process/reverseCurve.js +3 -3
- package/src/process/reversePath.js +4 -5
- package/src/process/roundPath.js +7 -6
- package/src/process/segmentToCubic.js +3 -3
- package/src/process/shortenSegment.js +3 -3
- package/src/process/splitCubic.js +1 -1
- package/src/process/splitPath.js +1 -1
- package/src/process/transformPath.js +8 -7
- package/src/svg-path-commander.js +60 -20
- package/src/util/getClosestPoint.js +1 -1
- package/src/util/getCubicSize.js +1 -1
- package/src/util/getDrawDirection.js +1 -1
- package/src/util/getPathArea.js +1 -1
- package/src/util/getPathBBox.js +2 -2
- package/src/util/getPathLength.js +1 -1
- package/src/util/getPointAtLength.js +1 -1
- package/src/util/getPropertiesAtLength.js +5 -4
- package/src/util/getPropertiesAtPoint.js +5 -4
- package/src/util/getSegmentAtLength.js +2 -2
- package/src/util/getSegmentOfPoint.js +2 -2
- package/src/util/getTotalLength.js +1 -1
- package/src/util/isAbsoluteArray.js +1 -1
- package/src/util/isCurveArray.js +1 -1
- package/src/util/isNormalizedArray.js +1 -1
- package/src/util/isPathArray.js +1 -1
- package/src/util/isPointInStroke.js +2 -2
- package/src/util/isRelativeArray.js +1 -1
- package/src/util/pathLengthFactory.js +12 -10
- package/src/util/segmentArcFactory.js +6 -5
- package/src/util/segmentCubicFactory.js +6 -5
- package/src/util/segmentLineFactory.js +2 -2
- package/src/util/segmentQuadFactory.js +6 -5
- package/src/util/shapeToPath.js +14 -14
- package/src/util/util.js +0 -2
- package/types/index.d.ts +1 -3
- package/types/more/modules.ts +0 -3
- package/types/more/svg.d.ts +11 -10
- package/types/svg-path-commander.d.ts +218 -228
- package/src/util/createPath.js +0 -17
- package/src/util/getPointAtPathLength.js +0 -15
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-

|
|
2
|
+
|
|
3
|
+

|
|
2
4
|
|
|
3
5
|
A modern set of ES6+ JavaScript tools for manipulating the `d` (description) attribute for *SVGPathElement* items. The library is implementing modern JavaScript API to produce reusable path strings with lossless quality. In addition, you also have a powerful tool to convert other SVG shapes like `<circle>` or `<rect>` to `<path>`.
|
|
4
6
|
|
|
@@ -45,10 +47,10 @@ Flip a path on the X axis:
|
|
|
45
47
|
```js
|
|
46
48
|
import SVGPathCommander from 'svg-path-commander';
|
|
47
49
|
|
|
48
|
-
const path = 'M0
|
|
50
|
+
const path = 'M0 0L100 0L50 100';
|
|
49
51
|
|
|
50
52
|
const flippedPathString = new SVGPathCommander(path).flipX().toString();
|
|
51
|
-
// result => 'M0
|
|
53
|
+
// result => 'M0 100h100L50 0'
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
Optimize a path string for best outcome by using the `round: 'auto'` option which will determine the amount of decimals based on the shape's bounding box:
|
|
@@ -167,7 +169,7 @@ For developer guidelines, and a complete list of static methods, head over to th
|
|
|
167
169
|
* all 3d transformations as well as skews will convert `A` (arc) path commands to `C` (cubic bezier) due to the lack of resources;
|
|
168
170
|
* most tools included with **SVGPathCommander** should work in your Node.js apps, but feel free to report any issue;
|
|
169
171
|
* other path commands like `R` (catmulRomBezier), `O`, `U` (ellipse and shorthand ellipse) are not present in the current draft and are not supported;
|
|
170
|
-
* normalization can mean many things to many people and our library is developed to convert path command values to absolute and shorthand to
|
|
172
|
+
* normalization can mean many things to many people and our library is developed to convert path command values to absolute and shorthand to longhand commands to provide a solid foundation for the main processing tools of our library;
|
|
171
173
|
* when compared to the native methods like `SVGPathElement.getTotalLength()` or `SVGPathElement.getPointAtLength()`, the output of our static methods is within a [0.002 - 0.05] margin delta, but from our experience it's proven to be a more consistent outcome.
|
|
172
174
|
|
|
173
175
|
|