@emasoft/svg-matrix 1.1.0 → 1.2.0
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/bin/svg-matrix.js +7 -6
- package/bin/svgm.js +109 -40
- package/dist/svg-matrix.min.js +7 -7
- package/dist/svg-toolbox.min.js +148 -228
- package/dist/svgm.min.js +152 -232
- package/dist/version.json +5 -5
- package/package.json +1 -1
- package/scripts/postinstall.js +72 -41
- package/scripts/test-postinstall.js +18 -16
- package/scripts/version-sync.js +78 -60
- package/src/animation-optimization.js +190 -98
- package/src/animation-references.js +11 -3
- package/src/arc-length.js +23 -20
- package/src/bezier-analysis.js +9 -13
- package/src/bezier-intersections.js +18 -4
- package/src/browser-verify.js +35 -8
- package/src/clip-path-resolver.js +285 -114
- package/src/convert-path-data.js +20 -8
- package/src/css-specificity.js +33 -9
- package/src/douglas-peucker.js +272 -141
- package/src/geometry-to-path.js +79 -22
- package/src/gjk-collision.js +287 -126
- package/src/index.js +56 -21
- package/src/inkscape-support.js +122 -101
- package/src/logger.js +43 -27
- package/src/marker-resolver.js +201 -121
- package/src/mask-resolver.js +231 -98
- package/src/matrix.js +9 -5
- package/src/mesh-gradient.js +22 -14
- package/src/off-canvas-detection.js +53 -17
- package/src/path-optimization.js +356 -171
- package/src/path-simplification.js +671 -256
- package/src/pattern-resolver.js +1 -3
- package/src/polygon-clip.js +396 -78
- package/src/svg-boolean-ops.js +90 -23
- package/src/svg-collections.js +1546 -667
- package/src/svg-flatten.js +152 -38
- package/src/svg-matrix-lib.js +2 -2
- package/src/svg-parser.js +5 -1
- package/src/svg-rendering-context.js +3 -1
- package/src/svg-toolbox-lib.js +2 -2
- package/src/svg-toolbox.js +99 -457
- package/src/svg-validation-data.js +513 -345
- package/src/svg2-polyfills.js +156 -93
- package/src/svgm-lib.js +8 -4
- package/src/transform-optimization.js +168 -51
- package/src/transforms2d.js +73 -40
- package/src/transforms3d.js +34 -27
- package/src/use-symbol-resolver.js +175 -76
- package/src/vector.js +80 -44
- package/src/vendor/inkscape-hatch-polyfill.js +143 -108
- package/src/vendor/inkscape-hatch-polyfill.min.js +291 -1
- package/src/vendor/inkscape-mesh-polyfill.js +953 -766
- package/src/vendor/inkscape-mesh-polyfill.min.js +896 -1
- package/src/verification.js +3 -4
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* SVG path conversion, and 2D/3D affine transformations using Decimal.js.
|
|
6
6
|
*
|
|
7
7
|
* @module @emasoft/svg-matrix
|
|
8
|
-
* @version 1.
|
|
8
|
+
* @version 1.2.0
|
|
9
9
|
* @license MIT
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
@@ -135,7 +135,7 @@ Decimal.set({ precision: 80 });
|
|
|
135
135
|
* Library version
|
|
136
136
|
* @constant {string}
|
|
137
137
|
*/
|
|
138
|
-
export const VERSION = '1.
|
|
138
|
+
export const VERSION = '1.2.0';
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* Default precision for path output (decimal places)
|
|
@@ -313,7 +313,6 @@ export {
|
|
|
313
313
|
analyzeCompatibilityMatrix,
|
|
314
314
|
generateFullCompatibilityMatrix,
|
|
315
315
|
printHierarchicalMatrix,
|
|
316
|
-
generateCompatibilityMatrixSVG_legacy,
|
|
317
316
|
generateCompatibilityMatrixSVG,
|
|
318
317
|
generateFlexibleSVGTable,
|
|
319
318
|
generateCompatibilityMatrixFlexible,
|
|
@@ -528,10 +527,14 @@ export function circleToPath(cx, cy, r, precision = DEFAULT_PRECISION) {
|
|
|
528
527
|
throw new TypeError("circleToPath: r cannot be null or undefined");
|
|
529
528
|
}
|
|
530
529
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
531
|
-
throw new TypeError(
|
|
530
|
+
throw new TypeError(
|
|
531
|
+
`circleToPath: precision must be a finite number, got ${typeof precision}`,
|
|
532
|
+
);
|
|
532
533
|
}
|
|
533
534
|
if (precision < 0) {
|
|
534
|
-
throw new RangeError(
|
|
535
|
+
throw new RangeError(
|
|
536
|
+
`circleToPath: precision must be non-negative, got ${precision}`,
|
|
537
|
+
);
|
|
535
538
|
}
|
|
536
539
|
return GeometryToPath.circleToPathData(cx, cy, r, precision);
|
|
537
540
|
}
|
|
@@ -561,10 +564,14 @@ export function ellipseToPath(cx, cy, rx, ry, precision = DEFAULT_PRECISION) {
|
|
|
561
564
|
throw new TypeError("ellipseToPath: ry cannot be null or undefined");
|
|
562
565
|
}
|
|
563
566
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
564
|
-
throw new TypeError(
|
|
567
|
+
throw new TypeError(
|
|
568
|
+
`ellipseToPath: precision must be a finite number, got ${typeof precision}`,
|
|
569
|
+
);
|
|
565
570
|
}
|
|
566
571
|
if (precision < 0) {
|
|
567
|
-
throw new RangeError(
|
|
572
|
+
throw new RangeError(
|
|
573
|
+
`ellipseToPath: precision must be non-negative, got ${precision}`,
|
|
574
|
+
);
|
|
568
575
|
}
|
|
569
576
|
return GeometryToPath.ellipseToPathData(cx, cy, rx, ry, precision);
|
|
570
577
|
}
|
|
@@ -604,10 +611,14 @@ export function rectToPath(
|
|
|
604
611
|
throw new TypeError("rectToPath: height cannot be null or undefined");
|
|
605
612
|
}
|
|
606
613
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
607
|
-
throw new TypeError(
|
|
614
|
+
throw new TypeError(
|
|
615
|
+
`rectToPath: precision must be a finite number, got ${typeof precision}`,
|
|
616
|
+
);
|
|
608
617
|
}
|
|
609
618
|
if (precision < 0) {
|
|
610
|
-
throw new RangeError(
|
|
619
|
+
throw new RangeError(
|
|
620
|
+
`rectToPath: precision must be non-negative, got ${precision}`,
|
|
621
|
+
);
|
|
611
622
|
}
|
|
612
623
|
return GeometryToPath.rectToPathData(
|
|
613
624
|
x,
|
|
@@ -646,10 +657,14 @@ export function lineToPath(x1, y1, x2, y2, precision = DEFAULT_PRECISION) {
|
|
|
646
657
|
throw new TypeError("lineToPath: y2 cannot be null or undefined");
|
|
647
658
|
}
|
|
648
659
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
649
|
-
throw new TypeError(
|
|
660
|
+
throw new TypeError(
|
|
661
|
+
`lineToPath: precision must be a finite number, got ${typeof precision}`,
|
|
662
|
+
);
|
|
650
663
|
}
|
|
651
664
|
if (precision < 0) {
|
|
652
|
-
throw new RangeError(
|
|
665
|
+
throw new RangeError(
|
|
666
|
+
`lineToPath: precision must be non-negative, got ${precision}`,
|
|
667
|
+
);
|
|
653
668
|
}
|
|
654
669
|
return GeometryToPath.lineToPathData(x1, y1, x2, y2, precision);
|
|
655
670
|
}
|
|
@@ -667,10 +682,14 @@ export function polygonToPath(points, precision = DEFAULT_PRECISION) {
|
|
|
667
682
|
throw new TypeError("polygonToPath: points cannot be null or undefined");
|
|
668
683
|
}
|
|
669
684
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
670
|
-
throw new TypeError(
|
|
685
|
+
throw new TypeError(
|
|
686
|
+
`polygonToPath: precision must be a finite number, got ${typeof precision}`,
|
|
687
|
+
);
|
|
671
688
|
}
|
|
672
689
|
if (precision < 0) {
|
|
673
|
-
throw new RangeError(
|
|
690
|
+
throw new RangeError(
|
|
691
|
+
`polygonToPath: precision must be non-negative, got ${precision}`,
|
|
692
|
+
);
|
|
674
693
|
}
|
|
675
694
|
return GeometryToPath.polygonToPathData(points, precision);
|
|
676
695
|
}
|
|
@@ -688,10 +707,14 @@ export function polylineToPath(points, precision = DEFAULT_PRECISION) {
|
|
|
688
707
|
throw new TypeError("polylineToPath: points cannot be null or undefined");
|
|
689
708
|
}
|
|
690
709
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
691
|
-
throw new TypeError(
|
|
710
|
+
throw new TypeError(
|
|
711
|
+
`polylineToPath: precision must be a finite number, got ${typeof precision}`,
|
|
712
|
+
);
|
|
692
713
|
}
|
|
693
714
|
if (precision < 0) {
|
|
694
|
-
throw new RangeError(
|
|
715
|
+
throw new RangeError(
|
|
716
|
+
`polylineToPath: precision must be non-negative, got ${precision}`,
|
|
717
|
+
);
|
|
695
718
|
}
|
|
696
719
|
return GeometryToPath.polylineToPathData(points, precision);
|
|
697
720
|
}
|
|
@@ -731,10 +754,14 @@ export function pathToString(commands, precision = DEFAULT_PRECISION) {
|
|
|
731
754
|
throw new TypeError("pathToString: commands cannot be null or undefined");
|
|
732
755
|
}
|
|
733
756
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
734
|
-
throw new TypeError(
|
|
757
|
+
throw new TypeError(
|
|
758
|
+
`pathToString: precision must be a finite number, got ${typeof precision}`,
|
|
759
|
+
);
|
|
735
760
|
}
|
|
736
761
|
if (precision < 0) {
|
|
737
|
-
throw new RangeError(
|
|
762
|
+
throw new RangeError(
|
|
763
|
+
`pathToString: precision must be non-negative, got ${precision}`,
|
|
764
|
+
);
|
|
738
765
|
}
|
|
739
766
|
return GeometryToPath.pathArrayToString(commands, precision);
|
|
740
767
|
}
|
|
@@ -783,10 +810,14 @@ export function transformPath(pathData, matrix, precision = DEFAULT_PRECISION) {
|
|
|
783
810
|
throw new TypeError("transformPath: matrix cannot be null or undefined");
|
|
784
811
|
}
|
|
785
812
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
786
|
-
throw new TypeError(
|
|
813
|
+
throw new TypeError(
|
|
814
|
+
`transformPath: precision must be a finite number, got ${typeof precision}`,
|
|
815
|
+
);
|
|
787
816
|
}
|
|
788
817
|
if (precision < 0) {
|
|
789
|
-
throw new RangeError(
|
|
818
|
+
throw new RangeError(
|
|
819
|
+
`transformPath: precision must be non-negative, got ${precision}`,
|
|
820
|
+
);
|
|
790
821
|
}
|
|
791
822
|
return GeometryToPath.transformPathData(pathData, matrix, precision);
|
|
792
823
|
}
|
|
@@ -805,10 +836,14 @@ export function elementToPath(element, precision = DEFAULT_PRECISION) {
|
|
|
805
836
|
throw new TypeError("elementToPath: element cannot be null or undefined");
|
|
806
837
|
}
|
|
807
838
|
if (typeof precision !== "number" || !Number.isFinite(precision)) {
|
|
808
|
-
throw new TypeError(
|
|
839
|
+
throw new TypeError(
|
|
840
|
+
`elementToPath: precision must be a finite number, got ${typeof precision}`,
|
|
841
|
+
);
|
|
809
842
|
}
|
|
810
843
|
if (precision < 0) {
|
|
811
|
-
throw new RangeError(
|
|
844
|
+
throw new RangeError(
|
|
845
|
+
`elementToPath: precision must be non-negative, got ${precision}`,
|
|
846
|
+
);
|
|
812
847
|
}
|
|
813
848
|
return GeometryToPath.convertElementToPath(element, precision);
|
|
814
849
|
}
|