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/dist/util.d.ts CHANGED
@@ -1,202 +1,369 @@
1
1
  /*!
2
- * SVGPathCommander v2.2.2 (http://thednp.github.io/svg-path-commander)
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 src/interface.d.ts
8
+ /** The properties of a path segment found by segment lookup utilities. */
8
9
  type SegmentProperties = {
10
+ /** The path segment. */
9
11
  segment: PathSegment;
12
+ /** The index of the segment in the path. */
10
13
  index: number;
14
+ /** The length of the segment. */
11
15
  length: number;
16
+ /** The distance from the start of the path to the end of the segment. */
12
17
  lengthAtSegment: number;
13
18
  };
19
+ /** The closest point on the path to a given point, with the distance and optional segment. */
14
20
  type PointProperties = {
21
+ /** The closest point on the path to the given point. */
15
22
  closest: {
23
+ /** The X coordinate of the closest point. */
16
24
  x: number;
25
+ /** The Y coordinate of the closest point. */
17
26
  y: number;
18
27
  };
28
+ /** The distance from the given point to the closest point on the path. */
19
29
  distance: number;
30
+ /** The segment which contains the closest point. */
20
31
  segment?: SegmentProperties;
21
32
  };
33
+ /** The attributes of a `<line>` element read by `shapeToPath`. */
22
34
  type LineAttr = {
35
+ /** The element type. */
23
36
  type: "line";
37
+ /** The X coordinate of the start point. */
24
38
  x1: number;
39
+ /** The Y coordinate of the start point. */
25
40
  y1: number;
41
+ /** The X coordinate of the end point. */
26
42
  x2: number;
43
+ /** The Y coordinate of the end point. */
27
44
  y2: number;
28
45
  [key: string]: string | number;
29
46
  };
47
+ /** The attributes of a `<polygon>` or `<polyline>` element read by `shapeToPath`. */
30
48
  type PolyAttr = {
49
+ /** The element type. */
31
50
  type: "polygon" | "polyline";
51
+ /** The points attribute value. */
32
52
  points: string;
33
53
  [key: string]: string | number;
34
54
  };
55
+ /** The attributes of a `<circle>` element read by `shapeToPath`. */
35
56
  type CircleAttr = {
57
+ /** The element type. */
36
58
  type: "circle";
59
+ /** The X coordinate of the center. */
37
60
  cx: number;
61
+ /** The Y coordinate of the center. */
38
62
  cy: number;
63
+ /** The circle radius. */
39
64
  r: number;
40
65
  [key: string]: string | number;
41
66
  };
67
+ /** The attributes of an `<ellipse>` element read by `shapeToPath`. */
42
68
  type EllipseAttr = {
69
+ /** The element type. */
43
70
  type: "ellipse";
71
+ /** The X coordinate of the center. */
44
72
  cx: number;
73
+ /** The Y coordinate of the center. */
45
74
  cy: number;
75
+ /** The X axis radius. */
46
76
  rx: number;
77
+ /** The Y axis radius. */
47
78
  ry?: number;
48
79
  [key: string]: string | number | undefined;
49
80
  };
81
+ /** The attributes of a `<rect>` element read by `shapeToPath`. */
50
82
  type RectAttr = {
83
+ /** The element type. */
51
84
  type: "rect";
85
+ /** The rectangle width. */
52
86
  width: number;
87
+ /** The rectangle height. */
53
88
  height: number;
89
+ /** The X coordinate of the top-left corner. */
54
90
  x: number;
91
+ /** The Y coordinate of the top-left corner. */
55
92
  y: number;
93
+ /** The X axis corner radius. */
56
94
  rx?: number;
95
+ /** The Y axis corner radius. */
57
96
  ry?: number;
58
97
  [key: string]: string | number | undefined;
59
98
  };
99
+ /** The attributes of a `<glyph>` element read by `shapeToPath`. */
60
100
  type GlyphAttr = {
101
+ /** The element type. */
61
102
  type: "glyph";
103
+ /** The path data of the glyph. */
62
104
  d: string;
63
105
  [key: string]: string | number;
64
106
  };
107
+ /** The parameter names read from each SVG shape element by `shapeToPath`. */
65
108
  type ShapeParams = {
109
+ /** The parameter names read from the `<line>` element. */
66
110
  line: ["x1", "y1", "x2", "y2"];
111
+ /** The parameter names read from the `<circle>` element. */
67
112
  circle: ["cx", "cy", "r"];
113
+ /** The parameter names read from the `<ellipse>` element. */
68
114
  ellipse: ["cx", "cy", "rx", "ry"];
115
+ /** The parameter names read from the `<rect>` element. */
69
116
  rect: ["width", "height", "x", "y", "rx", "ry"];
117
+ /** The parameter names read from the `<polygon>` element. */
70
118
  polygon: ["points"];
119
+ /** The parameter names read from the `<polyline>` element. */
71
120
  polyline: ["points"];
121
+ /** The parameter names read from the `<glyph>` element. */
72
122
  glyph: ["d"];
73
123
  };
124
+ /** The current state tracked by the SVG path string parser. */
74
125
  type ParserParams = {
126
+ /** The X coordinate of the previous moveto point. */
75
127
  mx: number;
128
+ /** The Y coordinate of the previous moveto point. */
76
129
  my: number;
130
+ /** The X coordinate of the previous control point. */
77
131
  x1: number;
132
+ /** The Y coordinate of the previous control point. */
78
133
  y1: number;
134
+ /** The X coordinate of the second control point. */
79
135
  x2: number;
136
+ /** The Y coordinate of the second control point. */
80
137
  y2: number;
138
+ /** The X coordinate of the current point. */
81
139
  x: number;
140
+ /** The Y coordinate of the current point. */
82
141
  y: number;
142
+ /** The X coordinate of the previous quadratic control point. */
83
143
  qx: number | null;
144
+ /** The Y coordinate of the previous quadratic control point. */
84
145
  qy: number | null;
85
146
  };
147
+ /** A transform function object with translate, rotate, scale, skew and origin. */
86
148
  type TransformObject = {
149
+ /** A translate value, a number for all axes or an array of values. */
87
150
  translate: number | number[];
151
+ /** A rotate value, a number for all axes or an array of values. */
88
152
  rotate: number | number[];
153
+ /** A scale value, a number for all axes or an array of values. */
89
154
  scale: number | number[];
155
+ /** A skew value, a number for all axes or an array of values. */
90
156
  skew: number | number[];
157
+ /** The transform origin. */
91
158
  origin: number[];
92
159
  };
93
160
  //#endregion
94
161
  //#region src/types.d.ts
162
+ /** Whitespace character codes recognized by the SVG path string tokenizer. */
95
163
  type SpaceNumber = 0x1680 | 0x180e | 0x2000 | 0x2001 | 0x2002 | 0x2003 | 0x2004 | 0x2005 | 0x2006 | 0x2007 | 0x2008 | 0x2009 | 0x200a | 0x202f | 0x205f | 0x3000 | 0xfeff | 0x0a | 0x0d | 0x2028 | 0x2029 | 0x20 | 0x09 | 0x0b | 0x0c | 0xa0 | 0x1680;
164
+ /** Character codes of all SVG path command letters. */
96
165
  type PathCommandNumber = 0x6d | 0x7a | 0x6c | 0x68 | 0x76 | 0x63 | 0x73 | 0x71 | 0x74 | 0x61;
166
+ /** Character codes of the decimal digits 0-9. */
97
167
  type DigitNumber = 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39;
168
+ /** The absolute moveto command letter. */
98
169
  type MCommand = "M";
170
+ /** The relative moveto command letter. */
99
171
  type mCommand = "m";
172
+ /** The absolute lineto command letter. */
100
173
  type LCommand = "L";
174
+ /** The relative lineto command letter. */
101
175
  type lCommand = "l";
176
+ /** The absolute vertical lineto command letter. */
102
177
  type VCommand = "V";
178
+ /** The relative vertical lineto command letter. */
103
179
  type vCommand = "v";
180
+ /** The absolute horizontal lineto command letter. */
104
181
  type HCommand = "H";
182
+ /** The relative horizontal lineto command letter. */
105
183
  type hCommand = "h";
184
+ /** The absolute closepath command letter. */
106
185
  type ZCommand = "Z";
186
+ /** The relative closepath command letter. */
107
187
  type zCommand = "z";
188
+ /** The absolute cubic Bezier command letter. */
108
189
  type CCommand = "C";
190
+ /** The relative cubic Bezier command letter. */
109
191
  type cCommand = "c";
192
+ /** The absolute smooth cubic Bezier command letter. */
110
193
  type SCommand = "S";
194
+ /** The relative smooth cubic Bezier command letter. */
111
195
  type sCommand = "s";
196
+ /** The absolute quadratic Bezier command letter. */
112
197
  type QCommand = "Q";
198
+ /** The relative quadratic Bezier command letter. */
113
199
  type qCommand = "q";
200
+ /** The absolute smooth quadratic Bezier command letter. */
114
201
  type TCommand = "T";
202
+ /** The relative smooth quadratic Bezier command letter. */
115
203
  type tCommand = "t";
204
+ /** The absolute elliptical arc command letter. */
116
205
  type ACommand = "A";
206
+ /** The relative elliptical arc command letter. */
117
207
  type aCommand = "a";
208
+ /** The union of all absolute path command letters. */
118
209
  type AbsoluteCommand = MCommand | LCommand | VCommand | HCommand | ZCommand | CCommand | SCommand | QCommand | TCommand | ACommand;
210
+ /** The union of all relative path command letters. */
119
211
  type RelativeCommand = mCommand | lCommand | vCommand | hCommand | zCommand | cCommand | sCommand | qCommand | tCommand | aCommand;
212
+ /** Any SVG path command letter, absolute or relative. */
120
213
  type PathCommand = AbsoluteCommand | RelativeCommand;
214
+ /** The absolute moveto segment tuple `[M, x, y]`. */
121
215
  type MSegment = [MCommand, number, number];
216
+ /** The relative moveto segment tuple `[m, dx, dy]`. */
122
217
  type mSegment = [mCommand, number, number];
218
+ /** The moveto segment, absolute or relative. */
123
219
  type MoveSegment = MSegment | mSegment;
220
+ /** The absolute lineto segment tuple `[L, x, y]`. */
124
221
  type LSegment = [LCommand, number, number];
222
+ /** The relative lineto segment tuple `[l, dx, dy]`. */
125
223
  type lSegment = [lCommand, number, number];
224
+ /** The lineto segment, absolute or relative. */
126
225
  type LineSegment = LSegment | lSegment;
226
+ /** The absolute vertical lineto segment tuple `[V, y]`. */
127
227
  type VSegment = [VCommand, number];
228
+ /** The relative vertical lineto segment tuple `[v, dy]`. */
128
229
  type vSegment = [vCommand, number];
230
+ /** The vertical lineto segment, absolute or relative. */
129
231
  type VertLineSegment = vSegment | VSegment;
232
+ /** The absolute horizontal lineto segment tuple `[H, x]`. */
130
233
  type HSegment = [HCommand, number];
234
+ /** The relative horizontal lineto segment tuple `[h, dx]`. */
131
235
  type hSegment = [hCommand, number];
236
+ /** The horizontal lineto segment, absolute or relative. */
132
237
  type HorLineSegment = HSegment | hSegment;
238
+ /** The absolute closepath segment tuple `[Z]`. */
133
239
  type ZSegment = [ZCommand];
240
+ /** The relative closepath segment tuple `[z]`. */
134
241
  type zSegment = [zCommand];
242
+ /** The closepath segment, absolute or relative. */
135
243
  type CloseSegment = ZSegment | zSegment;
244
+ /** The absolute cubic Bezier segment tuple `[C, x1, y1, x2, y2, x, y]`. */
136
245
  type CSegment = [CCommand, number, number, number, number, number, number];
246
+ /** The relative cubic Bezier segment tuple `[c, dx1, dy1, dx2, dy2, dx, dy]`. */
137
247
  type cSegment = [cCommand, number, number, number, number, number, number];
248
+ /** The cubic Bezier segment, absolute or relative. */
138
249
  type CubicSegment = CSegment | cSegment;
250
+ /** The absolute smooth cubic Bezier segment tuple `[S, x2, y2, x, y]`. */
139
251
  type SSegment = [SCommand, number, number, number, number];
252
+ /** The relative smooth cubic Bezier segment tuple `[s, dx2, dy2, dx, dy]`. */
140
253
  type sSegment = [sCommand, number, number, number, number];
254
+ /** The smooth cubic Bezier segment, absolute or relative. */
141
255
  type ShortCubicSegment = SSegment | sSegment;
256
+ /** The absolute quadratic Bezier segment tuple `[Q, x1, y1, x, y]`. */
142
257
  type QSegment = [QCommand, number, number, number, number];
258
+ /** The relative quadratic Bezier segment tuple `[q, dx1, dy1, dx, dy]`. */
143
259
  type qSegment = [qCommand, number, number, number, number];
260
+ /** The quadratic Bezier segment, absolute or relative. */
144
261
  type QuadSegment = QSegment | qSegment;
262
+ /** The absolute smooth quadratic Bezier segment tuple `[T, x, y]`. */
145
263
  type TSegment = [TCommand, number, number];
264
+ /** The relative smooth quadratic Bezier segment tuple `[t, dx, dy]`. */
146
265
  type tSegment = [tCommand, number, number];
266
+ /** The smooth quadratic Bezier segment, absolute or relative. */
147
267
  type ShortQuadSegment = TSegment | tSegment;
268
+ /** The absolute elliptical arc segment tuple `[A, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, x, y]`. */
148
269
  type ASegment = [ACommand, number, number, number, number, number, number, number];
270
+ /** The relative elliptical arc segment tuple `[a, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, dx, dy]`. */
149
271
  type aSegment = [aCommand, number, number, number, number, number, number, number];
272
+ /** The elliptical arc segment, absolute or relative. */
150
273
  type ArcSegment = ASegment | aSegment;
274
+ /** Any SVG path command segment. */
151
275
  type PathSegment = MoveSegment | LineSegment | VertLineSegment | HorLineSegment | CloseSegment | CubicSegment | ShortCubicSegment | QuadSegment | ShortQuadSegment | ArcSegment;
276
+ /** Any shorthand or single-coordinate path segment. */
152
277
  type ShortSegment = VertLineSegment | HorLineSegment | ShortCubicSegment | ShortQuadSegment | CloseSegment;
278
+ /** Any absolute path command segment. */
153
279
  type AbsoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
280
+ /** Any relative path command segment. */
154
281
  type RelativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
282
+ /** The path segments used by the normalized form (no shorthand commands). */
155
283
  type NormalSegment = MSegment | LSegment | CSegment | QSegment | ASegment | ZSegment;
284
+ /** A parsed SVG path string as an array of path segments. */
156
285
  type PathArray = [MSegment | mSegment, ...PathSegment[]];
286
+ /** A `PathArray` with only absolute path segments. */
157
287
  type AbsoluteArray = [MSegment, ...AbsoluteSegment[]];
288
+ /** A `PathArray` with only relative path segments. */
158
289
  type RelativeArray = [MSegment, ...RelativeSegment[]];
290
+ /** A `PathArray` with only normalized segments (no shorthand commands). */
159
291
  type NormalArray = [MSegment, ...NormalSegment[]];
292
+ /** A `PathArray` with only moveto and cubic Bezier segments. */
160
293
  type CurveArray = [MSegment, ...CSegment[]];
294
+ /** A `CurveArray` ending with a closepath segment. */
161
295
  type ClosedCurveArray = [MSegment, ...CSegment[], ZSegment];
296
+ /** A `PathArray` describing a closed polygon (moveto, lineto and closepath). */
162
297
  type PolygonArray = [MSegment, ...LSegment[], ZSegment];
298
+ /** A `PathArray` describing an open polyline (moveto and lineto). */
163
299
  type PolylineArray = [MSegment, ...LSegment[]];
300
+ /** The `PathArray` shapes supported by path morphing. */
164
301
  type MorphPathArray = PolygonArray | PolylineArray | CurveArray | ClosedCurveArray;
302
+ /** The SVG element types that can be converted to a path. */
165
303
  type ShapeTypes = SVGPolylineElement | SVGPolygonElement | SVGLineElement | SVGEllipseElement | SVGCircleElement | SVGRectElement;
304
+ /** The shape attributes mapped to each supported SVG element type. */
166
305
  type ShapeOps = LineAttr | PolyAttr | PolyAttr | EllipseAttr | CircleAttr | RectAttr | GlyphAttr;
306
+ /** A `TransformObject` with a required 3D origin. */
167
307
  type TransformObjectValues = Partial<TransformObject> & {
308
+ /** The transform origin. */
168
309
  origin: [number, number, number];
169
310
  };
311
+ /** A 2D point with `x` and `y` coordinates. */
170
312
  type Point = {
313
+ /** The X coordinate. */
171
314
  x: number;
315
+ /** The Y coordinate. */
172
316
  y: number;
173
317
  };
318
+ /** A 2D point as a tuple `[x, y]`. */
174
319
  type PointTuple = [number, number];
320
+ /** A `Point` with a `t` parameter (a point on a curve at ratio `t`). */
175
321
  type DerivedPoint = Point & {
322
+ /** The parameter ratio in `[0-1]`. */
176
323
  t: number;
177
324
  };
325
+ /** The six points of a quadratic Bezier curve (on-curve and off-curve control points). */
178
326
  type QuadPoints = [Point, Point, Point, Point, Point, Point];
327
+ /** The eight points of a cubic Bezier curve (on-curve and off-curve control points). */
179
328
  type CubicPoints = [Point, Point, Point, Point, Point, Point, Point, Point];
329
+ /** The six derived points of a quadratic Bezier curve, each with a `t` parameter. */
180
330
  type DerivedQuadPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
331
+ /** The eight derived points of a cubic Bezier curve, each with a `t` parameter. */
181
332
  type DerivedCubicPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
333
+ /** The six coordinates of a quadratic Bezier segment `[x1, y1, cx, cy, x, y]`. */
182
334
  type QuadCoordinates = [number, number, number, number, number, number];
335
+ /** The eight coordinates of a cubic Bezier segment. */
183
336
  type CubicCoordinates = [number, number, number, number, number, number, number, number];
337
+ /** A function that derives a point on a curve at a given `t` ratio. */
184
338
  type DeriveCallback = (t: number) => Point;
339
+ /** A callback invoked for each segment while iterating over a `PathArray`. */
185
340
  type IteratorCallback<T extends PathArray, K extends keyof T = number> = (segment: PathSegment & T[K], index: number, lastX: number, lastY: number) => PathSegment | T[K] | false | void | undefined;
341
+ /** The bounding box extremes `[minX, minY, maxX, maxY]`. */
186
342
  type BBoxMaxima = [minX: number, minY: number, maxX: number, maxY: number];
343
+ /** An intersection point between two curves, including both `t` ratios. */
187
344
  type IntersectionPoint = {
345
+ /** The X coordinate of the intersection point. */
188
346
  x: number;
347
+ /** The Y coordinate of the intersection point. */
189
348
  y: number;
349
+ /** The parameter ratio of the first curve. */
190
350
  t1: number;
351
+ /** The parameter ratio of the second curve. */
191
352
  t2: number;
192
353
  };
354
+ /** Options for equalizing two paths for morphing. */
193
355
  interface EqualizationOptions {
194
- /** @default "auto" */
356
+ /** The equalization mode. @default "auto" */
195
357
  mode?: "curve" | "auto";
358
+ /** The number of sample points for the line mode. */
196
359
  sampleSize?: number;
360
+ /** The amount of decimals to round values to. */
197
361
  roundValues?: number;
362
+ /** Whether to reverse the second path before equalization. */
198
363
  reverse?: boolean;
364
+ /** Whether to close the path before equalization. */
199
365
  close?: boolean;
366
+ /** The target segment count for both paths. */
200
367
  target?: number;
201
368
  }
202
369
  //#endregion
@@ -324,6 +491,7 @@ declare const getPointAtArcLength: (x1: number, y1: number, RX: number, RY: numb
324
491
  * @returns the extrema of the Arc segment
325
492
  */
326
493
  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];
494
+ /** The tools for elliptical arc computation. */
327
495
  declare const arcTools: {
328
496
  angleBetween: typeof angleBetween;
329
497
  arcLength: typeof arcLength;
@@ -347,7 +515,20 @@ declare const deriveBezier: (points: QuadPoints | CubicPoints) => (DerivedQuadPo
347
515
  * @param t
348
516
  */
349
517
  declare const computeBezier: (points: DerivedQuadPoints | DerivedCubicPoints, t: number) => DerivedPoint;
518
+ /**
519
+ * Calculates the speed (derivative magnitude) of a Bezier curve at parameter `t`.
520
+ *
521
+ * @param derivativeFn the curve derivative function
522
+ * @param t the sampled point ratio in `[0-1]`
523
+ * @returns the curve speed at parameter `t`
524
+ */
350
525
  declare const calculateBezier: (derivativeFn: DeriveCallback, t: number) => number;
526
+ /**
527
+ * Returns the total arc length of a Bezier segment.
528
+ *
529
+ * @param derivativeFn the curve derivative function
530
+ * @returns the total arc length
531
+ */
351
532
  declare const bezierLength: (derivativeFn: DeriveCallback) => number;
352
533
  /**
353
534
  * Returns the arc length of a Bezier segment from its start point
@@ -398,6 +579,7 @@ declare const minmaxQ: ([v1, cp, v2]: [number, number, number]) => PointTuple;
398
579
  * @see https://github.com/kpym/SVGPathy/blob/acd1a50c626b36d81969f6e98e8602e128ba4302/lib/box.js#L127
399
580
  */
400
581
  declare const minmaxC: ([v1, cp1, cp2, v2]: [number, number, number, number]) => PointTuple;
582
+ /** The tools for Bezier curve computation. */
401
583
  declare const bezierTools: {
402
584
  bezierLength: typeof bezierLength;
403
585
  bezierLengthAtT: typeof bezierLengthAtT;
@@ -481,6 +663,7 @@ declare const getPointAtCubicLength: (x1: number, y1: number, c1x: number, c1y:
481
663
  * @returns the extrema of the CubicBezier segment
482
664
  */
483
665
  declare const getCubicBBox: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => BBoxMaxima;
666
+ /** The tools for cubic Bezier computation. */
484
667
  declare const cubicTools: {
485
668
  getCubicBBox: typeof getCubicBBox;
486
669
  getCubicLength: typeof getCubicLength;
@@ -523,6 +706,7 @@ declare const getPointAtLineLength: (x1: number, y1: number, x2: number, y2: num
523
706
  * @returns the bounding box for line segments
524
707
  */
525
708
  declare const getLineBBox: (x1: number, y1: number, x2: number, y2: number) => [number, number, number, number];
709
+ /** The tools for line segment computation. */
526
710
  declare const lineTools: {
527
711
  getLineBBox: typeof getLineBBox;
528
712
  getLineLength: typeof getLineLength;
@@ -590,6 +774,7 @@ declare const getPointAtQuadLength: (x1: number, y1: number, cx: number, cy: num
590
774
  * @returns the extrema of the QuadraticBezier segment
591
775
  */
592
776
  declare const getQuadBBox: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => [number, number, number, number];
777
+ /** The tools for quadratic Bezier computation. */
593
778
  declare const quadTools: {
594
779
  getPointAtQuadLength: typeof getPointAtQuadLength;
595
780
  getPointAtQuadSegmentLength: typeof getPointAtQuadSegmentLength;
@@ -626,6 +811,7 @@ declare const polygonLength: (polygon: PointTuple[]) => number;
626
811
  * @returns [x, y] centroid
627
812
  */
628
813
  declare const polygonCentroid: (polygon: PointTuple[]) => PointTuple;
814
+ /** The tools for polygon computation. */
629
815
  declare const polygonTools: {
630
816
  polygonArea: typeof polygonArea;
631
817
  polygonLength: typeof polygonLength;
@@ -1586,7 +1772,7 @@ declare const equalizePaths: (pathInput1: string | PathArray, pathInput2: string
1586
1772
  * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)
1587
1773
  * // => 1
1588
1774
  * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)
1589
- * // => [{ x: 50, y: 25, t1: 0.5, t2: 0.5 }]
1775
+ * // => [{ x: 80.4136, y: 19.5864, t1: 0.7262, t2: 0.2738 }]
1590
1776
  * ```
1591
1777
  */
1592
1778
  declare const pathsIntersection: <T extends string | PathArray>(pathInput1: T, pathInput2: T, justCount?: boolean) => number | IntersectionPoint[];
@@ -1 +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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAsBU;EACV;EACA;EACA;EACA;EACA;;;;KCpHU;KA6BA;KAYA;KAaA;KACA;KAEA;KACA;KAEA;KACA;KAEA;KACA;KAEA;KACA;KAEA;KACA;KAEA;KACA;KAEA;KACA;KAEA;KACA;KAEA;KACA;KAEA,kBACR,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA;KAEQ,kBACR,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA;KAEQ,cAAc,kBAAkB;KAEhC,YAAY;KACZ,YAAY;KACZ,cAAc,WAAW;KAEzB,YAAY;KACZ,YAAY;KACZ,cAAc,WAAW;KAEzB,YAAY;KACZ,YAAY;KACZ,kBAAkB,WAAW;KAE7B,YAAY;KACZ,YAAY;KACZ,iBAAiB,WAAW;KAE5B,YAAY;KACZ,YAAY;KACZ,eAAe,WAAW;KAE1B,YACV;KAQU,YACV;KAQU,eAAe,WAAW;KAE1B,YAAY;KACZ,YAAY;KACZ,oBAAoB,WAAW;KAE/B,YAAY;KACZ,YAAY;KACZ,cAAc,WAAW;KAEzB,YAAY;KACZ,YAAY;KACZ,mBAAmB,WAAW;KAE9B,YACV;KASU,YACV;KASU,aAAa,WAAW;KAExB,cACR,cACA,cACA,kBACA,iBACA,eACA,eACA,oBACA,cACA,mBACA;KAEQ,eACR,kBACA,iBACA,oBACA,mBACA;KAEQ,kBACR,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA;KAEQ,kBACR,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA;KAEQ,gBACR,WACA,WACA,WACA,WACA,WACA;KAEQ,aAAa,WAAW,aAAa;KACrC,iB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,YACA,YACA,aACE,kBAAkB;;;;;;;;;;;;;;;;;;cCkBT,mBAAgB,OACpB,oBAAkB,OAClB,oBAAkB,aACb,yBACV,gBAAgB;;;;;;;;;;;;;;;;;;cCdP,gBAAa,qBACH,WAAS,qBACT,WAAS,qBAE5B,gBAAgB;;;;;;;;;;;;;;;;;;;cCjBP,oBAAqB,mBAAmB,WAAS,YAChD,GAAC,YACD,GAAC,iCAEH;;;;;;;;;;cCjBC,uBAAoB,GAAO,YAAU,GAAK;;;;;;;;;;cCF1C,oBAAiB,MACtB,aAAU,GAAA,IACR"}
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":";;;;;;;;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;;;KA2CU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;KAmDU;;EAEV;;EAEA;;EAEA;;EA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;;cCkBT,mBAAgB,OACpB,oBAAkB,OAClB,oBAAkB,aACb,yBACV,gBAAgB;;;;;;;;;;;;;;;;;;cCdP,gBAAa,qBACH,WAAS,qBACT,WAAS,qBAE5B,gBAAgB;;;;;;;;;;;;;;;;;;;cCjBP,oBAAqB,mBAAmB,WAAS,YAChD,GAAC,YACD,GAAC,iCAEH;;;;;;;;;;cCjBC,uBAAoB,GAAO,YAAU,GAAK;;;;;;;;;;cCF1C,oBAAiB,MACtB,aAAU,GAAA,IACR"}
package/dist/util.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SVGPathCommander v2.2.2 (http://thednp.github.io/svg-path-commander)
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
  */
@@ -97,6 +97,7 @@ const getLineBBox = (x1, y1, x2, y2) => {
97
97
  max(y1, y2)
98
98
  ];
99
99
  };
100
+ /** The tools for line segment computation. */
100
101
  const lineTools = {
101
102
  getLineBBox,
102
103
  getLineLength,
@@ -134,6 +135,7 @@ const Tvalues = [
134
135
  -.9951872199970213,
135
136
  .9951872199970213
136
137
  ];
138
+ /** The weights for the 32-point Gauss-Legendre quadrature. */
137
139
  const Cvalues = [
138
140
  .12793819534675216,
139
141
  .12793819534675216,
@@ -234,11 +236,24 @@ const computeBezier = (points, t) => {
234
236
  t
235
237
  };
236
238
  };
239
+ /**
240
+ * Calculates the speed (derivative magnitude) of a Bezier curve at parameter `t`.
241
+ *
242
+ * @param derivativeFn the curve derivative function
243
+ * @param t the sampled point ratio in `[0-1]`
244
+ * @returns the curve speed at parameter `t`
245
+ */
237
246
  const calculateBezier = (derivativeFn, t) => {
238
247
  const d = derivativeFn(t);
239
248
  const l = d.x * d.x + d.y * d.y;
240
249
  return Math.sqrt(l);
241
250
  };
251
+ /**
252
+ * Returns the total arc length of a Bezier segment.
253
+ *
254
+ * @param derivativeFn the curve derivative function
255
+ * @returns the total arc length
256
+ */
242
257
  const bezierLength = (derivativeFn) => {
243
258
  return bezierLengthAtT(derivativeFn, 1);
244
259
  };
@@ -320,6 +335,7 @@ const getBezierLength = (curve) => {
320
335
  return computeBezier(dpoints[0], t);
321
336
  });
322
337
  };
338
+ /** The precision threshold to consider a cubic polynomial as quadratic. */
323
339
  const CBEZIER_MINMAX_EPSILON = 1e-8;
324
340
  /**
325
341
  * Returns the most extreme points in a Quad Bezier segment.
@@ -360,6 +376,7 @@ const minmaxC = ([v1, cp1, cp2, v2]) => {
360
376
  }
361
377
  return [min, max];
362
378
  };
379
+ /** The tools for Bezier curve computation. */
363
380
  const bezierTools = {
364
381
  bezierLength,
365
382
  bezierLengthAtT,
@@ -703,6 +720,7 @@ const getArcBBox = (x1, y1, RX, RY, angle, LAF, SF, x, y) => {
703
720
  yMax
704
721
  ];
705
722
  };
723
+ /** The tools for elliptical arc computation. */
706
724
  const arcTools = {
707
725
  angleBetween,
708
726
  arcLength,
@@ -839,6 +857,7 @@ const getCubicBBox = (x1, y1, c1x, c1y, c2x, c2y, x2, y2) => {
839
857
  cyMinMax[1]
840
858
  ];
841
859
  };
860
+ /** The tools for cubic Bezier computation. */
842
861
  const cubicTools = {
843
862
  getCubicBBox,
844
863
  getCubicLength,
@@ -959,6 +978,7 @@ const getQuadBBox = (x1, y1, cx, cy, x2, y2) => {
959
978
  cyMinMax[1]
960
979
  ];
961
980
  };
981
+ /** The tools for quadratic Bezier computation. */
962
982
  const quadTools = {
963
983
  getPointAtQuadLength,
964
984
  getPointAtQuadSegmentLength,
@@ -1022,6 +1042,7 @@ const polygonCentroid = (polygon) => {
1022
1042
  const count = polygon.length;
1023
1043
  return [sumX / count, sumY / count];
1024
1044
  };
1045
+ /** The tools for polygon computation. */
1025
1046
  const polygonTools = {
1026
1047
  polygonArea,
1027
1048
  polygonLength,
@@ -4221,6 +4242,14 @@ const intersect = (x1, y1, x2, y2, x3, y3, x4, y4) => {
4221
4242
  y: py
4222
4243
  };
4223
4244
  };
4245
+ /**
4246
+ * Returns the intersection point(s) of two cubic Bezier curves.
4247
+ *
4248
+ * @param bez1 the coordinates of the first cubic Bezier segment
4249
+ * @param bez2 the coordinates of the second cubic Bezier segment
4250
+ * @param config optional intersection options
4251
+ * @returns the intersection points, or `undefined` if the curves do not intersect
4252
+ */
4224
4253
  const interHelper = (bez1, bez2, config) => {
4225
4254
  const bbox1 = getCubicBBox(...bez1);
4226
4255
  const bbox2 = getCubicBBox(...bez2);
@@ -4279,7 +4308,7 @@ const interHelper = (bez1, bez2, config) => {
4279
4308
  * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)
4280
4309
  * // => 1
4281
4310
  * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)
4282
- * // => [{ x: 50, y: 25, t1: 0.5, t2: 0.5 }]
4311
+ * // => [{ x: 80.4136, y: 19.5864, t1: 0.7262, t2: 0.2738 }]
4283
4312
  * ```
4284
4313
  */
4285
4314
  const pathsIntersection = (pathInput1, pathInput2, justCount = true) => {