svg-path-commander 2.2.1 → 2.2.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/dist/util.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /*!
2
- * SVGPathCommander v2.2.1 (http://thednp.github.io/svg-path-commander)
2
+ * SVGPathCommander v2.2.2 (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
+ import CSSMatrix from "@thednp/dommatrix";
6
7
  //#region src/interface.d.ts
7
8
  type SegmentProperties = {
8
9
  segment: PathSegment;
@@ -200,85 +201,435 @@ interface EqualizationOptions {
200
201
  }
201
202
  //#endregion
202
203
  //#region src/math/arcTools.d.ts
203
- declare const arcTools: {
204
- angleBetween: (v0: Point, v1: Point) => number;
205
- arcLength: (rx: number, ry: number, theta: number) => number;
206
- arcPoint: (cx: number, cy: number, rx: number, ry: number, alpha: number, theta: number) => PointTuple;
207
- getArcBBox: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => [number, number, number, number];
208
- getArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => number;
209
- getArcProps: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => {
210
- rx: number;
211
- ry: number;
212
- startAngle: number;
213
- endAngle: number;
214
- center: {
215
- x: number;
216
- y: number;
217
- };
218
- };
219
- getPointAtArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number, distance?: number) => {
204
+ /**
205
+ * Returns the signed arc length of an ellipse segment from angle `0` up to
206
+ * the given `theta` angle, by integrating the curve speed
207
+ * `|sqrt(rx^2 * sin^2(phi) + ry^2 * cos^2(phi))|` over the `[0, theta]`
208
+ * interval with Gauss-Legendre quadrature.
209
+ *
210
+ * @param rx radius along X axis
211
+ * @param ry radius along Y axis
212
+ * @param theta the angle in radians
213
+ * @returns the signed arc length
214
+ */
215
+ declare const arcLengthAtAngle: (rx: number, ry: number, theta: number) => number;
216
+ /**
217
+ * Returns the signed arc length of an ellipse segment between two angles.
218
+ * @param rx radius along X axis
219
+ * @param ry radius along Y axis
220
+ * @param from the start angle in radians
221
+ * @param to the end angle in radians
222
+ * @returns the signed arc length
223
+ */
224
+ declare const arcLengthBetween: (rx: number, ry: number, from: number, to: number) => number;
225
+ /**
226
+ * Returns the Arc segment length.
227
+ * @param rx radius along X axis
228
+ * @param ry radius along Y axis
229
+ * @param theta the angle in radians
230
+ * @returns the arc length
231
+ */
232
+ declare const arcLength: (rx: number, ry: number, theta: number) => number;
233
+ /**
234
+ * Find point on ellipse at given angle around ellipse (theta);
235
+ * @param cx the center X
236
+ * @param cy the center Y
237
+ * @param rx the radius X
238
+ * @param ry the radius Y
239
+ * @param alpha the arc rotation angle in radians
240
+ * @param theta the arc sweep angle in radians
241
+ * @returns a point around ellipse at given angle
242
+ */
243
+ declare const arcPoint: (cx: number, cy: number, rx: number, ry: number, alpha: number, theta: number) => PointTuple;
244
+ /**
245
+ * Returns the angle between two points.
246
+ * @param v0 starting point
247
+ * @param v1 ending point
248
+ * @returns the angle in radian
249
+ */
250
+ declare const angleBetween: (v0: Point, v1: Point) => number;
251
+ /**
252
+ * Returns the following properties for an Arc segment: center, start angle,
253
+ * end angle, and radiuses on X and Y axis.
254
+ *
255
+ * @param x1 the starting point X
256
+ * @param y1 the starting point Y
257
+ * @param RX the radius on X axis
258
+ * @param RY the radius on Y axis
259
+ * @param angle the ellipse rotation in degrees
260
+ * @param LAF the large arc flag
261
+ * @param SF the sweep flag
262
+ * @param x2 the ending point X
263
+ * @param y2 the ending point Y
264
+ * @returns properties specific to Arc segments
265
+ */
266
+ declare const getArcProps: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => {
267
+ rx: number;
268
+ ry: number;
269
+ startAngle: number;
270
+ endAngle: number;
271
+ center: {
220
272
  x: number;
221
273
  y: number;
222
274
  };
223
275
  };
276
+ /**
277
+ * Returns the length of an Arc segment.
278
+ *
279
+ * @param x1 the starting point X
280
+ * @param y1 the starting point Y
281
+ * @param c1x the first control point X
282
+ * @param c1y the first control point Y
283
+ * @param c2x the second control point X
284
+ * @param c2y the second control point Y
285
+ * @param x2 the ending point X
286
+ * @param y2 the ending point Y
287
+ * @returns the length of the Arc segment
288
+ */
289
+ declare const getArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => number;
290
+ /**
291
+ * Returns a point along an Arc segment at a given distance.
292
+ *
293
+ * @param x1 the starting point X
294
+ * @param y1 the starting point Y
295
+ * @param RX the radius on X axis
296
+ * @param RY the radius on Y axis
297
+ * @param angle the ellipse rotation in degrees
298
+ * @param LAF the large arc flag
299
+ * @param SF the sweep flag
300
+ * @param x2 the ending point X
301
+ * @param y2 the ending point Y
302
+ * @param distance the distance along the arc
303
+ * @returns a point along the Arc segment
304
+ */
305
+ declare const getPointAtArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number, distance?: number) => {
306
+ x: number;
307
+ y: number;
308
+ };
309
+ /**
310
+ * Returns the extrema for an Arc segment in the following format:
311
+ * [MIN_X, MIN_Y, MAX_X, MAX_Y]
312
+ *
313
+ * @see https://github.com/herrstrietzel/svg-pathdata-getbbox
314
+ *
315
+ * @param x1 the starting point X
316
+ * @param y1 the starting point Y
317
+ * @param RX the radius on X axis
318
+ * @param RY the radius on Y axis
319
+ * @param angle the ellipse rotation in degrees
320
+ * @param LAF the large arc flag
321
+ * @param SF the sweep flag
322
+ * @param x2 the ending point X
323
+ * @param y2 the ending point Y
324
+ * @returns the extrema of the Arc segment
325
+ */
326
+ declare const getArcBBox: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => [number, number, number, number];
327
+ declare const arcTools: {
328
+ angleBetween: typeof angleBetween;
329
+ arcLength: typeof arcLength;
330
+ arcLengthAtAngle: typeof arcLengthAtAngle;
331
+ arcLengthBetween: typeof arcLengthBetween;
332
+ arcPoint: typeof arcPoint;
333
+ getArcBBox: typeof getArcBBox;
334
+ getArcLength: typeof getArcLength;
335
+ getArcProps: typeof getArcProps;
336
+ getPointAtArcLength: typeof getPointAtArcLength;
337
+ };
224
338
  //#endregion
225
339
  //#region src/math/bezier.d.ts
340
+ /**
341
+ * @param points
342
+ * @returns
343
+ */
344
+ declare const deriveBezier: (points: QuadPoints | CubicPoints) => (DerivedQuadPoints | DerivedCubicPoints)[];
345
+ /**
346
+ * @param points
347
+ * @param t
348
+ */
349
+ declare const computeBezier: (points: DerivedQuadPoints | DerivedCubicPoints, t: number) => DerivedPoint;
350
+ declare const calculateBezier: (derivativeFn: DeriveCallback, t: number) => number;
351
+ declare const bezierLength: (derivativeFn: DeriveCallback) => number;
352
+ /**
353
+ * Returns the arc length of a Bezier segment from its start point
354
+ * up to a given `t` ratio, by integrating the curve speed `|B'(t)|`
355
+ * over the `[0, t]` interval with Gauss-Legendre quadrature.
356
+ *
357
+ * @param derivativeFn the curve derivative function
358
+ * @param t the sampled point ratio in `[0-1]`
359
+ * @returns the arc length up to parameter `t`
360
+ */
361
+ declare const bezierLengthAtT: (derivativeFn: DeriveCallback, t: number) => number;
362
+ /**
363
+ * Builds the Bezier points array from a curve coordinates array.
364
+ * @param curve cubic / quad bezier segment
365
+ */
366
+ declare const getBezierPoints: (curve: CubicCoordinates | QuadCoordinates) => CubicPoints | QuadPoints;
367
+ /**
368
+ * Returns the arc length of a Bezier segment from its start point
369
+ * up to a given `t` ratio, for the segment given by its coordinates.
370
+ *
371
+ * @param curve cubic / quad bezier segment
372
+ * @param t the sampled point ratio in `[0-1]`
373
+ * @returns the arc length up to parameter `t`
374
+ */
375
+ declare const getBezierLengthAtT: (curve: CubicCoordinates | QuadCoordinates, t: number) => number;
376
+ /**
377
+ * Returns the `t` parameter of a Bezier segment at which the cumulative
378
+ * arc length equals the given `distance`, found by interval bisection.
379
+ *
380
+ * @param curve cubic / quad bezier segment
381
+ * @param distance the distance along the segment in `[0, length]`
382
+ * @returns the `t` parameter in `[0-1]`
383
+ */
384
+ declare const getTAtBezierLength: (curve: CubicCoordinates | QuadCoordinates, distance: number) => number;
385
+ /**
386
+ * Returns the length of CubicBezier / Quad segment.
387
+ * @param curve cubic / quad bezier segment
388
+ */
389
+ declare const getBezierLength: (curve: CubicCoordinates | QuadCoordinates) => number;
390
+ /**
391
+ * Returns the most extreme points in a Quad Bezier segment.
392
+ * @param A an array which consist of X/Y values
393
+ */
394
+ declare const minmaxQ: ([v1, cp, v2]: [number, number, number]) => PointTuple;
395
+ /**
396
+ * Returns the most extreme points in a Cubic Bezier segment.
397
+ * @param A an array which consist of X/Y values
398
+ * @see https://github.com/kpym/SVGPathy/blob/acd1a50c626b36d81969f6e98e8602e128ba4302/lib/box.js#L127
399
+ */
400
+ declare const minmaxC: ([v1, cp1, cp2, v2]: [number, number, number, number]) => PointTuple;
226
401
  declare const bezierTools: {
227
- bezierLength: (derivativeFn: DeriveCallback) => number;
228
- calculateBezier: (derivativeFn: DeriveCallback, t: number) => number;
402
+ bezierLength: typeof bezierLength;
403
+ bezierLengthAtT: typeof bezierLengthAtT;
404
+ calculateBezier: typeof calculateBezier;
229
405
  CBEZIER_MINMAX_EPSILON: number;
230
- computeBezier: (points: DerivedQuadPoints | DerivedCubicPoints, t: number) => DerivedPoint;
406
+ computeBezier: typeof computeBezier;
231
407
  Cvalues: number[];
232
- deriveBezier: (points: QuadPoints | CubicPoints) => (DerivedCubicPoints | DerivedQuadPoints)[];
233
- getBezierLength: (curve: CubicCoordinates | QuadCoordinates) => number;
234
- minmaxC: ([v1, cp1, cp2, v2]: [number, number, number, number]) => PointTuple;
235
- minmaxQ: ([v1, cp, v2]: [number, number, number]) => PointTuple;
408
+ deriveBezier: typeof deriveBezier;
409
+ getBezierLength: typeof getBezierLength;
410
+ getBezierLengthAtT: typeof getBezierLengthAtT;
411
+ getBezierPoints: typeof getBezierPoints;
412
+ getTAtBezierLength: typeof getTAtBezierLength;
413
+ minmaxC: typeof minmaxC;
414
+ minmaxQ: typeof minmaxQ;
236
415
  Tvalues: number[];
237
416
  };
238
417
  //#endregion
239
418
  //#region src/math/cubicTools.d.ts
419
+ /**
420
+ * Returns a point at a given length of a CubicBezier segment.
421
+ *
422
+ * @param x1 the starting point X
423
+ * @param y1 the starting point Y
424
+ * @param c1x the first control point X
425
+ * @param c1y the first control point Y
426
+ * @param c2x the second control point X
427
+ * @param c2y the second control point Y
428
+ * @param x2 the ending point X
429
+ * @param y2 the ending point Y
430
+ * @param t a [0-1] ratio
431
+ * @returns the point at cubic-bezier segment length
432
+ */
433
+ declare const getPointAtCubicSegmentLength: ([x1, y1, c1x, c1y, c2x, c2y, x2, y2]: CubicCoordinates, t: number) => {
434
+ x: number;
435
+ y: number;
436
+ };
437
+ /**
438
+ * Returns the length of a CubicBezier segment.
439
+ *
440
+ * @param x1 the starting point X
441
+ * @param y1 the starting point Y
442
+ * @param c1x the first control point X
443
+ * @param c1y the first control point Y
444
+ * @param c2x the second control point X
445
+ * @param c2y the second control point Y
446
+ * @param x2 the ending point X
447
+ * @param y2 the ending point Y
448
+ * @returns the CubicBezier segment length
449
+ */
450
+ declare const getCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => number;
451
+ /**
452
+ * Returns the point along a CubicBezier segment at a given distance.
453
+ *
454
+ * @param x1 the starting point X
455
+ * @param y1 the starting point Y
456
+ * @param c1x the first control point X
457
+ * @param c1y the first control point Y
458
+ * @param c2x the second control point X
459
+ * @param c2y the second control point Y
460
+ * @param x2 the ending point X
461
+ * @param y2 the ending point Y
462
+ * @param distance the distance to look at
463
+ * @returns the point at CubicBezier length
464
+ */
465
+ declare const getPointAtCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number, distance?: number) => {
466
+ x: number;
467
+ y: number;
468
+ };
469
+ /**
470
+ * Returns the bounding box of a CubicBezier segment in the following format:
471
+ * [MIN_X, MIN_Y, MAX_X, MAX_Y]
472
+ *
473
+ * @param x1 the starting point X
474
+ * @param y1 the starting point Y
475
+ * @param c1x the first control point X
476
+ * @param c1y the first control point Y
477
+ * @param c2x the second control point X
478
+ * @param c2y the second control point Y
479
+ * @param x2 the ending point X
480
+ * @param y2 the ending point Y
481
+ * @returns the extrema of the CubicBezier segment
482
+ */
483
+ declare const getCubicBBox: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => BBoxMaxima;
240
484
  declare const cubicTools: {
241
- getCubicBBox: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => BBoxMaxima;
242
- getCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => number;
243
- getPointAtCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number, distance?: number) => {
244
- x: number;
245
- y: number;
246
- };
247
- getPointAtCubicSegmentLength: ([x1, y1, c1x, c1y, c2x, c2y, x2, y2]: CubicCoordinates, t: number) => {
248
- x: number;
249
- y: number;
250
- };
485
+ getCubicBBox: typeof getCubicBBox;
486
+ getCubicLength: typeof getCubicLength;
487
+ getPointAtCubicLength: typeof getPointAtCubicLength;
488
+ getPointAtCubicSegmentLength: typeof getPointAtCubicSegmentLength;
251
489
  };
252
490
  //#endregion
253
491
  //#region src/math/lineTools.d.ts
492
+ /**
493
+ * Returns length for line segments (MoveTo, LineTo).
494
+ *
495
+ * @param x1 the starting point X
496
+ * @param y1 the starting point Y
497
+ * @param x2 the ending point X
498
+ * @param y2 the ending point Y
499
+ * @returns the line segment length
500
+ */
501
+ declare const getLineLength: (x1: number, y1: number, x2: number, y2: number) => number;
502
+ /**
503
+ * Returns a point along the line segments (MoveTo, LineTo).
504
+ *
505
+ * @param x1 the starting point X
506
+ * @param y1 the starting point Y
507
+ * @param x2 the ending point X
508
+ * @param y2 the ending point Y
509
+ * @param distance the distance to point in [0-1] range
510
+ * @returns the point at length
511
+ */
512
+ declare const getPointAtLineLength: (x1: number, y1: number, x2: number, y2: number, distance?: number) => {
513
+ x: number;
514
+ y: number;
515
+ };
516
+ /**
517
+ * Returns bounding box for line segments (MoveTo, LineTo).
518
+ *
519
+ * @param x1 the starting point X
520
+ * @param y1 the starting point Y
521
+ * @param x2 the ending point X
522
+ * @param y2 the ending point Y
523
+ * @returns the bounding box for line segments
524
+ */
525
+ declare const getLineBBox: (x1: number, y1: number, x2: number, y2: number) => [number, number, number, number];
254
526
  declare const lineTools: {
255
- getLineBBox: (x1: number, y1: number, x2: number, y2: number) => [number, number, number, number];
256
- getLineLength: (x1: number, y1: number, x2: number, y2: number) => number;
257
- getPointAtLineLength: (x1: number, y1: number, x2: number, y2: number, distance?: number) => {
258
- x: number;
259
- y: number;
260
- };
527
+ getLineBBox: typeof getLineBBox;
528
+ getLineLength: typeof getLineLength;
529
+ getPointAtLineLength: typeof getPointAtLineLength;
261
530
  };
262
531
  //#endregion
263
532
  //#region src/math/quadTools.d.ts
533
+ /**
534
+ * Returns the {x,y} coordinates of a point at a
535
+ * given length of a quadratic-bezier segment.
536
+ *
537
+ * @see https://github.com/substack/point-at-length
538
+ *
539
+ * @param x1 the starting point X
540
+ * @param y1 the starting point Y
541
+ * @param cx the control point X
542
+ * @param cy the control point Y
543
+ * @param x2 the ending point X
544
+ * @param y2 the ending point Y
545
+ * @param t a [0-1] ratio
546
+ * @returns the requested {x,y} coordinates
547
+ */
548
+ declare const getPointAtQuadSegmentLength: ([x1, y1, cx, cy, x2, y2]: QuadCoordinates, t: number) => {
549
+ x: number;
550
+ y: number;
551
+ };
552
+ /**
553
+ * Returns the length of a QuadraticBezier segment.
554
+ *
555
+ * @param x1 the starting point X
556
+ * @param y1 the starting point Y
557
+ * @param cx the control point X
558
+ * @param cy the control point Y
559
+ * @param x2 the ending point X
560
+ * @param y2 the ending point Y
561
+ * @returns the QuadraticBezier segment length
562
+ */
563
+ declare const getQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => number;
564
+ /**
565
+ * Returns the point along a QuadraticBezier segment at a given distance.
566
+ *
567
+ * @param x1 the starting point X
568
+ * @param y1 the starting point Y
569
+ * @param cx the control point X
570
+ * @param cy the control point Y
571
+ * @param x2 the ending point X
572
+ * @param y2 the ending point Y
573
+ * @param distance the distance to look at
574
+ * @returns the point at QuadraticBezier length
575
+ */
576
+ declare const getPointAtQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number, distance?: number) => {
577
+ x: number;
578
+ y: number;
579
+ };
580
+ /**
581
+ * Returns the bounding box of a QuadraticBezier segment in the following format:
582
+ * [MIN_X, MIN_Y, MAX_X, MAX_Y]
583
+ *
584
+ * @param x1 the starting point X
585
+ * @param y1 the starting point Y
586
+ * @param cx the control point X
587
+ * @param cy the control point Y
588
+ * @param x2 the ending point X
589
+ * @param y2 the ending point Y
590
+ * @returns the extrema of the QuadraticBezier segment
591
+ */
592
+ declare const getQuadBBox: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => [number, number, number, number];
264
593
  declare const quadTools: {
265
- getPointAtQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number, distance?: number) => {
266
- x: number;
267
- y: number;
268
- };
269
- getPointAtQuadSegmentLength: ([x1, y1, cx, cy, x2, y2]: QuadCoordinates, t: number) => {
270
- x: number;
271
- y: number;
272
- };
273
- getQuadBBox: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => [number, number, number, number];
274
- getQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => number;
594
+ getPointAtQuadLength: typeof getPointAtQuadLength;
595
+ getPointAtQuadSegmentLength: typeof getPointAtQuadSegmentLength;
596
+ getQuadBBox: typeof getQuadBBox;
597
+ getQuadLength: typeof getQuadLength;
275
598
  };
276
599
  //#endregion
277
600
  //#region src/math/polygonTools.d.ts
601
+ /**
602
+ * d3-polygon-area
603
+ * @see https://github.com/d3/d3-polygon
604
+ *
605
+ * Returns the area of a polygon.
606
+ *
607
+ * @param polygon Array of [x, y]
608
+ * @returns Signed area
609
+ */
610
+ declare const polygonArea: (polygon: PointTuple[]) => number;
611
+ /**
612
+ * d3-polygon-length
613
+ * https://github.com/d3/d3-polygon
614
+ *
615
+ * Returns the perimeter of a polygon.
616
+ *
617
+ * @param polygon an array of coordinates
618
+ * @returns the polygon length
619
+ */
620
+ declare const polygonLength: (polygon: PointTuple[]) => number;
621
+ /**
622
+ * Computes the centroid (geometric center) of a polygon.
623
+ * Uses average of all endpoint coordinates (robust for polygons and curves).
624
+ *
625
+ * @param polygon A polygon with consists of [x, y] tuples
626
+ * @returns [x, y] centroid
627
+ */
628
+ declare const polygonCentroid: (polygon: PointTuple[]) => PointTuple;
278
629
  declare const polygonTools: {
279
- polygonArea: (polygon: PointTuple[]) => number;
280
- polygonLength: (polygon: PointTuple[]) => number;
281
- polygonCentroid: (polygon: PointTuple[]) => PointTuple;
630
+ polygonArea: typeof polygonArea;
631
+ polygonLength: typeof polygonLength;
632
+ polygonCentroid: typeof polygonCentroid;
282
633
  };
283
634
  //#endregion
284
635
  //#region src/math/distanceSquareRoot.d.ts
@@ -401,7 +752,6 @@ declare const pathToString: <T extends PathArray>(path: T, roundOption?: number
401
752
  *
402
753
  * If parameter value is already a `PathArray`,
403
754
  * return a clone of it.
404
-
405
755
  * @example
406
756
  * parsePathString("M 0 0L50 50")
407
757
  * // => [["M",0,0],["L",50,50]]
@@ -644,7 +994,7 @@ declare const getDrawDirection: (path: string | PathArray) => boolean;
644
994
  * // => -10000 (counter-clockwise square)
645
995
  * ```
646
996
  */
647
- declare const getPathArea: <T extends PathArray>(path: T) => number;
997
+ declare const getPathArea: <T extends PathArray | string>(path: T) => number;
648
998
  //#endregion
649
999
  //#region src/util/getPointAtLength.d.ts
650
1000
  /**
@@ -884,7 +1234,7 @@ declare const shapeToPathArray: (element: ShapeTypes | ShapeOps) => false | Path
884
1234
  * // => [['M', 10, 90], ['C', 30, 90, 25, 10, 50, 10], ['C', 75, 10, 70, 90, 90, 90]]
885
1235
  * ```
886
1236
  */
887
- declare const normalizePath: (pathInput: string | PathArray) => NormalArray;
1237
+ declare const normalizePath: <T extends string | PathArray>(pathInput: T) => NormalArray;
888
1238
  //#endregion
889
1239
  //#region src/process/optimizePath.d.ts
890
1240
  /**
@@ -902,7 +1252,7 @@ declare const normalizePath: (pathInput: string | PathArray) => NormalArray;
902
1252
  * // => [['M', 10, 10], ['l', 0, 0], ['l', 80, 80]]
903
1253
  * ```
904
1254
  */
905
- declare const optimizePath: <T extends PathArray>(pathInput: T, roundOption?: number) => PathArray;
1255
+ declare const optimizePath: <T extends string | PathArray>(pathInput: T, roundOption?: number) => PathArray;
906
1256
  //#endregion
907
1257
  //#region src/process/reversePath.d.ts
908
1258
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","names":[],"sources":["../src/interface.ts","../src/types.ts","../src/math/arcTools.ts","../src/math/bezier.ts","../src/math/cubicTools.ts","../src/math/lineTools.ts","../src/math/quadTools.ts","../src/math/polygonTools.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/invalidPathValue.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/paramsCount.ts","../src/parser/paramsParser.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/distanceEpsilon.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/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isPolygonArray.ts","../src/util/isPolylineArray.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/util/isMultiPath.ts","../src/util/isClosedPath.ts","../src/util/shapeParams.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.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"],"mappings":";;;;;;;KAEY;EACV,SAAS;EACT;EACA;EACA;;KAKU;EACV;IACE;IACA;;EAEF;EACA,UAAU;;KAGA;EACV;EACA;EACA;EACA;EACA;GACC;;KAES;EACV;EACA;GACC;;KAES;EACV;EACA;EACA;EACA;GACC;;KAES;EACV;EACA;EACA;EACA;EACA;GACC;;KAES;EACV;EACA;EACA;EACA;EACA;EACA;EACA;GACC;;KAES;EACV;EACA;GACC;;KAGS;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAmBU;EACV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