svg-path-commander 2.2.2 → 2.2.4
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/CHANGELOG.md +19 -0
- package/README.md +2 -2
- package/dist/index.d.ts +337 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +135 -6
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/util.d.ts +189 -3
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +31 -2
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/interface.ts","../src/types.ts","../src/math/distanceSquareRoot.ts","../src/math/midPoint.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/convert/pathToAbsolute.ts","../src/convert/pathToRelative.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/parser/parsePathString.ts","../src/parser/pathParser.ts","../src/parser/finalizeSegment.ts","../src/parser/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.ts","../src/parser/scanFlag.ts","../src/parser/scanParam.ts","../src/parser/scanSegment.ts","../src/parser/skipSpaces.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/getClosestPoint.ts","../src/util/getDrawDirection.ts","../src/util/getPathArea.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isAbsoluteArray.ts","../src/util/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.ts","../src/process/normalizePath.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/transformPath.ts","../src/process/absolutizeSegment.ts","../src/process/arcToCubic.ts","../src/process/getSVGMatrix.ts","../src/process/iterate.ts","../src/process/lineToCubic.ts","../src/process/normalizeSegment.ts","../src/process/projection2d.ts","../src/process/quadToCubic.ts","../src/process/relativizeSegment.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/process/roundSegment.ts","../src/process/segmentToCubic.ts","../src/process/shortenSegment.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/equalizeSegments.ts","../src/morph/equalizePaths.ts","../src/intersect/pathIntersection.ts","../src/intersect/boundingBoxIntersect.ts","../src/intersect/isPointInsideBBox.ts","../src/main.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/interface.ts","../src/types.ts","../src/math/distanceSquareRoot.ts","../src/math/midPoint.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/convert/pathToAbsolute.ts","../src/convert/pathToRelative.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/parser/parsePathString.ts","../src/parser/pathParser.ts","../src/parser/finalizeSegment.ts","../src/parser/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.ts","../src/parser/scanFlag.ts","../src/parser/scanParam.ts","../src/parser/scanSegment.ts","../src/parser/skipSpaces.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/getClosestPoint.ts","../src/util/getDrawDirection.ts","../src/util/getPathArea.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isAbsoluteArray.ts","../src/util/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.ts","../src/process/normalizePath.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/transformPath.ts","../src/process/absolutizeSegment.ts","../src/process/arcToCubic.ts","../src/process/getSVGMatrix.ts","../src/process/iterate.ts","../src/process/lineToCubic.ts","../src/process/normalizeSegment.ts","../src/process/projection2d.ts","../src/process/quadToCubic.ts","../src/process/relativizeSegment.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/process/roundSegment.ts","../src/process/segmentToCubic.ts","../src/process/shortenSegment.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/equalizeSegments.ts","../src/morph/equalizePaths.ts","../src/intersect/pathIntersection.ts","../src/intersect/boundingBoxIntersect.ts","../src/intersect/isPointInsideBBox.ts","../src/main.ts"],"mappings":";;;;;;;;KAGY;;EAEV,SAAS;;EAET;;EAEA;;EAEA;;;KAIU;;EAEV;;IAEE;;IAEA;;;EAGF;;EAEA,UAAU;;;KAIA;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;GACC;;;KAIS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;KAIU;;EAEV;;EAEA;;EAEA;;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;;SAEX,oBAAW;;SAEX,yBAAgB;;SAEhB,8BAAqB;;SAErB,6BAAoB;;SAEpB,2BAAkB;;SAElB,0BAAiB;;SAEjB,uBAAc;;SAGd,wBAAe;;SAEf,qBAAY;;SAEZ,uBAAc;;SAEd,0BAAiB;;SAEjB,oBAAW;;SAEX,wBAAe;;SAEf,wBAAe;;SAEf,oBAAW;;SAGX,sBAAa;;SAEb,aAFa;;SAIb,oBAAW;;SAEX,yBAAgB;;SAGhB,0BAAiB;;SAEjB,mBAAU;;SAEV,qBAAY;;SAEZ,gBAAO;;SAEP,oBAAW;;SAEX,sBAAa;;SAEb,yBAAgB;;SAEhB,qBAAY;;SAEZ,qBAAY;;SAEZ,oBAAW;;SAEX,0BAAiB;;SAEjB,qBAAY;;SAEZ,oBAAW;;SAEX,kBAAS;;SAET,qBAAY;;SAEZ,uBAAc;;SAEd,uBAAc;;SAEd,kBAAS;;SAET,sBAAa;;SAEb,yBAAgB;;SAEhB,0BAAiB;;SAEjB,sBAAa;;SAEb,0BAAiB;;SAEjB,0BAAiB;;SAEjB,6BAAoB;;SAEpB,oBAAW;;SAEX,qBAAY;;SAEZ,wBAAe;;SAEf"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v2.2.
|
|
2
|
+
* SVGPathCommander v2.2.4 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2026 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
6
6
|
import CSSMatrix from "@thednp/dommatrix";
|
|
7
7
|
//#region package.json
|
|
8
|
-
var version = "2.2.
|
|
8
|
+
var version = "2.2.4";
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/math/midPoint.ts
|
|
11
11
|
/**
|
|
@@ -100,6 +100,7 @@ const getLineBBox = (x1, y1, x2, y2) => {
|
|
|
100
100
|
max(y1, y2)
|
|
101
101
|
];
|
|
102
102
|
};
|
|
103
|
+
/** The tools for line segment computation. */
|
|
103
104
|
const lineTools = {
|
|
104
105
|
getLineBBox,
|
|
105
106
|
getLineLength,
|
|
@@ -137,6 +138,7 @@ const Tvalues = [
|
|
|
137
138
|
-.9951872199970213,
|
|
138
139
|
.9951872199970213
|
|
139
140
|
];
|
|
141
|
+
/** The weights for the 32-point Gauss-Legendre quadrature. */
|
|
140
142
|
const Cvalues = [
|
|
141
143
|
.12793819534675216,
|
|
142
144
|
.12793819534675216,
|
|
@@ -237,11 +239,24 @@ const computeBezier = (points, t) => {
|
|
|
237
239
|
t
|
|
238
240
|
};
|
|
239
241
|
};
|
|
242
|
+
/**
|
|
243
|
+
* Calculates the speed (derivative magnitude) of a Bezier curve at parameter `t`.
|
|
244
|
+
*
|
|
245
|
+
* @param derivativeFn the curve derivative function
|
|
246
|
+
* @param t the sampled point ratio in `[0-1]`
|
|
247
|
+
* @returns the curve speed at parameter `t`
|
|
248
|
+
*/
|
|
240
249
|
const calculateBezier = (derivativeFn, t) => {
|
|
241
250
|
const d = derivativeFn(t);
|
|
242
251
|
const l = d.x * d.x + d.y * d.y;
|
|
243
252
|
return Math.sqrt(l);
|
|
244
253
|
};
|
|
254
|
+
/**
|
|
255
|
+
* Returns the total arc length of a Bezier segment.
|
|
256
|
+
*
|
|
257
|
+
* @param derivativeFn the curve derivative function
|
|
258
|
+
* @returns the total arc length
|
|
259
|
+
*/
|
|
245
260
|
const bezierLength = (derivativeFn) => {
|
|
246
261
|
return bezierLengthAtT(derivativeFn, 1);
|
|
247
262
|
};
|
|
@@ -323,6 +338,7 @@ const getBezierLength = (curve) => {
|
|
|
323
338
|
return computeBezier(dpoints[0], t);
|
|
324
339
|
});
|
|
325
340
|
};
|
|
341
|
+
/** The precision threshold to consider a cubic polynomial as quadratic. */
|
|
326
342
|
const CBEZIER_MINMAX_EPSILON = 1e-8;
|
|
327
343
|
/**
|
|
328
344
|
* Returns the most extreme points in a Quad Bezier segment.
|
|
@@ -363,6 +379,7 @@ const minmaxC = ([v1, cp1, cp2, v2]) => {
|
|
|
363
379
|
}
|
|
364
380
|
return [min, max];
|
|
365
381
|
};
|
|
382
|
+
/** The tools for Bezier curve computation. */
|
|
366
383
|
const bezierTools = {
|
|
367
384
|
bezierLength,
|
|
368
385
|
bezierLengthAtT,
|
|
@@ -706,6 +723,7 @@ const getArcBBox = (x1, y1, RX, RY, angle, LAF, SF, x, y) => {
|
|
|
706
723
|
yMax
|
|
707
724
|
];
|
|
708
725
|
};
|
|
726
|
+
/** The tools for elliptical arc computation. */
|
|
709
727
|
const arcTools = {
|
|
710
728
|
angleBetween,
|
|
711
729
|
arcLength,
|
|
@@ -842,6 +860,7 @@ const getCubicBBox = (x1, y1, c1x, c1y, c2x, c2y, x2, y2) => {
|
|
|
842
860
|
cyMinMax[1]
|
|
843
861
|
];
|
|
844
862
|
};
|
|
863
|
+
/** The tools for cubic Bezier computation. */
|
|
845
864
|
const cubicTools = {
|
|
846
865
|
getCubicBBox,
|
|
847
866
|
getCubicLength,
|
|
@@ -962,6 +981,7 @@ const getQuadBBox = (x1, y1, cx, cy, x2, y2) => {
|
|
|
962
981
|
cyMinMax[1]
|
|
963
982
|
];
|
|
964
983
|
};
|
|
984
|
+
/** The tools for quadratic Bezier computation. */
|
|
965
985
|
const quadTools = {
|
|
966
986
|
getPointAtQuadLength,
|
|
967
987
|
getPointAtQuadSegmentLength,
|
|
@@ -1025,6 +1045,7 @@ const polygonCentroid = (polygon) => {
|
|
|
1025
1045
|
const count = polygon.length;
|
|
1026
1046
|
return [sumX / count, sumY / count];
|
|
1027
1047
|
};
|
|
1048
|
+
/** The tools for polygon computation. */
|
|
1028
1049
|
const polygonTools = {
|
|
1029
1050
|
polygonArea,
|
|
1030
1051
|
polygonLength,
|
|
@@ -4224,6 +4245,14 @@ const intersect = (x1, y1, x2, y2, x3, y3, x4, y4) => {
|
|
|
4224
4245
|
y: py
|
|
4225
4246
|
};
|
|
4226
4247
|
};
|
|
4248
|
+
/**
|
|
4249
|
+
* Returns the intersection point(s) of two cubic Bezier curves.
|
|
4250
|
+
*
|
|
4251
|
+
* @param bez1 the coordinates of the first cubic Bezier segment
|
|
4252
|
+
* @param bez2 the coordinates of the second cubic Bezier segment
|
|
4253
|
+
* @param config optional intersection options
|
|
4254
|
+
* @returns the intersection points, or `undefined` if the curves do not intersect
|
|
4255
|
+
*/
|
|
4227
4256
|
const interHelper = (bez1, bez2, config) => {
|
|
4228
4257
|
const bbox1 = getCubicBBox(...bez1);
|
|
4229
4258
|
const bbox2 = getCubicBBox(...bez2);
|
|
@@ -4282,7 +4311,7 @@ const interHelper = (bez1, bez2, config) => {
|
|
|
4282
4311
|
* pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)
|
|
4283
4312
|
* // => 1
|
|
4284
4313
|
* pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)
|
|
4285
|
-
* // => [{ x:
|
|
4314
|
+
* // => [{ x: 80.4136, y: 19.5864, t1: 0.7262, t2: 0.2738 }]
|
|
4286
4315
|
* ```
|
|
4287
4316
|
*/
|
|
4288
4317
|
const pathsIntersection = (pathInput1, pathInput2, justCount = true) => {
|
|
@@ -4414,9 +4443,21 @@ var SVGPathCommander = class {
|
|
|
4414
4443
|
this.origin = origin;
|
|
4415
4444
|
return this;
|
|
4416
4445
|
}
|
|
4446
|
+
/**
|
|
4447
|
+
* Returns the path bounding box, equivalent to native `path.getBBox()`.
|
|
4448
|
+
*
|
|
4449
|
+
* @public
|
|
4450
|
+
* @returns the pathBBox
|
|
4451
|
+
*/
|
|
4417
4452
|
get bbox() {
|
|
4418
4453
|
return getPathBBox(this.segments);
|
|
4419
4454
|
}
|
|
4455
|
+
/**
|
|
4456
|
+
* Returns the total path length, equivalent to native `path.getTotalLength()`.
|
|
4457
|
+
*
|
|
4458
|
+
* @public
|
|
4459
|
+
* @returns the path total length
|
|
4460
|
+
*/
|
|
4420
4461
|
get length() {
|
|
4421
4462
|
return getTotalLength(this.segments);
|
|
4422
4463
|
}
|
|
@@ -4507,7 +4548,7 @@ var SVGPathCommander = class {
|
|
|
4507
4548
|
* @example
|
|
4508
4549
|
* ```ts
|
|
4509
4550
|
* new SVGPathCommander('M0 0L100 0L100 100L0 100Z').reverse().toString()
|
|
4510
|
-
* // => 'M0
|
|
4551
|
+
* // => 'M0 100L100 100L100 0L0 0Z'
|
|
4511
4552
|
* ```
|
|
4512
4553
|
*
|
|
4513
4554
|
* @param onlySubpath - option to reverse all sub-paths except first
|
|
@@ -4556,7 +4597,7 @@ var SVGPathCommander = class {
|
|
|
4556
4597
|
* @example
|
|
4557
4598
|
* ```ts
|
|
4558
4599
|
* new SVGPathCommander('M10 10L10 10L90 90').optimize().toString()
|
|
4559
|
-
* // => 'M10
|
|
4600
|
+
* // => 'M10 10v0l80 80'
|
|
4560
4601
|
* ```
|
|
4561
4602
|
*
|
|
4562
4603
|
* @returns this for chaining
|
|
@@ -4680,96 +4721,184 @@ var SVGPathCommander = class {
|
|
|
4680
4721
|
dispose() {
|
|
4681
4722
|
Object.keys(this).forEach((key) => delete this[key]);
|
|
4682
4723
|
}
|
|
4724
|
+
/** The default instance options. */
|
|
4683
4725
|
static options = defaultOptions;
|
|
4726
|
+
/**
|
|
4727
|
+
* The DOMMatrix shim used for transformations.
|
|
4728
|
+
* @see https://github.com/thednp/dommatrix
|
|
4729
|
+
*/
|
|
4684
4730
|
static CSSMatrix = CSSMatrix;
|
|
4731
|
+
/** The tools for elliptical arc computation. */
|
|
4685
4732
|
static arcTools = arcTools;
|
|
4733
|
+
/** The tools for Bezier curve computation. */
|
|
4686
4734
|
static bezierTools = bezierTools;
|
|
4735
|
+
/** The tools for cubic Bezier computation. */
|
|
4687
4736
|
static cubicTools = cubicTools;
|
|
4737
|
+
/** The tools for line segment computation. */
|
|
4688
4738
|
static lineTools = lineTools;
|
|
4739
|
+
/** The tools for polygon computation. */
|
|
4689
4740
|
static polygonTools = polygonTools;
|
|
4741
|
+
/** The tools for quadratic Bezier computation. */
|
|
4690
4742
|
static quadTools = quadTools;
|
|
4743
|
+
/** Parses a path string value or object and returns an array */
|
|
4691
4744
|
static pathToAbsolute = pathToAbsolute;
|
|
4745
|
+
/** Parses a path string value or object and returns an array */
|
|
4692
4746
|
static pathToRelative = pathToRelative;
|
|
4747
|
+
/** Parses a path string or PathArray and returns a new one */
|
|
4693
4748
|
static pathToCurve = pathToCurve;
|
|
4749
|
+
/** Returns a valid `d` attribute string value created */
|
|
4694
4750
|
static pathToString = pathToString;
|
|
4751
|
+
/** Returns the square root of the distance */
|
|
4695
4752
|
static distanceSquareRoot = distanceSquareRoot;
|
|
4753
|
+
/** Returns the coordinates of a specified distance */
|
|
4696
4754
|
static midPoint = midPoint;
|
|
4755
|
+
/** Returns an {x,y} vector rotated by a given */
|
|
4697
4756
|
static rotateVector = rotateVector;
|
|
4757
|
+
/** Rounds a number to the specified number of decimal places. */
|
|
4698
4758
|
static roundTo = roundTo;
|
|
4759
|
+
/** Parses a path string value and returns an array */
|
|
4699
4760
|
static parsePathString = parsePathString;
|
|
4761
|
+
/** Breaks the parsing of a pathString once a segment is finalized. */
|
|
4700
4762
|
static finalizeSegment = finalizeSegment;
|
|
4763
|
+
/** Error message prefix used when a path string cannot be parsed. */
|
|
4701
4764
|
static invalidPathValue = invalidPathValue;
|
|
4765
|
+
/** Checks if the character is an A (arc-to) path command. */
|
|
4702
4766
|
static isArcCommand = isArcCommand;
|
|
4767
|
+
/** Checks if a character is a digit. */
|
|
4703
4768
|
static isDigit = isDigit;
|
|
4769
|
+
/** Checks if the character is or belongs to a number. */
|
|
4704
4770
|
static isDigitStart = isDigitStart;
|
|
4771
|
+
/** Checks if the character is a MoveTo command. */
|
|
4705
4772
|
static isMoveCommand = isMoveCommand;
|
|
4773
|
+
/** Checks if the character is a path command. */
|
|
4706
4774
|
static isPathCommand = isPathCommand;
|
|
4775
|
+
/** Checks if the character is a space. */
|
|
4707
4776
|
static isSpace = isSpace;
|
|
4777
|
+
/** The number of parameters for each path command. */
|
|
4708
4778
|
static paramsCount = paramsCounts;
|
|
4779
|
+
/** Default parser parameters object used to track position state */
|
|
4709
4780
|
static paramsParser = paramsParser;
|
|
4781
|
+
/** The `PathParser` is used by the `parsePathString` static method */
|
|
4710
4782
|
static PathParser = PathParser;
|
|
4783
|
+
/** Validates an A (arc-to) specific path command value. */
|
|
4711
4784
|
static scanFlag = scanFlag;
|
|
4785
|
+
/** Validates every character of the path string, */
|
|
4712
4786
|
static scanParam = scanParam;
|
|
4787
|
+
/** Scans every character in the path string to determine */
|
|
4713
4788
|
static scanSegment = scanSegment;
|
|
4789
|
+
/** Points the parser to the next character in the */
|
|
4714
4790
|
static skipSpaces = skipSpaces;
|
|
4791
|
+
/** Small threshold value used for floating-point distance comparisons in path calculations. */
|
|
4715
4792
|
static distanceEpsilon = DISTANCE_EPSILON;
|
|
4793
|
+
/** Checks a `PathArray` for an unnecessary `Z` segment */
|
|
4716
4794
|
static fixPath = fixPath;
|
|
4795
|
+
/** Returns the point in path closest to a given point. */
|
|
4717
4796
|
static getClosestPoint = getClosestPoint;
|
|
4797
|
+
/** Check if a path is drawn clockwise and returns true if so, */
|
|
4718
4798
|
static getDrawDirection = getDrawDirection;
|
|
4799
|
+
/** Returns the area of a single cubic-bezier segment. */
|
|
4719
4800
|
static getPathArea = getPathArea;
|
|
4801
|
+
/** Calculates the bounding box of a path. */
|
|
4720
4802
|
static getPathBBox = getPathBBox;
|
|
4803
|
+
/** Returns [x,y] coordinates of a point at a given length along a path. */
|
|
4721
4804
|
static getPointAtLength = getPointAtLength;
|
|
4805
|
+
/** Returns the segment, its index and length as well as */
|
|
4722
4806
|
static getPropertiesAtLength = getPropertiesAtLength;
|
|
4807
|
+
/** Returns the point and segment in path closest to a given point as well as */
|
|
4723
4808
|
static getPropertiesAtPoint = getPropertiesAtPoint;
|
|
4809
|
+
/** Returns the segment at a given length. */
|
|
4724
4810
|
static getSegmentAtLength = getSegmentAtLength;
|
|
4811
|
+
/** Returns the path segment which contains a given point. */
|
|
4725
4812
|
static getSegmentOfPoint = getSegmentOfPoint;
|
|
4813
|
+
/** Returns the total length of a path, equivalent to `shape.getTotalLength()`. */
|
|
4726
4814
|
static getTotalLength = getTotalLength;
|
|
4815
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
4727
4816
|
static isAbsoluteArray = isAbsoluteArray;
|
|
4817
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
4728
4818
|
static isCurveArray = isCurveArray;
|
|
4819
|
+
/** Checks if a path is a polygon (only M, L, H, V, Z commands). */
|
|
4729
4820
|
static isPolygonArray = isPolygonArray;
|
|
4821
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
4730
4822
|
static isNormalizedArray = isNormalizedArray;
|
|
4823
|
+
/** Iterates an array to check if it's an actual `pathArray`. */
|
|
4731
4824
|
static isPathArray = isPathArray;
|
|
4825
|
+
/** Checks if a given point is in the stroke of a path. */
|
|
4732
4826
|
static isPointInStroke = isPointInStroke;
|
|
4827
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
4733
4828
|
static isRelativeArray = isRelativeArray;
|
|
4829
|
+
/** Parses a path string value to determine its validity */
|
|
4734
4830
|
static isValidPath = isValidPath;
|
|
4831
|
+
/** Samples points from a path to form a polygon approximation. */
|
|
4735
4832
|
static samplePolygon = samplePolygon;
|
|
4833
|
+
/** Supported shapes and their specific parameters. */
|
|
4736
4834
|
static shapeParams = shapeParams;
|
|
4835
|
+
/** Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`, */
|
|
4737
4836
|
static shapeToPath = shapeToPath;
|
|
4837
|
+
/** Returns a new PathArray from line attributes. */
|
|
4738
4838
|
static shapeToPathArray = shapeToPathArray;
|
|
4839
|
+
/** Returns an absolute segment of a `PathArray` object. */
|
|
4739
4840
|
static absolutizeSegment = absolutizeSegment;
|
|
4841
|
+
/** Converts A (arc-to) segments to C (cubic-bezier-to). */
|
|
4740
4842
|
static arcToCubic = arcToCubic;
|
|
4843
|
+
/** Returns a transformation matrix to apply to `<path>` elements. */
|
|
4741
4844
|
static getSVGMatrix = getSVGMatrix;
|
|
4845
|
+
/** Iterates over a `PathArray`, executing a callback for each segment. */
|
|
4742
4846
|
static iterate = iterate;
|
|
4847
|
+
/** Converts an L (line-to) segment to C (cubic-bezier). */
|
|
4743
4848
|
static lineToCubic = lineToCubic;
|
|
4849
|
+
/** Parses a path string or PathArray, then iterates the result for: */
|
|
4744
4850
|
static normalizePath = normalizePath;
|
|
4851
|
+
/** Normalizes a single segment of a `pathArray` object. */
|
|
4745
4852
|
static normalizeSegment = normalizeSegment;
|
|
4853
|
+
/** Optimizes a PathArray: */
|
|
4746
4854
|
static optimizePath = optimizePath;
|
|
4855
|
+
/** Transforms a specified point using a matrix, returning a new */
|
|
4747
4856
|
static projection2d = projection2d;
|
|
4857
|
+
/** Converts a Q (quadratic-bezier) segment to C (cubic-bezier). */
|
|
4748
4858
|
static quadToCubic = quadToCubic;
|
|
4859
|
+
/** Returns a relative segment of a `PathArray` object. */
|
|
4749
4860
|
static relativizeSegment = relativizeSegment;
|
|
4861
|
+
/** Reverses all segments of a `pathArray` */
|
|
4750
4862
|
static reverseCurve = reverseCurve;
|
|
4863
|
+
/** Reverses all segments of a PathArray and returns a new PathArray */
|
|
4751
4864
|
static reversePath = reversePath;
|
|
4865
|
+
/** Rounds the values of a `pathArray` instance to */
|
|
4752
4866
|
static roundPath = roundPath;
|
|
4867
|
+
/** Rounds the numeric values of a path segment to the specified precision. */
|
|
4753
4868
|
static roundSegment = roundSegment;
|
|
4869
|
+
/** Converts any segment to C (cubic-bezier). */
|
|
4754
4870
|
static segmentToCubic = segmentToCubic;
|
|
4871
|
+
/** Shorten a single segment of a `pathArray` object. */
|
|
4755
4872
|
static shortenSegment = shortenSegment;
|
|
4873
|
+
/** Split a path string or PathArray into an array of sub-paths. */
|
|
4756
4874
|
static splitPath = splitPath;
|
|
4875
|
+
/** Equalizes two paths for morphing (single/multi subpath). */
|
|
4757
4876
|
static equalizePaths = equalizePaths;
|
|
4877
|
+
/** Equalizes two paths for morphing (single subpath only). */
|
|
4758
4878
|
static equalizeSegments = equalizeSegments;
|
|
4879
|
+
/** Split a cubic Bézier into two cubics at parameter t [0–1]. */
|
|
4759
4880
|
static splitCubicSegment = splitCubicSegment;
|
|
4881
|
+
/** Apply a 2D / 3D transformation to a PathArray. */
|
|
4760
4882
|
static transformPath = transformPath;
|
|
4883
|
+
/** Checks if a point is inside a bounding box. */
|
|
4761
4884
|
static isPointInsideBBox = isPointInsideBBox;
|
|
4885
|
+
/** Finds intersection points between two paths. */
|
|
4762
4886
|
static pathsIntersection = pathsIntersection;
|
|
4887
|
+
/** Checks if two bounding boxes intersect. */
|
|
4763
4888
|
static boundingBoxIntersect = boundingBoxIntersect;
|
|
4889
|
+
/** Determines if an SVG path contains multiple subpaths. */
|
|
4764
4890
|
static isMultiPath = isMultiPath;
|
|
4891
|
+
/** Check if a PathArray is closed, which means its last segment is a Z. */
|
|
4765
4892
|
static isClosedPath = isClosedPath;
|
|
4893
|
+
/** Checks if a path is a polyline (only M, L, H, V commands). */
|
|
4766
4894
|
static isPolylineArray = isPolylineArray;
|
|
4895
|
+
/** The library version. */
|
|
4767
4896
|
static version = version;
|
|
4768
4897
|
};
|
|
4769
4898
|
//#endregion
|
|
4770
4899
|
//#region src/index.ts
|
|
4771
4900
|
var src_default = SVGPathCommander;
|
|
4772
4901
|
//#endregion
|
|
4773
|
-
export { src_default as default };
|
|
4902
|
+
export { SVGPathCommander, src_default as default };
|
|
4774
4903
|
|
|
4775
4904
|
//# sourceMappingURL=index.js.map
|