svg-path-commander 0.2.0-alpha3 → 1.0.2
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 +11 -4
- package/dist/svg-path-commander.es5.js +708 -776
- package/dist/svg-path-commander.es5.min.js +2 -2
- package/dist/svg-path-commander.esm.js +684 -757
- package/dist/svg-path-commander.esm.min.js +2 -2
- package/dist/svg-path-commander.js +684 -757
- package/dist/svg-path-commander.min.js +2 -2
- package/package.json +10 -12
- package/src/convert/pathToAbsolute.js +1 -0
- package/src/convert/pathToCurve.js +1 -0
- package/src/convert/pathToRelative.js +1 -16
- package/src/convert/pathToString.js +1 -1
- package/src/parser/finalizeSegment.js +3 -16
- package/src/parser/isSpace.js +1 -0
- package/src/parser/parsePathString.js +0 -11
- package/src/parser/scanFlag.js +5 -5
- package/src/parser/scanParam.js +10 -7
- package/src/process/fixPath.js +1 -1
- package/src/process/getSVGMatrix.js +11 -12
- package/src/process/lineToCubic.js +2 -2
- package/src/process/normalizePath.js +1 -8
- package/src/process/normalizeSegment.js +5 -10
- package/src/process/optimizePath.js +1 -5
- package/src/process/projection2d.js +29 -9
- package/src/process/reverseCurve.js +0 -1
- package/src/process/reversePath.js +0 -10
- package/src/process/roundPath.js +3 -4
- package/src/process/segmentToCubic.js +1 -6
- package/src/process/shortenSegment.js +4 -7
- package/src/process/splitCubic.js +0 -4
- package/src/process/splitPath.js +19 -10
- package/src/process/transformPath.js +18 -40
- package/src/svg-path-commander.js +8 -9
- package/src/util/getPathArea.js +0 -2
- package/src/util/getPathBBox.js +16 -43
- package/src/util/getPointAtLength.js +1 -2
- package/src/util/getPropertiesAtLength.js +5 -10
- package/src/util/getPropertiesAtPoint.js +1 -2
- package/src/util/getSegmentAtLength.js +1 -3
- package/src/util/getSegmentOfPoint.js +1 -3
- package/src/util/getTotalLength.js +1 -2
- package/src/util/isAbsoluteArray.js +1 -1
- package/src/util/isCurveArray.js +2 -2
- package/src/util/isNormalizedArray.js +1 -1
- package/src/util/isPointInStroke.js +1 -1
- package/src/util/isRelativeArray.js +1 -1
- package/src/util/pathLengthFactory.js +55 -48
- package/src/util/segmentArcFactory.js +179 -28
- package/src/util/segmentCubicFactory.js +34 -20
- package/src/util/segmentLineFactory.js +25 -12
- package/src/util/segmentQuadFactory.js +37 -22
- package/src/util/shapeToPath.js +24 -13
- package/src/util/util.js +8 -2
- package/src/version.js +0 -1
- package/types/index.d.ts +3 -4
- package/types/more/modules.ts +1 -3
- package/types/more/svg.d.ts +8 -1
- package/types/svg-path-commander.d.ts +69 -106
- package/src/process/shorthandToCubic.js +0 -16
- package/src/process/shorthandToQuad.js +0 -16
- package/src/process/transformEllipse.js +0 -73
- package/src/util/getCubicSize.js +0 -66
- package/src/util/getPathLength.js +0 -21
package/README.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
# SVGPathCommander
|
|
1
|
+
# SVGPathCommander
|
|
2
|
+
[](https://coveralls.io/github/thednp/svg-path-commander)
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://github.com/thednp/svg-path-commander/actions/workflows/ci.yml)
|
|
2
6
|
|
|
3
7
|

|
|
4
8
|
|
|
@@ -9,6 +13,7 @@ A modern set of ES6+ JavaScript tools for manipulating the `d` (description) att
|
|
|
9
13
|
[](https://www.jsdelivr.com/package/npm/svg-path-commander)
|
|
10
14
|
|
|
11
15
|
While you may find familiar tools inside, this library brings ***new additions***:
|
|
16
|
+
* the build in `getBBox`, `getPointAtLength` and `getTotalLength` are more reliable and much more accurate than the native methods, not to mention their world class performance ratings;
|
|
12
17
|
* a tool that can *reverse path draw direction* without altering path commands, even with specific shorthand path commands;
|
|
13
18
|
* a unique tool that can *reverse path draw direction* for path strings with only 'C' path commands;
|
|
14
19
|
* a new and unique tool to *apply transform functions to path commands* via the modern *DOMMatrix* API.
|
|
@@ -16,11 +21,11 @@ While you may find familiar tools inside, this library brings ***new additions**
|
|
|
16
21
|
**The key differences with other libraries**:
|
|
17
22
|
* ES6+ sourced with modernized codebase and build tools; all inherited codebase has been modernized as well;
|
|
18
23
|
* along with the modern codebase, the library also comes with strong TypeScript definitions;
|
|
24
|
+
* this library can create 3D to 2D projections, making your SVGs look like 3D but in the SVG coordinate system;
|
|
19
25
|
* you can use this library in both web apps and Node.js, you are not restricted to a single environment;
|
|
20
|
-
* path command transformations are all consistent with the SVG coordinates system, where others compute transform origin only for rotation transformation
|
|
21
|
-
* this library can create 3D to 2D projections, making your SVGs look like 3D but in the SVG coordinate system.
|
|
26
|
+
* path command transformations are all consistent with the SVG coordinates system, where others compute transform origin only for rotation transformation.
|
|
22
27
|
|
|
23
|
-
**SVGPathCommander**
|
|
28
|
+
**SVGPathCommander** can use the [DOMMatrix API](https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix) for *SVGPathElement* path command transformation and implements a very fast and modernized [DOMMatrix shim](https://github.com/thednp/dommatrix).
|
|
24
29
|
There are a couple of good reasons for this implementation:
|
|
25
30
|
* *WebKitCSSMatrix* and *SVGMatrix* APIs are slowly pushed away by DOMMatrix, the green light for new and modern implementations;
|
|
26
31
|
* we can actually apply a [3D transformation](https://github.com/ndebeiss/svg3d) matrix to SVG path commands, by calculating a 2D projection of the actual shape in 3D coordinates;
|
|
@@ -183,6 +188,8 @@ For developer guidelines, and a complete list of static methods, head over to th
|
|
|
183
188
|
* Nicolas Debeissat for the inspiration on [svg3d](https://github.com/ndebeiss/svg3d)
|
|
184
189
|
* Mike Bostock for his awesome [closestPoint](https://bl.ocks.org/mbostock/8027637)
|
|
185
190
|
* James Halliday for his excelent [point-at-length](https://github.com/substack/point-at-length)
|
|
191
|
+
* Eric Eastwood for his excelent [svg-curve-lib](https://github.com/MadLittleMods/svg-curve-lib)
|
|
192
|
+
* PhET Interactive Simulations for their [kite](https://github.com/phetsims/kite)
|
|
186
193
|
|
|
187
194
|
# License
|
|
188
195
|
**SVGPathCommander** is released under [MIT Licence](https://github.com/thednp/svg-path-commander/blob/master/LICENSE).
|