svg-path-commander 2.2.3 → 2.3.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/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * SVGPathCommander v2.2.3 (http://thednp.github.io/svg-path-commander)
2
+ * SVGPathCommander v2.3.0 (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.3";
8
+ var version = "2.3.0";
9
9
  //#endregion
10
10
  //#region src/math/midPoint.ts
11
11
  /**
@@ -1120,12 +1120,25 @@ const finalizeSegment = (path) => {
1120
1120
  let pathCommand = path.pathValue[path.segmentStart];
1121
1121
  let relativeCommand = pathCommand.toLowerCase();
1122
1122
  const { data } = path;
1123
- while (data.length >= paramsCounts[relativeCommand]) {
1124
- if (relativeCommand === "m" && data.length > 2) {
1125
- path.segments.push([pathCommand].concat(data.splice(0, 2)));
1123
+ let index = 0;
1124
+ while (data.length - index >= paramsCounts[relativeCommand]) {
1125
+ if (relativeCommand === "m" && data.length - index > 2) {
1126
+ const segment = new Array(3);
1127
+ segment[0] = pathCommand;
1128
+ segment[1] = data[index];
1129
+ segment[2] = data[index + 1];
1130
+ path.segments.push(segment);
1131
+ index += 2;
1126
1132
  relativeCommand = "l";
1127
1133
  pathCommand = pathCommand === "m" ? "l" : "L";
1128
- } else path.segments.push([pathCommand].concat(data.splice(0, paramsCounts[relativeCommand])));
1134
+ } else {
1135
+ const paramCount = paramsCounts[relativeCommand];
1136
+ const segment = new Array(paramCount + 1);
1137
+ segment[0] = pathCommand;
1138
+ for (let i = 0; i < paramCount; i += 1) segment[i + 1] = data[index + i];
1139
+ path.segments.push(segment);
1140
+ index += paramCount;
1141
+ }
1129
1142
  if (!paramsCounts[relativeCommand]) break;
1130
1143
  }
1131
1144
  };
@@ -1240,7 +1253,60 @@ const scanParam = (path) => {
1240
1253
  }
1241
1254
  }
1242
1255
  path.index = index;
1243
- path.param = +path.pathValue.slice(start, index);
1256
+ path.param = scanNumber(pathValue, start, index);
1257
+ };
1258
+ /**
1259
+ * Converts a validated number substring to a Number without
1260
+ * allocating a new string, matching `+str.slice(start, end)`.
1261
+ *
1262
+ * Falls back to the native conversion when the value cannot be
1263
+ * represented exactly with plain double arithmetic (more than 15
1264
+ * significant digits or an exponent beyond +-22).
1265
+ *
1266
+ * @param str - the path string
1267
+ * @param start - the index of the first char of the number
1268
+ * @param end - the index after the last char of the number
1269
+ * @returns the parsed number
1270
+ */
1271
+ const scanNumber = (str, start, end) => {
1272
+ let i = start;
1273
+ let sign = 1;
1274
+ let param = 0;
1275
+ let decimals = 0;
1276
+ let sigDigits = 0;
1277
+ let inFraction = false;
1278
+ let expSign = 1;
1279
+ let exp = 0;
1280
+ const ch = str.charCodeAt(i);
1281
+ if (ch === 43) i += 1;
1282
+ else if (ch === 45) {
1283
+ sign = -1;
1284
+ i += 1;
1285
+ }
1286
+ for (; i < end; i += 1) {
1287
+ const code = str.charCodeAt(i);
1288
+ if (code === 46) inFraction = true;
1289
+ else if (code === 101 || code === 69) {
1290
+ i += 1;
1291
+ const expCode = str.charCodeAt(i);
1292
+ if (expCode === 43) i += 1;
1293
+ else if (expCode === 45) {
1294
+ expSign = -1;
1295
+ i += 1;
1296
+ }
1297
+ for (; i < end; i += 1) exp = exp * 10 + (str.charCodeAt(i) - 48);
1298
+ } else {
1299
+ const digit = code - 48;
1300
+ if (digit !== 0 || param !== 0) sigDigits += 1;
1301
+ param = param * 10 + digit;
1302
+ if (inFraction) decimals += 1;
1303
+ }
1304
+ }
1305
+ if (sigDigits > 15 || sigDigits === 0) return +str.slice(start, end);
1306
+ const scale = expSign * exp - decimals;
1307
+ if (scale > 22 || scale < -22) return +str.slice(start, end);
1308
+ if (scale >= 0) return sign * param * 10 ** scale;
1309
+ return sign * param / 10 ** -scale;
1244
1310
  };
1245
1311
  //#endregion
1246
1312
  //#region src/parser/isSpace.ts
@@ -1484,6 +1550,15 @@ const absolutizeSegment = (segment, index, lastX, lastY) => {
1484
1550
  segment[1] + lastX,
1485
1551
  segment[2] + lastY
1486
1552
  ];
1553
+ else if (absCommand === "C") return [
1554
+ absCommand,
1555
+ segment[1] + lastX,
1556
+ segment[2] + lastY,
1557
+ segment[3] + lastX,
1558
+ segment[4] + lastY,
1559
+ segment[5] + lastX,
1560
+ segment[6] + lastY
1561
+ ];
1487
1562
  else {
1488
1563
  const absValues = [];
1489
1564
  const seglen = segment.length;
@@ -1529,8 +1604,9 @@ const iterate = (path, iterator) => {
1529
1604
  while (i < path.length) {
1530
1605
  const segment = path[i];
1531
1606
  const [pathCommand] = segment;
1532
- const absCommand = pathCommand.toUpperCase();
1533
- const isRelative = absCommand !== pathCommand;
1607
+ const commandCode = pathCommand.charCodeAt(0);
1608
+ const isRelative = commandCode >= 97;
1609
+ const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
1534
1610
  const iteratorResult = iterator(segment, i, x, y);
1535
1611
  if (iteratorResult === false) break;
1536
1612
  if (absCommand === "Z") {
@@ -1974,20 +2050,19 @@ const pathToString = (path, roundOption) => {
1974
2050
  let segment = path[0];
1975
2051
  let result = "";
1976
2052
  round = roundOption === "off" ? roundOption : typeof roundOption === "number" && roundOption >= 0 ? roundOption : typeof round === "number" && round >= 0 ? round : "off";
2053
+ const pow = round === "off" ? 0 : 10 ** round;
1977
2054
  for (let i = 0; i < pathLen; i += 1) {
1978
2055
  segment = path[i];
1979
- const [pathCommand] = segment;
1980
- const values = segment.slice(1);
2056
+ const pathCommand = segment[0];
2057
+ const segLen = segment.length;
1981
2058
  result += pathCommand;
1982
- if (round === "off") result += values.join(" ");
1983
- else {
1984
- let j = 0;
1985
- const valLen = values.length;
1986
- while (j < valLen) {
1987
- result += roundTo(values[j], round);
1988
- if (j !== valLen - 1) result += " ";
1989
- j += 1;
1990
- }
2059
+ if (round === "off") for (let j = 1; j < segLen; j += 1) {
2060
+ result += segment[j];
2061
+ if (j !== segLen - 1) result += " ";
2062
+ }
2063
+ else for (let j = 1; j < segLen; j += 1) {
2064
+ result += Math.round(segment[j] * pow) / pow;
2065
+ if (j !== segLen - 1) result += " ";
1991
2066
  }
1992
2067
  }
1993
2068
  return result;
@@ -2039,8 +2114,10 @@ const getPathBBox = (pathInput) => {
2039
2114
  let paramQY = 0;
2040
2115
  iterate(path, (seg, index, lastX, lastY) => {
2041
2116
  [pathCommand] = seg;
2042
- const absCommand = pathCommand.toUpperCase();
2043
- const absoluteSegment = absCommand !== pathCommand ? absolutizeSegment(seg, index, lastX, lastY) : seg.slice(0);
2117
+ const commandCode = pathCommand.charCodeAt(0);
2118
+ const isRelative = commandCode >= 97;
2119
+ const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
2120
+ const absoluteSegment = isRelative ? absolutizeSegment(seg, index, lastX, lastY) : seg;
2044
2121
  const normalSegment = absCommand === "V" ? [
2045
2122
  "L",
2046
2123
  lastX,
@@ -2051,7 +2128,7 @@ const getPathBBox = (pathInput) => {
2051
2128
  lastY
2052
2129
  ] : absoluteSegment;
2053
2130
  [pathCommand] = normalSegment;
2054
- if (!"TQ".includes(absCommand)) {
2131
+ if (absCommand !== "T" && absCommand !== "Q") {
2055
2132
  paramQX = 0;
2056
2133
  paramQY = 0;
2057
2134
  }
@@ -2081,8 +2158,24 @@ const getPathBBox = (pathInput) => {
2081
2158
  yMin = min(minY, yMin);
2082
2159
  xMax = max(maxX, xMax);
2083
2160
  yMax = max(maxY, yMax);
2084
- [paramX1, paramY1] = pathCommand === "Z" ? [mx, my] : normalSegment.slice(-2);
2085
- [paramX2, paramY2] = pathCommand === "C" ? [normalSegment[3], normalSegment[4]] : pathCommand === "S" ? [normalSegment[1], normalSegment[2]] : [paramX1, paramY1];
2161
+ if (pathCommand === "Z") {
2162
+ paramX1 = mx;
2163
+ paramY1 = my;
2164
+ } else {
2165
+ const segLen = normalSegment.length;
2166
+ paramX1 = normalSegment[segLen - 2];
2167
+ paramY1 = normalSegment[segLen - 1];
2168
+ }
2169
+ if (pathCommand === "C") {
2170
+ paramX2 = normalSegment[3];
2171
+ paramY2 = normalSegment[4];
2172
+ } else if (pathCommand === "S") {
2173
+ paramX2 = normalSegment[1];
2174
+ paramY2 = normalSegment[2];
2175
+ } else {
2176
+ paramX2 = paramX1;
2177
+ paramY2 = paramY1;
2178
+ }
2086
2179
  });
2087
2180
  const width = xMax - xMin;
2088
2181
  const height = yMax - yMin;
@@ -3395,6 +3488,12 @@ const getSVGMatrix = (transform) => {
3395
3488
  * @returns the resulting Tuple
3396
3489
  */
3397
3490
  const translatePoint = (cssm, v) => {
3491
+ if (cssm.is2D) return [
3492
+ cssm.a * v[0] + cssm.c * v[1] + cssm.e * v[3],
3493
+ cssm.b * v[0] + cssm.d * v[1] + cssm.f * v[3],
3494
+ 0,
3495
+ 1
3496
+ ];
3398
3497
  let m = CSSMatrix.Translate(v[0], v[1], v[2]);
3399
3498
  [, , , m.m44] = v;
3400
3499
  m = cssm.multiply(m);
@@ -3435,6 +3534,161 @@ const projection2d = (m, point2D, origin) => {
3435
3534
  //#endregion
3436
3535
  //#region src/process/transformPath.ts
3437
3536
  /**
3537
+ * Applies a 2D transformation to a `PathArray` in a single pass, without
3538
+ * absolutizing or copying each segment, returning a new absolute `PathArray`.
3539
+ *
3540
+ * @param path the parsed path value
3541
+ * @param a the `a` value of the matrix
3542
+ * @param b the `b` value of the matrix
3543
+ * @param c the `c` value of the matrix
3544
+ * @param d the `d` value of the matrix
3545
+ * @param e the `e` value of the matrix
3546
+ * @param f the `f` value of the matrix
3547
+ * @param originX the transform origin `x` value
3548
+ * @param originY the transform origin `y` value
3549
+ * @returns the transformed absolute path
3550
+ */
3551
+ const transform2D = (path, a, b, c, d, e, f, originX, originY) => {
3552
+ const result = [];
3553
+ let x = 0;
3554
+ let y = 0;
3555
+ let lx = 0;
3556
+ let ly = 0;
3557
+ let ox = 0;
3558
+ let oy = 0;
3559
+ let omx = 0;
3560
+ let omy = 0;
3561
+ for (let i = 0, len = path.length; i < len; i += 1) {
3562
+ const seg = path[i];
3563
+ const pathCommand = seg[0];
3564
+ const commandCode = pathCommand.charCodeAt(0);
3565
+ const isRelative = commandCode >= 97;
3566
+ const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
3567
+ const outCommand = i === 0 && isRelative ? pathCommand : absCommand;
3568
+ if (absCommand === "Z") {
3569
+ result.push(["Z"]);
3570
+ ox = omx;
3571
+ oy = omy;
3572
+ continue;
3573
+ }
3574
+ if (absCommand === "V") {
3575
+ const absY = seg[1] + (isRelative ? oy : 0);
3576
+ lx = a * ox + c * absY + e - originX + originX;
3577
+ ly = b * ox + d * absY + f - originY + originY;
3578
+ if (x !== lx && y !== ly) result.push([
3579
+ "L",
3580
+ lx,
3581
+ ly
3582
+ ]);
3583
+ else if (y === ly) result.push(["H", lx]);
3584
+ else if (x === lx) result.push(["V", ly]);
3585
+ else result.push([
3586
+ "L",
3587
+ ox,
3588
+ absY
3589
+ ]);
3590
+ oy = absY;
3591
+ x = lx;
3592
+ y = ly;
3593
+ continue;
3594
+ }
3595
+ if (absCommand === "H") {
3596
+ const absX = seg[1] + (isRelative ? ox : 0);
3597
+ lx = a * absX + c * oy + e - originX + originX;
3598
+ ly = b * absX + d * oy + f - originY + originY;
3599
+ if (x !== lx && y !== ly) result.push([
3600
+ "L",
3601
+ lx,
3602
+ ly
3603
+ ]);
3604
+ else if (y === ly) result.push(["H", lx]);
3605
+ else if (x === lx) result.push(["V", ly]);
3606
+ else result.push([
3607
+ "L",
3608
+ absX,
3609
+ oy
3610
+ ]);
3611
+ ox = absX;
3612
+ x = lx;
3613
+ y = ly;
3614
+ continue;
3615
+ }
3616
+ if (absCommand === "A") {
3617
+ const absX = seg[6] + (isRelative ? ox : 0);
3618
+ const absY = seg[7] + (isRelative ? oy : 0);
3619
+ const cubics = arcToCubic(ox, oy, seg[1], seg[2], seg[3], seg[4], seg[5], absX, absY);
3620
+ const cubicsLen = cubics.length;
3621
+ let k = 0;
3622
+ if (cubicsLen > 0) do {
3623
+ const piece = ["C"];
3624
+ const end = k + 6;
3625
+ for (let j = k; j < end; j += 2) {
3626
+ lx = a * cubics[j] + c * cubics[j + 1] + e - originX + originX;
3627
+ ly = b * cubics[j] + d * cubics[j + 1] + f - originY + originY;
3628
+ piece.push(lx, ly);
3629
+ }
3630
+ result.push(piece);
3631
+ k = end;
3632
+ } while (k < cubicsLen);
3633
+ else result.push(["C"]);
3634
+ if (cubicsLen > 0) {
3635
+ ox = cubics[cubicsLen - 2];
3636
+ oy = cubics[cubicsLen - 1];
3637
+ } else {
3638
+ ox = absX;
3639
+ oy = absY;
3640
+ }
3641
+ x = lx;
3642
+ y = ly;
3643
+ continue;
3644
+ }
3645
+ if (absCommand === "L") {
3646
+ const absX = seg[1] + (isRelative ? ox : 0);
3647
+ const absY = seg[2] + (isRelative ? oy : 0);
3648
+ lx = a * absX + c * absY + e - originX + originX;
3649
+ ly = b * absX + d * absY + f - originY + originY;
3650
+ if (x !== lx && y !== ly) result.push([
3651
+ "L",
3652
+ lx,
3653
+ ly
3654
+ ]);
3655
+ else if (y === ly) result.push(["H", lx]);
3656
+ else if (x === lx) result.push(["V", ly]);
3657
+ else result.push([
3658
+ "L",
3659
+ absX,
3660
+ absY
3661
+ ]);
3662
+ ox = absX;
3663
+ oy = absY;
3664
+ x = lx;
3665
+ y = ly;
3666
+ continue;
3667
+ }
3668
+ {
3669
+ const piece = [outCommand];
3670
+ const segLen = seg.length;
3671
+ for (let j = 1; j < segLen; j += 2) {
3672
+ const absX = seg[j] + (isRelative ? ox : 0);
3673
+ const absY = seg[j + 1] + (isRelative ? oy : 0);
3674
+ lx = a * absX + c * absY + e - originX + originX;
3675
+ ly = b * absX + d * absY + f - originY + originY;
3676
+ piece.push(lx, ly);
3677
+ }
3678
+ result.push(piece);
3679
+ ox = seg[segLen - 2] + (isRelative ? ox : 0);
3680
+ oy = seg[segLen - 1] + (isRelative ? oy : 0);
3681
+ if (absCommand === "M") {
3682
+ omx = ox;
3683
+ omy = oy;
3684
+ }
3685
+ x = lx;
3686
+ y = ly;
3687
+ }
3688
+ }
3689
+ return result;
3690
+ };
3691
+ /**
3438
3692
  * Apply a 2D / 3D transformation to a PathArray.
3439
3693
  *
3440
3694
  * Since SVGElement doesn't support 3D transformation, this function
@@ -3451,12 +3705,6 @@ const projection2d = (m, point2D, origin) => {
3451
3705
  * ```
3452
3706
  */
3453
3707
  const transformPath = (pathInput, transform) => {
3454
- let x = 0;
3455
- let y = 0;
3456
- let lx = 0;
3457
- let ly = 0;
3458
- let j = 0;
3459
- let jj = 0;
3460
3708
  const path = parsePathString(pathInput);
3461
3709
  const transformProps = transform && Object.keys(transform);
3462
3710
  if (!transform || transformProps && !transformProps.length) return path.slice(0);
@@ -3464,8 +3712,15 @@ const transformPath = (pathInput, transform) => {
3464
3712
  const origin = transform.origin;
3465
3713
  const matrixInstance = getSVGMatrix(transform);
3466
3714
  if (matrixInstance.isIdentity) return path.slice(0);
3715
+ if (matrixInstance.is2D) return transform2D(path, matrixInstance.a, matrixInstance.b, matrixInstance.c, matrixInstance.d, matrixInstance.e, matrixInstance.f, origin[0], origin[1]);
3716
+ let x = 0;
3717
+ let y = 0;
3718
+ let lx = 0;
3719
+ let ly = 0;
3720
+ let j = 0;
3721
+ let jj = 0;
3467
3722
  return iterate(path, (seg, index, lastX, lastY) => {
3468
- let [pathCommand] = seg;
3723
+ const [pathCommand] = seg;
3469
3724
  const absCommand = pathCommand.toUpperCase();
3470
3725
  const absoluteSegment = absCommand !== pathCommand ? absolutizeSegment(seg, index, lastX, lastY) : seg.slice(0);
3471
3726
  let result = absCommand === "A" ? ["C"].concat(arcToCubic(lastX, lastY, absoluteSegment[1], absoluteSegment[2], absoluteSegment[3], absoluteSegment[4], absoluteSegment[5], absoluteSegment[6], absoluteSegment[7])) : absCommand === "V" ? [
@@ -3477,14 +3732,12 @@ const transformPath = (pathInput, transform) => {
3477
3732
  absoluteSegment[1],
3478
3733
  lastY
3479
3734
  ] : absoluteSegment;
3480
- pathCommand = result[0];
3481
- const isLongArc = pathCommand === "C" && result.length > 7;
3482
- const tempSegment = isLongArc ? result.slice(0, 7) : result.slice(0);
3483
- if (isLongArc) {
3735
+ if (result[0] === "C" && result.length > 7) {
3736
+ const tempSegment = result.slice(0, 7);
3484
3737
  path.splice(index + 1, 0, ["C"].concat(result.slice(7)));
3485
3738
  result = tempSegment;
3486
3739
  }
3487
- if (pathCommand === "L") {
3740
+ if (result[0] === "L") {
3488
3741
  [lx, ly] = projection2d(matrixInstance, [result[1], result[2]], origin);
3489
3742
  if (x !== lx && y !== ly) result = [
3490
3743
  "L",
@@ -4311,7 +4564,7 @@ const interHelper = (bez1, bez2, config) => {
4311
4564
  * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)
4312
4565
  * // => 1
4313
4566
  * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)
4314
- * // => [{ x: 50, y: 25, t1: 0.5, t2: 0.5 }]
4567
+ * // => [{ x: 80.4136, y: 19.5864, t1: 0.7262, t2: 0.2738 }]
4315
4568
  * ```
4316
4569
  */
4317
4570
  const pathsIntersection = (pathInput1, pathInput2, justCount = true) => {
@@ -4443,9 +4696,21 @@ var SVGPathCommander = class {
4443
4696
  this.origin = origin;
4444
4697
  return this;
4445
4698
  }
4699
+ /**
4700
+ * Returns the path bounding box, equivalent to native `path.getBBox()`.
4701
+ *
4702
+ * @public
4703
+ * @returns the pathBBox
4704
+ */
4446
4705
  get bbox() {
4447
4706
  return getPathBBox(this.segments);
4448
4707
  }
4708
+ /**
4709
+ * Returns the total path length, equivalent to native `path.getTotalLength()`.
4710
+ *
4711
+ * @public
4712
+ * @returns the path total length
4713
+ */
4449
4714
  get length() {
4450
4715
  return getTotalLength(this.segments);
4451
4716
  }
@@ -4536,7 +4801,7 @@ var SVGPathCommander = class {
4536
4801
  * @example
4537
4802
  * ```ts
4538
4803
  * new SVGPathCommander('M0 0L100 0L100 100L0 100Z').reverse().toString()
4539
- * // => 'M0 100L0 0L100 0L100 100Z'
4804
+ * // => 'M0 100L100 100L100 0L0 0Z'
4540
4805
  * ```
4541
4806
  *
4542
4807
  * @param onlySubpath - option to reverse all sub-paths except first
@@ -4585,7 +4850,7 @@ var SVGPathCommander = class {
4585
4850
  * @example
4586
4851
  * ```ts
4587
4852
  * new SVGPathCommander('M10 10L10 10L90 90').optimize().toString()
4588
- * // => 'M10 10l0 0 80 80'
4853
+ * // => 'M10 10v0l80 80'
4589
4854
  * ```
4590
4855
  *
4591
4856
  * @returns this for chaining
@@ -4709,96 +4974,184 @@ var SVGPathCommander = class {
4709
4974
  dispose() {
4710
4975
  Object.keys(this).forEach((key) => delete this[key]);
4711
4976
  }
4977
+ /** The default instance options. */
4712
4978
  static options = defaultOptions;
4979
+ /**
4980
+ * The DOMMatrix shim used for transformations.
4981
+ * @see https://github.com/thednp/dommatrix
4982
+ */
4713
4983
  static CSSMatrix = CSSMatrix;
4984
+ /** The tools for elliptical arc computation. */
4714
4985
  static arcTools = arcTools;
4986
+ /** The tools for Bezier curve computation. */
4715
4987
  static bezierTools = bezierTools;
4988
+ /** The tools for cubic Bezier computation. */
4716
4989
  static cubicTools = cubicTools;
4990
+ /** The tools for line segment computation. */
4717
4991
  static lineTools = lineTools;
4992
+ /** The tools for polygon computation. */
4718
4993
  static polygonTools = polygonTools;
4994
+ /** The tools for quadratic Bezier computation. */
4719
4995
  static quadTools = quadTools;
4996
+ /** Parses a path string value or object and returns an array */
4720
4997
  static pathToAbsolute = pathToAbsolute;
4998
+ /** Parses a path string value or object and returns an array */
4721
4999
  static pathToRelative = pathToRelative;
5000
+ /** Parses a path string or PathArray and returns a new one */
4722
5001
  static pathToCurve = pathToCurve;
5002
+ /** Returns a valid `d` attribute string value created */
4723
5003
  static pathToString = pathToString;
5004
+ /** Returns the square root of the distance */
4724
5005
  static distanceSquareRoot = distanceSquareRoot;
5006
+ /** Returns the coordinates of a specified distance */
4725
5007
  static midPoint = midPoint;
5008
+ /** Returns an {x,y} vector rotated by a given */
4726
5009
  static rotateVector = rotateVector;
5010
+ /** Rounds a number to the specified number of decimal places. */
4727
5011
  static roundTo = roundTo;
5012
+ /** Parses a path string value and returns an array */
4728
5013
  static parsePathString = parsePathString;
5014
+ /** Breaks the parsing of a pathString once a segment is finalized. */
4729
5015
  static finalizeSegment = finalizeSegment;
5016
+ /** Error message prefix used when a path string cannot be parsed. */
4730
5017
  static invalidPathValue = invalidPathValue;
5018
+ /** Checks if the character is an A (arc-to) path command. */
4731
5019
  static isArcCommand = isArcCommand;
5020
+ /** Checks if a character is a digit. */
4732
5021
  static isDigit = isDigit;
5022
+ /** Checks if the character is or belongs to a number. */
4733
5023
  static isDigitStart = isDigitStart;
5024
+ /** Checks if the character is a MoveTo command. */
4734
5025
  static isMoveCommand = isMoveCommand;
5026
+ /** Checks if the character is a path command. */
4735
5027
  static isPathCommand = isPathCommand;
5028
+ /** Checks if the character is a space. */
4736
5029
  static isSpace = isSpace;
5030
+ /** The number of parameters for each path command. */
4737
5031
  static paramsCount = paramsCounts;
5032
+ /** Default parser parameters object used to track position state */
4738
5033
  static paramsParser = paramsParser;
5034
+ /** The `PathParser` is used by the `parsePathString` static method */
4739
5035
  static PathParser = PathParser;
5036
+ /** Validates an A (arc-to) specific path command value. */
4740
5037
  static scanFlag = scanFlag;
5038
+ /** Validates every character of the path string, */
4741
5039
  static scanParam = scanParam;
5040
+ /** Scans every character in the path string to determine */
4742
5041
  static scanSegment = scanSegment;
5042
+ /** Points the parser to the next character in the */
4743
5043
  static skipSpaces = skipSpaces;
5044
+ /** Small threshold value used for floating-point distance comparisons in path calculations. */
4744
5045
  static distanceEpsilon = DISTANCE_EPSILON;
5046
+ /** Checks a `PathArray` for an unnecessary `Z` segment */
4745
5047
  static fixPath = fixPath;
5048
+ /** Returns the point in path closest to a given point. */
4746
5049
  static getClosestPoint = getClosestPoint;
5050
+ /** Check if a path is drawn clockwise and returns true if so, */
4747
5051
  static getDrawDirection = getDrawDirection;
5052
+ /** Returns the area of a single cubic-bezier segment. */
4748
5053
  static getPathArea = getPathArea;
5054
+ /** Calculates the bounding box of a path. */
4749
5055
  static getPathBBox = getPathBBox;
5056
+ /** Returns [x,y] coordinates of a point at a given length along a path. */
4750
5057
  static getPointAtLength = getPointAtLength;
5058
+ /** Returns the segment, its index and length as well as */
4751
5059
  static getPropertiesAtLength = getPropertiesAtLength;
5060
+ /** Returns the point and segment in path closest to a given point as well as */
4752
5061
  static getPropertiesAtPoint = getPropertiesAtPoint;
5062
+ /** Returns the segment at a given length. */
4753
5063
  static getSegmentAtLength = getSegmentAtLength;
5064
+ /** Returns the path segment which contains a given point. */
4754
5065
  static getSegmentOfPoint = getSegmentOfPoint;
5066
+ /** Returns the total length of a path, equivalent to `shape.getTotalLength()`. */
4755
5067
  static getTotalLength = getTotalLength;
5068
+ /** Iterates an array to check if it's a `pathArray` */
4756
5069
  static isAbsoluteArray = isAbsoluteArray;
5070
+ /** Iterates an array to check if it's a `pathArray` */
4757
5071
  static isCurveArray = isCurveArray;
5072
+ /** Checks if a path is a polygon (only M, L, H, V, Z commands). */
4758
5073
  static isPolygonArray = isPolygonArray;
5074
+ /** Iterates an array to check if it's a `pathArray` */
4759
5075
  static isNormalizedArray = isNormalizedArray;
5076
+ /** Iterates an array to check if it's an actual `pathArray`. */
4760
5077
  static isPathArray = isPathArray;
5078
+ /** Checks if a given point is in the stroke of a path. */
4761
5079
  static isPointInStroke = isPointInStroke;
5080
+ /** Iterates an array to check if it's a `pathArray` */
4762
5081
  static isRelativeArray = isRelativeArray;
5082
+ /** Parses a path string value to determine its validity */
4763
5083
  static isValidPath = isValidPath;
5084
+ /** Samples points from a path to form a polygon approximation. */
4764
5085
  static samplePolygon = samplePolygon;
5086
+ /** Supported shapes and their specific parameters. */
4765
5087
  static shapeParams = shapeParams;
5088
+ /** Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`, */
4766
5089
  static shapeToPath = shapeToPath;
5090
+ /** Returns a new PathArray from line attributes. */
4767
5091
  static shapeToPathArray = shapeToPathArray;
5092
+ /** Returns an absolute segment of a `PathArray` object. */
4768
5093
  static absolutizeSegment = absolutizeSegment;
5094
+ /** Converts A (arc-to) segments to C (cubic-bezier-to). */
4769
5095
  static arcToCubic = arcToCubic;
5096
+ /** Returns a transformation matrix to apply to `<path>` elements. */
4770
5097
  static getSVGMatrix = getSVGMatrix;
5098
+ /** Iterates over a `PathArray`, executing a callback for each segment. */
4771
5099
  static iterate = iterate;
5100
+ /** Converts an L (line-to) segment to C (cubic-bezier). */
4772
5101
  static lineToCubic = lineToCubic;
5102
+ /** Parses a path string or PathArray, then iterates the result for: */
4773
5103
  static normalizePath = normalizePath;
5104
+ /** Normalizes a single segment of a `pathArray` object. */
4774
5105
  static normalizeSegment = normalizeSegment;
5106
+ /** Optimizes a PathArray: */
4775
5107
  static optimizePath = optimizePath;
5108
+ /** Transforms a specified point using a matrix, returning a new */
4776
5109
  static projection2d = projection2d;
5110
+ /** Converts a Q (quadratic-bezier) segment to C (cubic-bezier). */
4777
5111
  static quadToCubic = quadToCubic;
5112
+ /** Returns a relative segment of a `PathArray` object. */
4778
5113
  static relativizeSegment = relativizeSegment;
5114
+ /** Reverses all segments of a `pathArray` */
4779
5115
  static reverseCurve = reverseCurve;
5116
+ /** Reverses all segments of a PathArray and returns a new PathArray */
4780
5117
  static reversePath = reversePath;
5118
+ /** Rounds the values of a `pathArray` instance to */
4781
5119
  static roundPath = roundPath;
5120
+ /** Rounds the numeric values of a path segment to the specified precision. */
4782
5121
  static roundSegment = roundSegment;
5122
+ /** Converts any segment to C (cubic-bezier). */
4783
5123
  static segmentToCubic = segmentToCubic;
5124
+ /** Shorten a single segment of a `pathArray` object. */
4784
5125
  static shortenSegment = shortenSegment;
5126
+ /** Split a path string or PathArray into an array of sub-paths. */
4785
5127
  static splitPath = splitPath;
5128
+ /** Equalizes two paths for morphing (single/multi subpath). */
4786
5129
  static equalizePaths = equalizePaths;
5130
+ /** Equalizes two paths for morphing (single subpath only). */
4787
5131
  static equalizeSegments = equalizeSegments;
5132
+ /** Split a cubic Bézier into two cubics at parameter t [0–1]. */
4788
5133
  static splitCubicSegment = splitCubicSegment;
5134
+ /** Apply a 2D / 3D transformation to a PathArray. */
4789
5135
  static transformPath = transformPath;
5136
+ /** Checks if a point is inside a bounding box. */
4790
5137
  static isPointInsideBBox = isPointInsideBBox;
5138
+ /** Finds intersection points between two paths. */
4791
5139
  static pathsIntersection = pathsIntersection;
5140
+ /** Checks if two bounding boxes intersect. */
4792
5141
  static boundingBoxIntersect = boundingBoxIntersect;
5142
+ /** Determines if an SVG path contains multiple subpaths. */
4793
5143
  static isMultiPath = isMultiPath;
5144
+ /** Check if a PathArray is closed, which means its last segment is a Z. */
4794
5145
  static isClosedPath = isClosedPath;
5146
+ /** Checks if a path is a polyline (only M, L, H, V commands). */
4795
5147
  static isPolylineArray = isPolylineArray;
5148
+ /** The library version. */
4796
5149
  static version = version;
4797
5150
  };
4798
5151
  //#endregion
4799
5152
  //#region src/index.ts
4800
5153
  var src_default = SVGPathCommander;
4801
5154
  //#endregion
4802
- export { src_default as default };
5155
+ export { SVGPathCommander, src_default as default };
4803
5156
 
4804
5157
  //# sourceMappingURL=index.js.map