svg-path-commander 2.3.3 → 2.3.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/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  /*!
2
- * SVGPathCommander v2.3.3 (http://thednp.github.io/svg-path-commander)
2
+ * SVGPathCommander v2.3.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
- //#region src/interface.d.ts
8
7
  /** The properties of a path segment found by segment lookup utilities. */
9
- type SegmentProperties = {
8
+ export type SegmentProperties = {
10
9
  /** The path segment. */
11
10
  segment: PathSegment;
12
11
  /** The index of the segment in the path. */
@@ -17,7 +16,7 @@ type SegmentProperties = {
17
16
  lengthAtSegment: number;
18
17
  };
19
18
  /** The closest point on the path to a given point, with the distance and optional segment. */
20
- type PointProperties = {
19
+ export type PointProperties = {
21
20
  /** The closest point on the path to the given point. */
22
21
  closest: {
23
22
  /** The X coordinate of the closest point. */
@@ -31,7 +30,7 @@ type PointProperties = {
31
30
  segment?: SegmentProperties;
32
31
  };
33
32
  /** The attributes of a `<line>` element read by `shapeToPath`. */
34
- type LineAttr = {
33
+ export type LineAttr = {
35
34
  /** The element type. */
36
35
  type: "line";
37
36
  /** The X coordinate of the start point. */
@@ -45,7 +44,7 @@ type LineAttr = {
45
44
  [key: string]: string | number;
46
45
  };
47
46
  /** The attributes of a `<polygon>` or `<polyline>` element read by `shapeToPath`. */
48
- type PolyAttr = {
47
+ export type PolyAttr = {
49
48
  /** The element type. */
50
49
  type: "polygon" | "polyline";
51
50
  /** The points attribute value. */
@@ -53,7 +52,7 @@ type PolyAttr = {
53
52
  [key: string]: string | number;
54
53
  };
55
54
  /** The attributes of a `<circle>` element read by `shapeToPath`. */
56
- type CircleAttr = {
55
+ export type CircleAttr = {
57
56
  /** The element type. */
58
57
  type: "circle";
59
58
  /** The X coordinate of the center. */
@@ -65,7 +64,7 @@ type CircleAttr = {
65
64
  [key: string]: string | number;
66
65
  };
67
66
  /** The attributes of an `<ellipse>` element read by `shapeToPath`. */
68
- type EllipseAttr = {
67
+ export type EllipseAttr = {
69
68
  /** The element type. */
70
69
  type: "ellipse";
71
70
  /** The X coordinate of the center. */
@@ -79,7 +78,7 @@ type EllipseAttr = {
79
78
  [key: string]: string | number | undefined;
80
79
  };
81
80
  /** The attributes of a `<rect>` element read by `shapeToPath`. */
82
- type RectAttr = {
81
+ export type RectAttr = {
83
82
  /** The element type. */
84
83
  type: "rect";
85
84
  /** The rectangle width. */
@@ -97,7 +96,7 @@ type RectAttr = {
97
96
  [key: string]: string | number | undefined;
98
97
  };
99
98
  /** The attributes of a `<glyph>` element read by `shapeToPath`. */
100
- type GlyphAttr = {
99
+ export type GlyphAttr = {
101
100
  /** The element type. */
102
101
  type: "glyph";
103
102
  /** The path data of the glyph. */
@@ -105,7 +104,7 @@ type GlyphAttr = {
105
104
  [key: string]: string | number;
106
105
  };
107
106
  /** The parameter names read from each SVG shape element by `shapeToPath`. */
108
- type ShapeParams = {
107
+ export type ShapeParams = {
109
108
  /** The parameter names read from the `<line>` element. */
110
109
  line: ["x1", "y1", "x2", "y2"];
111
110
  /** The parameter names read from the `<circle>` element. */
@@ -122,7 +121,7 @@ type ShapeParams = {
122
121
  glyph: ["d"];
123
122
  };
124
123
  /** The bounding box of a path, equivalent to the native `getBBox()` result. */
125
- type PathBBox = {
124
+ export type PathBBox = {
126
125
  /** The width of the bounding box. */
127
126
  width: number;
128
127
  /** The height of the bounding box. */
@@ -143,7 +142,7 @@ type PathBBox = {
143
142
  cz: number;
144
143
  };
145
144
  /** The minimum and maximum points of a segment bounding box. */
146
- type SegmentLimits = {
145
+ export type SegmentLimits = {
147
146
  /** The minimum coordinates of the segment. */
148
147
  min: {
149
148
  /** The minimum X coordinate. */
@@ -160,7 +159,7 @@ type SegmentLimits = {
160
159
  };
161
160
  };
162
161
  /** The current state tracked by the SVG path string parser. */
163
- type ParserParams = {
162
+ export type ParserParams = {
164
163
  /** The X coordinate of the previous moveto point. */
165
164
  mx: number;
166
165
  /** The Y coordinate of the previous moveto point. */
@@ -169,10 +168,16 @@ type ParserParams = {
169
168
  x1: number;
170
169
  /** The Y coordinate of the previous control point. */
171
170
  y1: number;
172
- /** The X coordinate of the second control point. */
173
- x2: number;
174
- /** The Y coordinate of the second control point. */
175
- y2: number;
171
+ /**
172
+ * The X coordinate of the reflectable control point of the previous
173
+ * segment, `null` when the previous segment has none.
174
+ */
175
+ x2: number | null;
176
+ /**
177
+ * The Y coordinate of the reflectable control point of the previous
178
+ * segment, `null` when the previous segment has none.
179
+ */
180
+ y2: number | null;
176
181
  /** The X coordinate of the current point. */
177
182
  x: number;
178
183
  /** The Y coordinate of the current point. */
@@ -183,7 +188,7 @@ type ParserParams = {
183
188
  qy: number | null;
184
189
  };
185
190
  /** The result of a length computation factory: length, point and segment limits. */
186
- type LengthFactory = {
191
+ export type LengthFactory = {
187
192
  /** The total length of the segment. */
188
193
  length: number;
189
194
  /** The point on the segment at the given length. */
@@ -209,14 +214,14 @@ type LengthFactory = {
209
214
  };
210
215
  };
211
216
  /** The `SVGPathCommander` instance options. */
212
- type Options = {
217
+ export type Options = {
213
218
  /** The amount of decimals to round path values to, or "off" to disable rounding. */
214
219
  round: "off" | number;
215
220
  /** The transform origin used for path transformations. */
216
221
  origin: number[];
217
222
  };
218
223
  /** A path segment and its transformation context (command letter and coordinates). */
219
- type PathTransform = {
224
+ export type PathTransform = {
220
225
  /** The current path segment. */
221
226
  s: PathSegment;
222
227
  /** The current path command letter. */
@@ -227,7 +232,7 @@ type PathTransform = {
227
232
  y: number;
228
233
  };
229
234
  /** A transform function object with translate, rotate, scale, skew and origin. */
230
- type TransformObject = {
235
+ export type TransformObject = {
231
236
  /** A translate value, a number for all axes or an array of values. */
232
237
  translate: number | number[];
233
238
  /** A rotate value, a number for all axes or an array of values. */
@@ -240,200 +245,198 @@ type TransformObject = {
240
245
  origin: number[];
241
246
  };
242
247
  /** The keys of a `TransformObject`. */
243
- type TransformProps = keyof TransformObject;
248
+ export type TransformProps = keyof TransformObject;
244
249
  /** The entries of a `TransformObject` (key-value pairs). */
245
- type TransformEntries = [TransformProps, TransformObject[TransformProps]][];
246
- //#endregion
247
- //#region src/types.d.ts
250
+ export type TransformEntries = [TransformProps, TransformObject[TransformProps]][];
248
251
  /** Whitespace character codes recognized by the SVG path string tokenizer. */
249
- 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;
252
+ export 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;
250
253
  /** Character codes of all SVG path command letters. */
251
- type PathCommandNumber = 0x6d | 0x7a | 0x6c | 0x68 | 0x76 | 0x63 | 0x73 | 0x71 | 0x74 | 0x61;
254
+ export type PathCommandNumber = 0x6d | 0x7a | 0x6c | 0x68 | 0x76 | 0x63 | 0x73 | 0x71 | 0x74 | 0x61;
252
255
  /** Character codes of the decimal digits 0-9. */
253
- type DigitNumber = 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39;
256
+ export type DigitNumber = 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39;
254
257
  /** The absolute moveto command letter. */
255
- type MCommand = "M";
258
+ export type MCommand = "M";
256
259
  /** The relative moveto command letter. */
257
- type mCommand = "m";
260
+ export type mCommand = "m";
258
261
  /** The absolute lineto command letter. */
259
- type LCommand = "L";
262
+ export type LCommand = "L";
260
263
  /** The relative lineto command letter. */
261
- type lCommand = "l";
264
+ export type lCommand = "l";
262
265
  /** The absolute vertical lineto command letter. */
263
- type VCommand = "V";
266
+ export type VCommand = "V";
264
267
  /** The relative vertical lineto command letter. */
265
- type vCommand = "v";
268
+ export type vCommand = "v";
266
269
  /** The absolute horizontal lineto command letter. */
267
- type HCommand = "H";
270
+ export type HCommand = "H";
268
271
  /** The relative horizontal lineto command letter. */
269
- type hCommand = "h";
272
+ export type hCommand = "h";
270
273
  /** The absolute closepath command letter. */
271
- type ZCommand = "Z";
274
+ export type ZCommand = "Z";
272
275
  /** The relative closepath command letter. */
273
- type zCommand = "z";
276
+ export type zCommand = "z";
274
277
  /** The absolute cubic Bezier command letter. */
275
- type CCommand = "C";
278
+ export type CCommand = "C";
276
279
  /** The relative cubic Bezier command letter. */
277
- type cCommand = "c";
280
+ export type cCommand = "c";
278
281
  /** The absolute smooth cubic Bezier command letter. */
279
- type SCommand = "S";
282
+ export type SCommand = "S";
280
283
  /** The relative smooth cubic Bezier command letter. */
281
- type sCommand = "s";
284
+ export type sCommand = "s";
282
285
  /** The absolute quadratic Bezier command letter. */
283
- type QCommand = "Q";
286
+ export type QCommand = "Q";
284
287
  /** The relative quadratic Bezier command letter. */
285
- type qCommand = "q";
288
+ export type qCommand = "q";
286
289
  /** The absolute smooth quadratic Bezier command letter. */
287
- type TCommand = "T";
290
+ export type TCommand = "T";
288
291
  /** The relative smooth quadratic Bezier command letter. */
289
- type tCommand = "t";
292
+ export type tCommand = "t";
290
293
  /** The absolute elliptical arc command letter. */
291
- type ACommand = "A";
294
+ export type ACommand = "A";
292
295
  /** The relative elliptical arc command letter. */
293
- type aCommand = "a";
296
+ export type aCommand = "a";
294
297
  /** The union of all absolute path command letters. */
295
- type AbsoluteCommand = MCommand | LCommand | VCommand | HCommand | ZCommand | CCommand | SCommand | QCommand | TCommand | ACommand;
298
+ export type AbsoluteCommand = MCommand | LCommand | VCommand | HCommand | ZCommand | CCommand | SCommand | QCommand | TCommand | ACommand;
296
299
  /** The union of all relative path command letters. */
297
- type RelativeCommand = mCommand | lCommand | vCommand | hCommand | zCommand | cCommand | sCommand | qCommand | tCommand | aCommand;
300
+ export type RelativeCommand = mCommand | lCommand | vCommand | hCommand | zCommand | cCommand | sCommand | qCommand | tCommand | aCommand;
298
301
  /** Any SVG path command letter, absolute or relative. */
299
- type PathCommand = AbsoluteCommand | RelativeCommand;
302
+ export type PathCommand = AbsoluteCommand | RelativeCommand;
300
303
  /** The absolute moveto segment tuple `[M, x, y]`. */
301
- type MSegment = [MCommand, number, number];
304
+ export type MSegment = [MCommand, number, number];
302
305
  /** The relative moveto segment tuple `[m, dx, dy]`. */
303
- type mSegment = [mCommand, number, number];
306
+ export type mSegment = [mCommand, number, number];
304
307
  /** The moveto segment, absolute or relative. */
305
- type MoveSegment = MSegment | mSegment;
308
+ export type MoveSegment = MSegment | mSegment;
306
309
  /** The absolute lineto segment tuple `[L, x, y]`. */
307
- type LSegment = [LCommand, number, number];
310
+ export type LSegment = [LCommand, number, number];
308
311
  /** The relative lineto segment tuple `[l, dx, dy]`. */
309
- type lSegment = [lCommand, number, number];
312
+ export type lSegment = [lCommand, number, number];
310
313
  /** The lineto segment, absolute or relative. */
311
- type LineSegment = LSegment | lSegment;
314
+ export type LineSegment = LSegment | lSegment;
312
315
  /** The absolute vertical lineto segment tuple `[V, y]`. */
313
- type VSegment = [VCommand, number];
316
+ export type VSegment = [VCommand, number];
314
317
  /** The relative vertical lineto segment tuple `[v, dy]`. */
315
- type vSegment = [vCommand, number];
318
+ export type vSegment = [vCommand, number];
316
319
  /** The vertical lineto segment, absolute or relative. */
317
- type VertLineSegment = vSegment | VSegment;
320
+ export type VertLineSegment = vSegment | VSegment;
318
321
  /** The absolute horizontal lineto segment tuple `[H, x]`. */
319
- type HSegment = [HCommand, number];
322
+ export type HSegment = [HCommand, number];
320
323
  /** The relative horizontal lineto segment tuple `[h, dx]`. */
321
- type hSegment = [hCommand, number];
324
+ export type hSegment = [hCommand, number];
322
325
  /** The horizontal lineto segment, absolute or relative. */
323
- type HorLineSegment = HSegment | hSegment;
326
+ export type HorLineSegment = HSegment | hSegment;
324
327
  /** The absolute closepath segment tuple `[Z]`. */
325
- type ZSegment = [ZCommand];
328
+ export type ZSegment = [ZCommand];
326
329
  /** The relative closepath segment tuple `[z]`. */
327
- type zSegment = [zCommand];
330
+ export type zSegment = [zCommand];
328
331
  /** The closepath segment, absolute or relative. */
329
- type CloseSegment = ZSegment | zSegment;
332
+ export type CloseSegment = ZSegment | zSegment;
330
333
  /** The absolute cubic Bezier segment tuple `[C, x1, y1, x2, y2, x, y]`. */
331
- type CSegment = [CCommand, number, number, number, number, number, number];
334
+ export type CSegment = [CCommand, number, number, number, number, number, number];
332
335
  /** The relative cubic Bezier segment tuple `[c, dx1, dy1, dx2, dy2, dx, dy]`. */
333
- type cSegment = [cCommand, number, number, number, number, number, number];
336
+ export type cSegment = [cCommand, number, number, number, number, number, number];
334
337
  /** The cubic Bezier segment, absolute or relative. */
335
- type CubicSegment = CSegment | cSegment;
338
+ export type CubicSegment = CSegment | cSegment;
336
339
  /** The absolute smooth cubic Bezier segment tuple `[S, x2, y2, x, y]`. */
337
- type SSegment = [SCommand, number, number, number, number];
340
+ export type SSegment = [SCommand, number, number, number, number];
338
341
  /** The relative smooth cubic Bezier segment tuple `[s, dx2, dy2, dx, dy]`. */
339
- type sSegment = [sCommand, number, number, number, number];
342
+ export type sSegment = [sCommand, number, number, number, number];
340
343
  /** The smooth cubic Bezier segment, absolute or relative. */
341
- type ShortCubicSegment = SSegment | sSegment;
344
+ export type ShortCubicSegment = SSegment | sSegment;
342
345
  /** The absolute quadratic Bezier segment tuple `[Q, x1, y1, x, y]`. */
343
- type QSegment = [QCommand, number, number, number, number];
346
+ export type QSegment = [QCommand, number, number, number, number];
344
347
  /** The relative quadratic Bezier segment tuple `[q, dx1, dy1, dx, dy]`. */
345
- type qSegment = [qCommand, number, number, number, number];
348
+ export type qSegment = [qCommand, number, number, number, number];
346
349
  /** The quadratic Bezier segment, absolute or relative. */
347
- type QuadSegment = QSegment | qSegment;
350
+ export type QuadSegment = QSegment | qSegment;
348
351
  /** The absolute smooth quadratic Bezier segment tuple `[T, x, y]`. */
349
- type TSegment = [TCommand, number, number];
352
+ export type TSegment = [TCommand, number, number];
350
353
  /** The relative smooth quadratic Bezier segment tuple `[t, dx, dy]`. */
351
- type tSegment = [tCommand, number, number];
354
+ export type tSegment = [tCommand, number, number];
352
355
  /** The smooth quadratic Bezier segment, absolute or relative. */
353
- type ShortQuadSegment = TSegment | tSegment;
356
+ export type ShortQuadSegment = TSegment | tSegment;
354
357
  /** The absolute elliptical arc segment tuple `[A, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, x, y]`. */
355
- type ASegment = [ACommand, number, number, number, number, number, number, number];
358
+ export type ASegment = [ACommand, number, number, number, number, number, number, number];
356
359
  /** The relative elliptical arc segment tuple `[a, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, dx, dy]`. */
357
- type aSegment = [aCommand, number, number, number, number, number, number, number];
360
+ export type aSegment = [aCommand, number, number, number, number, number, number, number];
358
361
  /** The elliptical arc segment, absolute or relative. */
359
- type ArcSegment = ASegment | aSegment;
362
+ export type ArcSegment = ASegment | aSegment;
360
363
  /** Any SVG path command segment. */
361
- type PathSegment = MoveSegment | LineSegment | VertLineSegment | HorLineSegment | CloseSegment | CubicSegment | ShortCubicSegment | QuadSegment | ShortQuadSegment | ArcSegment;
364
+ export type PathSegment = MoveSegment | LineSegment | VertLineSegment | HorLineSegment | CloseSegment | CubicSegment | ShortCubicSegment | QuadSegment | ShortQuadSegment | ArcSegment;
362
365
  /** Any shorthand or single-coordinate path segment. */
363
- type ShortSegment = VertLineSegment | HorLineSegment | ShortCubicSegment | ShortQuadSegment | CloseSegment;
366
+ export type ShortSegment = VertLineSegment | HorLineSegment | ShortCubicSegment | ShortQuadSegment | CloseSegment;
364
367
  /** Any absolute path command segment. */
365
- type AbsoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
368
+ export type AbsoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
366
369
  /** Any relative path command segment. */
367
- type RelativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
370
+ export type RelativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
368
371
  /** The path segments used by the normalized form (no shorthand commands). */
369
- type NormalSegment = MSegment | LSegment | CSegment | QSegment | ASegment | ZSegment;
372
+ export type NormalSegment = MSegment | LSegment | CSegment | QSegment | ASegment | ZSegment;
370
373
  /** A parsed SVG path string as an array of path segments. */
371
- type PathArray = [MSegment | mSegment, ...PathSegment[]];
374
+ export type PathArray = [MSegment | mSegment, ...PathSegment[]];
372
375
  /** A `PathArray` with only absolute path segments. */
373
- type AbsoluteArray = [MSegment, ...AbsoluteSegment[]];
376
+ export type AbsoluteArray = [MSegment, ...AbsoluteSegment[]];
374
377
  /** A `PathArray` with only relative path segments. */
375
- type RelativeArray = [MSegment, ...RelativeSegment[]];
378
+ export type RelativeArray = [MSegment, ...RelativeSegment[]];
376
379
  /** A `PathArray` with only normalized segments (no shorthand commands). */
377
- type NormalArray = [MSegment, ...NormalSegment[]];
380
+ export type NormalArray = [MSegment, ...NormalSegment[]];
378
381
  /** A `PathArray` with only moveto and cubic Bezier segments. */
379
- type CurveArray = [MSegment, ...CSegment[]];
382
+ export type CurveArray = [MSegment, ...CSegment[]];
380
383
  /** A `CurveArray` ending with a closepath segment. */
381
- type ClosedCurveArray = [MSegment, ...CSegment[], ZSegment];
384
+ export type ClosedCurveArray = [MSegment, ...CSegment[], ZSegment];
382
385
  /** A `PathArray` describing a closed polygon (moveto, lineto and closepath). */
383
- type PolygonArray = [MSegment, ...LSegment[], ZSegment];
386
+ export type PolygonArray = [MSegment, ...LSegment[], ZSegment];
384
387
  /** A `PathArray` describing an open polyline (moveto and lineto). */
385
- type PolylineArray = [MSegment, ...LSegment[]];
388
+ export type PolylineArray = [MSegment, ...LSegment[]];
386
389
  /** The `PathArray` shapes supported by path morphing. */
387
- type MorphPathArray = PolygonArray | PolylineArray | CurveArray | ClosedCurveArray;
390
+ export type MorphPathArray = PolygonArray | PolylineArray | CurveArray | ClosedCurveArray;
388
391
  /** The SVG element types that can be converted to a path. */
389
- type ShapeTypes = SVGPolylineElement | SVGPolygonElement | SVGLineElement | SVGEllipseElement | SVGCircleElement | SVGRectElement;
392
+ export type ShapeTypes = SVGPolylineElement | SVGPolygonElement | SVGLineElement | SVGEllipseElement | SVGCircleElement | SVGRectElement;
390
393
  /** The tag names of the SVG elements that can be converted to a path. */
391
- type ShapeTags = "line" | "polyline" | "polygon" | "ellipse" | "circle" | "rect" | "glyph";
394
+ export type ShapeTags = "line" | "polyline" | "polygon" | "ellipse" | "circle" | "rect" | "glyph";
392
395
  /** The shape attributes mapped to each supported SVG element type. */
393
- type ShapeOps = LineAttr | PolyAttr | PolyAttr | EllipseAttr | CircleAttr | RectAttr | GlyphAttr;
396
+ export type ShapeOps = LineAttr | PolyAttr | EllipseAttr | CircleAttr | RectAttr | GlyphAttr;
394
397
  /** A `TransformObject` with a required 3D origin. */
395
- type TransformObjectValues = Partial<TransformObject> & {
398
+ export type TransformObjectValues = Partial<TransformObject> & {
396
399
  /** The transform origin. */
397
400
  origin: [number, number, number];
398
401
  };
399
402
  /** A 2D point with `x` and `y` coordinates. */
400
- type Point = {
403
+ export type Point = {
401
404
  /** The X coordinate. */
402
405
  x: number;
403
406
  /** The Y coordinate. */
404
407
  y: number;
405
408
  };
406
409
  /** A 2D point as a tuple `[x, y]`. */
407
- type PointTuple = [number, number];
410
+ export type PointTuple = [number, number];
408
411
  /** A `Point` with a `t` parameter (a point on a curve at ratio `t`). */
409
- type DerivedPoint = Point & {
412
+ export type DerivedPoint = Point & {
410
413
  /** The parameter ratio in `[0-1]`. */
411
414
  t: number;
412
415
  };
413
416
  /** The six points of a quadratic Bezier curve (on-curve and off-curve control points). */
414
- type QuadPoints = [Point, Point, Point, Point, Point, Point];
417
+ export type QuadPoints = [Point, Point, Point, Point, Point, Point];
415
418
  /** The eight points of a cubic Bezier curve (on-curve and off-curve control points). */
416
- type CubicPoints = [Point, Point, Point, Point, Point, Point, Point, Point];
419
+ export type CubicPoints = [Point, Point, Point, Point, Point, Point, Point, Point];
417
420
  /** The six derived points of a quadratic Bezier curve, each with a `t` parameter. */
418
- type DerivedQuadPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
421
+ export type DerivedQuadPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
419
422
  /** The eight derived points of a cubic Bezier curve, each with a `t` parameter. */
420
- type DerivedCubicPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
423
+ export type DerivedCubicPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
421
424
  /** The six coordinates of a quadratic Bezier segment `[x1, y1, cx, cy, x, y]`. */
422
- type QuadCoordinates = [number, number, number, number, number, number];
425
+ export type QuadCoordinates = [number, number, number, number, number, number];
423
426
  /** The eight coordinates of a cubic Bezier segment. */
424
- type CubicCoordinates = [number, number, number, number, number, number, number, number];
427
+ export type CubicCoordinates = [number, number, number, number, number, number, number, number];
425
428
  /** The coordinates of an arc segment (the eight numbers after the command letter). */
426
- type ArcCoordinates = [number, number, number, number, number, number, number, number, number];
429
+ export type ArcCoordinates = [number, number, number, number, number, number, number, number, number];
427
430
  /** The four coordinates of a line segment `[x1, y1, x2, y2]`. */
428
- type LineCoordinates = [number, number, number, number];
431
+ export type LineCoordinates = [number, number, number, number];
429
432
  /** A function that derives a point on a curve at a given `t` ratio. */
430
- type DeriveCallback = (t: number) => Point;
433
+ export type DeriveCallback = (t: number) => Point;
431
434
  /** A callback invoked for each segment while iterating over a `PathArray`. */
432
- 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;
435
+ export 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;
433
436
  /** The bounding box extremes `[minX, minY, maxX, maxY]`. */
434
- type BBoxMaxima = [minX: number, minY: number, maxX: number, maxY: number];
437
+ export type BBoxMaxima = [minX: number, minY: number, maxX: number, maxY: number];
435
438
  /** A point on the path at a given length, including the `t` ratio. */
436
- type PointAtLength = {
439
+ export type PointAtLength = {
437
440
  /** The X coordinate. */
438
441
  x: number;
439
442
  /** The Y coordinate. */
@@ -442,7 +445,7 @@ type PointAtLength = {
442
445
  t: number;
443
446
  };
444
447
  /** An intersection point between two curves, including both `t` ratios. */
445
- type IntersectionPoint = {
448
+ export type IntersectionPoint = {
446
449
  /** The X coordinate of the intersection point. */
447
450
  x: number;
448
451
  /** The Y coordinate of the intersection point. */
@@ -453,14 +456,14 @@ type IntersectionPoint = {
453
456
  t2: number;
454
457
  };
455
458
  /** Options for computing intersections between two curves. */
456
- interface IntersectionOptions {
459
+ export interface IntersectionOptions {
457
460
  /** Whether to only count the intersections without computing points. */
458
461
  justCount?: boolean;
459
462
  /** The epsilon value used for precision. */
460
463
  epsilon?: number;
461
464
  }
462
465
  /** Options for equalizing a single path to a given segment count. */
463
- interface PathEqualizationOptions {
466
+ export interface PathEqualizationOptions {
464
467
  /** The equalization mode. @default "auto" */
465
468
  mode?: "line" | "curve" | "auto";
466
469
  /** The number of sample points for the line mode. */
@@ -471,7 +474,7 @@ interface PathEqualizationOptions {
471
474
  close?: boolean;
472
475
  }
473
476
  /** Options for equalizing two paths for morphing. */
474
- interface EqualizationOptions {
477
+ export interface EqualizationOptions {
475
478
  /** The equalization mode. @default "auto" */
476
479
  mode?: "curve" | "auto";
477
480
  /** The number of sample points for the line mode. */
@@ -486,9 +489,9 @@ interface EqualizationOptions {
486
489
  target?: number;
487
490
  }
488
491
  /** `EqualizationOptions` without `reverse` and `target`, used for path pairs. */
489
- type PathsEqualizationOptions = Omit<EqualizationOptions, "reverse" | "target">;
492
+ export type PathsEqualizationOptions = Omit<EqualizationOptions, "reverse" | "target">;
490
493
  /** The geometric features of a path used for matching during morphing. */
491
- interface PathFeature {
494
+ export interface PathFeature {
492
495
  /** Whether the path is a polygon. */
493
496
  isPoly: boolean;
494
497
  /** The normalized path array. */
@@ -502,8 +505,6 @@ interface PathFeature {
502
505
  /** The bounding box of the path. */
503
506
  bbox: PathBBox;
504
507
  }
505
- //#endregion
506
- //#region src/math/distanceSquareRoot.d.ts
507
508
  /**
508
509
  * Returns the square root of the distance
509
510
  * between two given points.
@@ -513,8 +514,6 @@ interface PathFeature {
513
514
  * @returns the distance value
514
515
  */
515
516
  declare const distanceSquareRoot: (a: PointTuple, b: PointTuple) => number;
516
- //#endregion
517
- //#region src/math/midPoint.d.ts
518
517
  /**
519
518
  * Returns the coordinates of a specified distance
520
519
  * ratio between two points.
@@ -525,8 +524,6 @@ declare const distanceSquareRoot: (a: PointTuple, b: PointTuple) => number;
525
524
  * @returns the midpoint coordinates
526
525
  */
527
526
  declare const midPoint: ([ax, ay]: PointTuple, [bx, by]: PointTuple, t: number) => PointTuple;
528
- //#endregion
529
- //#region src/math/rotateVector.d.ts
530
527
  /**
531
528
  * Returns an {x,y} vector rotated by a given
532
529
  * angle in radian.
@@ -540,8 +537,6 @@ declare const rotateVector: (x: number, y: number, rad: number) => {
540
537
  x: number;
541
538
  y: number;
542
539
  };
543
- //#endregion
544
- //#region src/math/roundTo.d.ts
545
540
  /**
546
541
  * Rounds a number to the specified number of decimal places.
547
542
  *
@@ -550,8 +545,6 @@ declare const rotateVector: (x: number, y: number, rad: number) => {
550
545
  * @returns The rounded number
551
546
  */
552
547
  declare const roundTo: (n: number, round: number) => number;
553
- //#endregion
554
- //#region src/convert/pathToAbsolute.d.ts
555
548
  /**
556
549
  * Parses a path string value or object and returns an array
557
550
  * of segments, all converted to absolute values.
@@ -566,8 +559,6 @@ declare const roundTo: (n: number, round: number) => number;
566
559
  * ```
567
560
  */
568
561
  declare const pathToAbsolute: <T extends PathArray>(pathInput: string | T) => AbsoluteArray;
569
- //#endregion
570
- //#region src/convert/pathToRelative.d.ts
571
562
  /**
572
563
  * Parses a path string value or object and returns an array
573
564
  * of segments, all converted to relative values.
@@ -582,8 +573,6 @@ declare const pathToAbsolute: <T extends PathArray>(pathInput: string | T) => Ab
582
573
  * ```
583
574
  */
584
575
  declare const pathToRelative: <T extends PathArray>(pathInput: string | T) => RelativeArray;
585
- //#endregion
586
- //#region src/convert/pathToCurve.d.ts
587
576
  /**
588
577
  * Parses a path string or PathArray and returns a new one
589
578
  * in which all segments are converted to cubic-bezier.
@@ -598,8 +587,6 @@ declare const pathToRelative: <T extends PathArray>(pathInput: string | T) => Re
598
587
  * ```
599
588
  */
600
589
  declare const pathToCurve: <T extends PathArray>(pathInput: string | T) => CurveArray;
601
- //#endregion
602
- //#region src/convert/pathToString.d.ts
603
590
  /**
604
591
  * Returns a valid `d` attribute string value created
605
592
  * by rounding values and concatenating the PathArray segments.
@@ -615,14 +602,13 @@ declare const pathToCurve: <T extends PathArray>(pathInput: string | T) => Curve
615
602
  * ```
616
603
  */
617
604
  declare const pathToString: <T extends PathArray>(path: T, roundOption?: number | "off") => string;
618
- //#endregion
619
- //#region src/parser/parsePathString.d.ts
620
605
  /**
621
606
  * Parses a path string value and returns an array
622
607
  * of segments we like to call `PathArray`.
623
608
  *
624
609
  * If parameter value is already a `PathArray`,
625
610
  * return a clone of it.
611
+
626
612
  * @example
627
613
  * parsePathString("M 0 0L50 50")
628
614
  * // => [["M",0,0],["L",50,50]]
@@ -631,8 +617,6 @@ declare const pathToString: <T extends PathArray>(path: T, roundOption?: number
631
617
  * @returns the resulted `pathArray` or error string
632
618
  */
633
619
  declare const parsePathString: <T extends PathArray>(pathInput: string | T) => PathArray;
634
- //#endregion
635
- //#region src/parser/pathParser.d.ts
636
620
  /**
637
621
  * The `PathParser` is used by the `parsePathString` static method
638
622
  * to generate a `pathArray`.
@@ -650,16 +634,12 @@ declare class PathParser {
650
634
  err: string;
651
635
  constructor(pathString: string);
652
636
  }
653
- //#endregion
654
- //#region src/parser/finalizeSegment.d.ts
655
637
  /**
656
638
  * Breaks the parsing of a pathString once a segment is finalized.
657
639
  *
658
640
  * @param path - The PathParser instance
659
641
  */
660
642
  declare const finalizeSegment: (path: PathParser) => void;
661
- //#endregion
662
- //#region src/parser/isArcCommand.d.ts
663
643
  /**
664
644
  * Checks if the character is an A (arc-to) path command.
665
645
  *
@@ -667,8 +647,6 @@ declare const finalizeSegment: (path: PathParser) => void;
667
647
  * @returns check result
668
648
  */
669
649
  declare const isArcCommand: (code: number) => code is 97;
670
- //#endregion
671
- //#region src/parser/isDigit.d.ts
672
650
  /**
673
651
  * Checks if a character is a digit.
674
652
  *
@@ -676,8 +654,6 @@ declare const isArcCommand: (code: number) => code is 97;
676
654
  * @returns check result
677
655
  */
678
656
  declare const isDigit: (code: number) => code is DigitNumber;
679
- //#endregion
680
- //#region src/parser/isDigitStart.d.ts
681
657
  /**
682
658
  * Checks if the character is or belongs to a number.
683
659
  * [0-9]|+|-|.
@@ -686,8 +662,6 @@ declare const isDigit: (code: number) => code is DigitNumber;
686
662
  * @returns check result
687
663
  */
688
664
  declare const isDigitStart: (code: number) => code is DigitNumber | 43 | 45 | 46;
689
- //#endregion
690
- //#region src/parser/isMoveCommand.d.ts
691
665
  /**
692
666
  * Checks if the character is a MoveTo command.
693
667
  *
@@ -695,8 +669,6 @@ declare const isDigitStart: (code: number) => code is DigitNumber | 43 | 45 | 46
695
669
  * @returns check result
696
670
  */
697
671
  declare const isMoveCommand: (code: number) => code is 109 | 77;
698
- //#endregion
699
- //#region src/parser/isPathCommand.d.ts
700
672
  /**
701
673
  * Checks if the character is a path command.
702
674
  *
@@ -704,8 +676,6 @@ declare const isMoveCommand: (code: number) => code is 109 | 77;
704
676
  * @returns check result
705
677
  */
706
678
  declare const isPathCommand: (code: number) => code is PathCommandNumber;
707
- //#endregion
708
- //#region src/parser/isSpace.d.ts
709
679
  /**
710
680
  * Checks if the character is a space.
711
681
  *
@@ -713,8 +683,6 @@ declare const isPathCommand: (code: number) => code is PathCommandNumber;
713
683
  * @returns check result
714
684
  */
715
685
  declare const isSpace: (ch: number) => ch is SpaceNumber;
716
- //#endregion
717
- //#region src/parser/scanFlag.d.ts
718
686
  /**
719
687
  * Validates an A (arc-to) specific path command value.
720
688
  * Usually a `large-arc-flag` or `sweep-flag`.
@@ -722,8 +690,6 @@ declare const isSpace: (ch: number) => ch is SpaceNumber;
722
690
  * @param path - The PathParser instance
723
691
  */
724
692
  declare const scanFlag: (path: PathParser) => void;
725
- //#endregion
726
- //#region src/parser/scanParam.d.ts
727
693
  /**
728
694
  * Validates every character of the path string,
729
695
  * every path command, negative numbers or floating point numbers.
@@ -731,8 +697,6 @@ declare const scanFlag: (path: PathParser) => void;
731
697
  * @param path - The PathParser instance
732
698
  */
733
699
  declare const scanParam: (path: PathParser) => void;
734
- //#endregion
735
- //#region src/parser/scanSegment.d.ts
736
700
  /**
737
701
  * Scans every character in the path string to determine
738
702
  * where a segment starts and where it ends.
@@ -740,8 +704,6 @@ declare const scanParam: (path: PathParser) => void;
740
704
  * @param path - The PathParser instance
741
705
  */
742
706
  declare const scanSegment: (path: PathParser) => void;
743
- //#endregion
744
- //#region src/parser/skipSpaces.d.ts
745
707
  /**
746
708
  * Points the parser to the next character in the
747
709
  * path string every time it encounters any kind of
@@ -750,8 +712,6 @@ declare const scanSegment: (path: PathParser) => void;
750
712
  * @param path - The PathParser instance
751
713
  */
752
714
  declare const skipSpaces: (path: PathParser) => void;
753
- //#endregion
754
- //#region src/util/getPathBBox.d.ts
755
715
  /**
756
716
  * Calculates the bounding box of a path.
757
717
  *
@@ -775,8 +735,6 @@ declare const getPathBBox: <T extends PathArray>(pathInput: T | string) => {
775
735
  cy: number;
776
736
  cz: number;
777
737
  };
778
- //#endregion
779
- //#region src/util/getTotalLength.d.ts
780
738
  /**
781
739
  * Returns the total length of a path, equivalent to `shape.getTotalLength()`.
782
740
  *
@@ -790,8 +748,6 @@ declare const getPathBBox: <T extends PathArray>(pathInput: T | string) => {
790
748
  * ```
791
749
  */
792
750
  declare const getTotalLength: <T extends PathArray>(pathInput: string | T) => number;
793
- //#endregion
794
- //#region src/util/getClosestPoint.d.ts
795
751
  /**
796
752
  * Returns the point in path closest to a given point.
797
753
  *
@@ -806,8 +762,6 @@ declare const getClosestPoint: (pathInput: string | PathArray, point: {
806
762
  x: number;
807
763
  y: number;
808
764
  };
809
- //#endregion
810
- //#region src/util/getDrawDirection.d.ts
811
765
  /**
812
766
  * Check if a path is drawn clockwise and returns true if so,
813
767
  * false otherwise.
@@ -816,8 +770,6 @@ declare const getClosestPoint: (pathInput: string | PathArray, point: {
816
770
  * @returns true when clockwise or false if not
817
771
  */
818
772
  declare const getDrawDirection: (path: string | PathArray) => boolean;
819
- //#endregion
820
- //#region src/util/getPathArea.d.ts
821
773
  /**
822
774
  * Returns the signed area of a shape.
823
775
  *
@@ -835,8 +787,6 @@ declare const getDrawDirection: (path: string | PathArray) => boolean;
835
787
  * ```
836
788
  */
837
789
  declare const getPathArea: <T extends PathArray | string>(path: T) => number;
838
- //#endregion
839
- //#region src/util/getPointAtLength.d.ts
840
790
  /**
841
791
  * Returns [x,y] coordinates of a point at a given length along a path.
842
792
  *
@@ -854,8 +804,6 @@ declare const getPointAtLength: <T extends PathArray>(pathInput: string | T, dis
854
804
  x: number;
855
805
  y: number;
856
806
  };
857
- //#endregion
858
- //#region src/util/getPropertiesAtLength.d.ts
859
807
  /**
860
808
  * Returns the segment, its index and length as well as
861
809
  * the length to that segment at a given length in a path.
@@ -865,8 +813,6 @@ declare const getPointAtLength: <T extends PathArray>(pathInput: string | T, dis
865
813
  * @returns the requested properties
866
814
  */
867
815
  declare const getPropertiesAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => SegmentProperties;
868
- //#endregion
869
- //#region src/util/getPropertiesAtPoint.d.ts
870
816
  /**
871
817
  * Returns the point and segment in path closest to a given point as well as
872
818
  * the distance to the path stroke.
@@ -878,8 +824,6 @@ declare const getPropertiesAtLength: <T extends PathArray>(pathInput: string | T
878
824
  * @returns the requested properties
879
825
  */
880
826
  declare const getPropertiesAtPoint: <T extends PathArray>(pathInput: string | T, point: Point) => PointProperties;
881
- //#endregion
882
- //#region src/util/getSegmentAtLength.d.ts
883
827
  /**
884
828
  * Returns the segment at a given length.
885
829
  *
@@ -888,8 +832,6 @@ declare const getPropertiesAtPoint: <T extends PathArray>(pathInput: string | T,
888
832
  * @returns the requested segment
889
833
  */
890
834
  declare const getSegmentAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => PathSegment | undefined;
891
- //#endregion
892
- //#region src/util/getSegmentOfPoint.d.ts
893
835
  /**
894
836
  * Returns the path segment which contains a given point.
895
837
  *
@@ -901,8 +843,6 @@ declare const getSegmentOfPoint: <T extends PathArray>(path: string | T, point:
901
843
  x: number;
902
844
  y: number;
903
845
  }) => SegmentProperties | undefined;
904
- //#endregion
905
- //#region src/util/isAbsoluteArray.d.ts
906
846
  /**
907
847
  * Iterates an array to check if it's a `pathArray`
908
848
  * with all absolute values.
@@ -911,16 +851,12 @@ declare const getSegmentOfPoint: <T extends PathArray>(path: string | T, point:
911
851
  * @returns iteration result
912
852
  */
913
853
  declare const isAbsoluteArray: (path: unknown) => path is AbsoluteArray;
914
- //#endregion
915
- //#region src/util/isPolygonArray.d.ts
916
854
  /**
917
855
  * Checks if a path is a polygon (only M, L, H, V, Z commands).
918
856
  * @param pathArray PathArray (pre-normalize if needed)
919
857
  * @returns boolean
920
858
  */
921
859
  declare const isPolygonArray: (path: PathArray) => path is PolygonArray;
922
- //#endregion
923
- //#region src/util/isCurveArray.d.ts
924
860
  /**
925
861
  * Iterates an array to check if it's a `pathArray`
926
862
  * with all C (cubic bezier) segments.
@@ -929,8 +865,6 @@ declare const isPolygonArray: (path: PathArray) => path is PolygonArray;
929
865
  * @returns iteration result
930
866
  */
931
867
  declare const isCurveArray: (path: unknown) => path is CurveArray;
932
- //#endregion
933
- //#region src/util/isNormalizedArray.d.ts
934
868
  /**
935
869
  * Iterates an array to check if it's a `pathArray`
936
870
  * with all segments in non-shorthand notation
@@ -940,8 +874,6 @@ declare const isCurveArray: (path: unknown) => path is CurveArray;
940
874
  * @returns true if the array is a normalized path array
941
875
  */
942
876
  declare const isNormalizedArray: (path: unknown) => path is NormalArray;
943
- //#endregion
944
- //#region src/util/isPathArray.d.ts
945
877
  /**
946
878
  * Iterates an array to check if it's an actual `pathArray`.
947
879
  *
@@ -949,8 +881,6 @@ declare const isNormalizedArray: (path: unknown) => path is NormalArray;
949
881
  * @returns iteration result
950
882
  */
951
883
  declare const isPathArray: (path: unknown) => path is PathArray;
952
- //#endregion
953
- //#region src/util/isPointInStroke.d.ts
954
884
  /**
955
885
  * Checks if a given point is in the stroke of a path.
956
886
  *
@@ -962,8 +892,6 @@ declare const isPointInStroke: <T extends PathArray>(pathInput: string | T, poin
962
892
  x: number;
963
893
  y: number;
964
894
  }) => boolean;
965
- //#endregion
966
- //#region src/util/isRelativeArray.d.ts
967
895
  /**
968
896
  * Iterates an array to check if it's a `pathArray`
969
897
  * with relative values.
@@ -972,8 +900,6 @@ declare const isPointInStroke: <T extends PathArray>(pathInput: string | T, poin
972
900
  * @returns iteration result
973
901
  */
974
902
  declare const isRelativeArray: (path: unknown) => path is RelativeArray;
975
- //#endregion
976
- //#region src/util/isValidPath.d.ts
977
903
  /**
978
904
  * Parses a path string value to determine its validity
979
905
  * then returns true if it's valid or false otherwise.
@@ -982,8 +908,6 @@ declare const isRelativeArray: (path: unknown) => path is RelativeArray;
982
908
  * @returns the path string validity
983
909
  */
984
910
  declare const isValidPath: (pathString: string) => boolean;
985
- //#endregion
986
- //#region src/morph/samplePolygon.d.ts
987
911
  /**
988
912
  * Samples points from a path to form a polygon approximation.
989
913
  * Collects endpoints of each segment (M start + ends of L/C/etc).
@@ -994,8 +918,6 @@ declare const isValidPath: (pathString: string) => boolean;
994
918
  * @returns Array of [x, y] points
995
919
  */
996
920
  declare function samplePolygon<T extends NormalArray>(path: T): PointTuple[];
997
- //#endregion
998
- //#region src/util/shapeToPath.d.ts
999
921
  /**
1000
922
  * Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`,
1001
923
  * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>` or `<glyph>`. If `replace` parameter
@@ -1026,8 +948,6 @@ declare function samplePolygon<T extends NormalArray>(path: T): PointTuple[];
1026
948
  * ```
1027
949
  */
1028
950
  declare const shapeToPath: (element: ShapeTypes | ShapeOps, replace?: boolean, ownerDocument?: Document) => SVGPathElement | false;
1029
- //#endregion
1030
- //#region src/util/shapeToPathArray.d.ts
1031
951
  /**
1032
952
  * Returns a new `pathArray` created from attributes of a `<line>`, `<polyline>`,
1033
953
  * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>`, <path> or `<glyph>`.
@@ -1039,8 +959,6 @@ declare const shapeToPath: (element: ShapeTypes | ShapeOps, replace?: boolean, o
1039
959
  * @returns the newly created `<path>` element
1040
960
  */
1041
961
  declare const shapeToPathArray: (element: ShapeTypes | ShapeOps) => false | PathArray;
1042
- //#endregion
1043
- //#region src/util/isMultiPath.d.ts
1044
962
  /**
1045
963
  * Determines if an SVG path contains multiple subpaths.
1046
964
  * Accepts path string or PathArray.
@@ -1048,24 +966,18 @@ declare const shapeToPathArray: (element: ShapeTypes | ShapeOps) => false | Path
1048
966
  * @returns boolean
1049
967
  */
1050
968
  declare const isMultiPath: <T extends PathArray>(path: string | T) => boolean;
1051
- //#endregion
1052
- //#region src/util/isPolylineArray.d.ts
1053
969
  /**
1054
970
  * Checks if a path is a polyline (only M, L, H, V commands).
1055
971
  * @param pathArray PathArray (pre-normalize if needed)
1056
972
  * @returns boolean
1057
973
  */
1058
974
  declare function isPolylineArray(path: PathArray): path is PolylineArray;
1059
- //#endregion
1060
- //#region src/util/isClosedPath.d.ts
1061
975
  /**
1062
976
  * Check if a PathArray is closed, which means its last segment is a Z.
1063
977
  * @param path
1064
978
  * @returns true if the path is closed
1065
979
  */
1066
980
  declare const isClosedPath: <T extends PathArray>(path: T) => boolean;
1067
- //#endregion
1068
- //#region src/process/normalizePath.d.ts
1069
981
  /**
1070
982
  * Parses a path string or PathArray, then iterates the result for:
1071
983
  * * converting segments to absolute values
@@ -1081,8 +993,6 @@ declare const isClosedPath: <T extends PathArray>(path: T) => boolean;
1081
993
  * ```
1082
994
  */
1083
995
  declare const normalizePath: <T extends string | PathArray>(pathInput: T) => NormalArray;
1084
- //#endregion
1085
- //#region src/process/optimizePath.d.ts
1086
996
  /**
1087
997
  * Optimizes a PathArray:
1088
998
  * * converts segments to shorthand if possible
@@ -1099,8 +1009,6 @@ declare const normalizePath: <T extends string | PathArray>(pathInput: T) => Nor
1099
1009
  * ```
1100
1010
  */
1101
1011
  declare const optimizePath: <T extends string | PathArray>(pathInput: T, roundOption?: number) => PathArray;
1102
- //#endregion
1103
- //#region src/process/reversePath.d.ts
1104
1012
  /**
1105
1013
  * Reverses all segments of a PathArray and returns a new PathArray
1106
1014
  * with absolute values.
@@ -1114,9 +1022,7 @@ declare const optimizePath: <T extends string | PathArray>(pathInput: T, roundOp
1114
1022
  * // => [['M', 0, 100], ['L', 0, 0], ['L', 100, 0], ['L', 100, 100], ['Z']]
1115
1023
  * ```
1116
1024
  */
1117
- declare const reversePath: <T extends PathArray>(pathInput: T) => T;
1118
- //#endregion
1119
- //#region src/process/splitPath.d.ts
1025
+ declare const reversePath: <T extends PathArray>(pathInput: T | string) => T;
1120
1026
  /**
1121
1027
  * Split a path string or PathArray into an array of sub-paths.
1122
1028
  *
@@ -1136,8 +1042,6 @@ declare const reversePath: <T extends PathArray>(pathInput: T) => T;
1136
1042
  * ```
1137
1043
  */
1138
1044
  declare const splitPath: <T extends PathArray>(pathInput: T | string) => T[];
1139
- //#endregion
1140
- //#region src/process/transformPath.d.ts
1141
1045
  /**
1142
1046
  * Apply a 2D / 3D transformation to a PathArray.
1143
1047
  *
@@ -1155,8 +1059,6 @@ declare const splitPath: <T extends PathArray>(pathInput: T | string) => T[];
1155
1059
  * ```
1156
1060
  */
1157
1061
  declare const transformPath: <T extends PathArray>(pathInput: T | string, transform?: Partial<TransformObject>) => T | AbsoluteArray;
1158
- //#endregion
1159
- //#region src/process/absolutizeSegment.d.ts
1160
1062
  /**
1161
1063
  * Returns an absolute segment of a `PathArray` object.
1162
1064
  *
@@ -1167,8 +1069,6 @@ declare const transformPath: <T extends PathArray>(pathInput: T | string, transf
1167
1069
  * @returns the absolute segment
1168
1070
  */
1169
1071
  declare const absolutizeSegment: (segment: PathSegment, index: number, lastX: number, lastY: number) => AbsoluteSegment;
1170
- //#endregion
1171
- //#region src/process/arcToCubic.d.ts
1172
1072
  /**
1173
1073
  * Converts A (arc-to) segments to C (cubic-bezier-to).
1174
1074
  *
@@ -1188,8 +1088,6 @@ declare const absolutizeSegment: (segment: PathSegment, index: number, lastX: nu
1188
1088
  * @returns the resulting cubic-bezier segment(s)
1189
1089
  */
1190
1090
  declare const arcToCubic: (X1: number, Y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, X2: number, Y2: number, recursive?: [number, number, number, number]) => number[];
1191
- //#endregion
1192
- //#region src/process/getSVGMatrix.d.ts
1193
1091
  /**
1194
1092
  * Returns a transformation matrix to apply to `<path>` elements.
1195
1093
  *
@@ -1199,8 +1097,6 @@ declare const arcToCubic: (X1: number, Y1: number, RX: number, RY: number, angle
1199
1097
  * @returns a new transformation matrix
1200
1098
  */
1201
1099
  declare const getSVGMatrix: (transform: TransformObjectValues) => CSSMatrix;
1202
- //#endregion
1203
- //#region src/process/iterate.d.ts
1204
1100
  /**
1205
1101
  * Iterates over a `PathArray`, executing a callback for each segment.
1206
1102
  * The callback can:
@@ -1229,8 +1125,6 @@ declare const getSVGMatrix: (transform: TransformObjectValues) => CSSMatrix;
1229
1125
  * });
1230
1126
  */
1231
1127
  declare const iterate: <T extends PathArray>(path: T, iterator: IteratorCallback<T>) => T;
1232
- //#endregion
1233
- //#region src/process/lineToCubic.d.ts
1234
1128
  /**
1235
1129
  * Converts an L (line-to) segment to C (cubic-bezier).
1236
1130
  *
@@ -1241,18 +1135,15 @@ declare const iterate: <T extends PathArray>(path: T, iterator: IteratorCallback
1241
1135
  * @returns the cubic-bezier segment
1242
1136
  */
1243
1137
  declare const lineToCubic: (x1: number, y1: number, x2: number, y2: number) => number[];
1244
- //#endregion
1245
- //#region src/process/normalizeSegment.d.ts
1246
1138
  /**
1247
1139
  * Normalizes a single segment of a `pathArray` object.
1248
1140
  *
1249
1141
  * @param segment the segment object
1250
1142
  * @param params the normalization parameters
1143
+ * @param prevCommand the command of the previous segment
1251
1144
  * @returns the normalized segment
1252
1145
  */
1253
- declare const normalizeSegment: (segment: PathSegment, params: ParserParams) => NormalSegment;
1254
- //#endregion
1255
- //#region src/process/projection2d.d.ts
1146
+ declare const normalizeSegment: (segment: PathSegment, params: ParserParams, prevCommand?: PathCommand | null) => NormalSegment;
1256
1147
  /**
1257
1148
  * Returns the [x,y] projected coordinates for a given an [x,y] point
1258
1149
  * and an [x,y,z] perspective origin point.
@@ -1268,8 +1159,6 @@ declare const normalizeSegment: (segment: PathSegment, params: ParserParams) =>
1268
1159
  * @returns the projected [x,y] coordinates
1269
1160
  */
1270
1161
  declare const projection2d: (m: CSSMatrix, point2D: PointTuple, origin: [number, number, number]) => PointTuple;
1271
- //#endregion
1272
- //#region src/process/quadToCubic.d.ts
1273
1162
  /**
1274
1163
  * Converts a Q (quadratic-bezier) segment to C (cubic-bezier).
1275
1164
  *
@@ -1282,8 +1171,6 @@ declare const projection2d: (m: CSSMatrix, point2D: PointTuple, origin: [number,
1282
1171
  * @returns the cubic-bezier segment
1283
1172
  */
1284
1173
  declare const quadToCubic: (x1: number, y1: number, qx: number, qy: number, x2: number, y2: number) => [number, number, number, number, number, number];
1285
- //#endregion
1286
- //#region src/process/relativizeSegment.d.ts
1287
1174
  /**
1288
1175
  * Returns a relative segment of a `PathArray` object.
1289
1176
  *
@@ -1294,8 +1181,6 @@ declare const quadToCubic: (x1: number, y1: number, qx: number, qy: number, x2:
1294
1181
  * @returns the relative segment
1295
1182
  */
1296
1183
  declare const relativizeSegment: (segment: PathSegment, index: number, lastX: number, lastY: number) => MSegment | RelativeSegment;
1297
- //#endregion
1298
- //#region src/process/reverseCurve.d.ts
1299
1184
  /**
1300
1185
  * Reverses all segments of a `pathArray`
1301
1186
  * which consists of only C (cubic-bezier) path commands.
@@ -1304,8 +1189,6 @@ declare const relativizeSegment: (segment: PathSegment, index: number, lastX: nu
1304
1189
  * @returns the reversed `pathArray`
1305
1190
  */
1306
1191
  declare const reverseCurve: (path: CurveArray) => CurveArray;
1307
- //#endregion
1308
- //#region src/process/roundPath.d.ts
1309
1192
  /**
1310
1193
  * Rounds the values of a `pathArray` instance to
1311
1194
  * a specified amount of decimals and returns it.
@@ -1315,8 +1198,6 @@ declare const reverseCurve: (path: CurveArray) => CurveArray;
1315
1198
  * @returns the resulted `pathArray` with rounded values
1316
1199
  */
1317
1200
  declare const roundPath: <T extends PathArray>(path: T, roundOption?: number | "off") => T;
1318
- //#endregion
1319
- //#region src/process/roundSegment.d.ts
1320
1201
  /**
1321
1202
  * Rounds the numeric values of a path segment to the specified precision.
1322
1203
  *
@@ -1325,8 +1206,6 @@ declare const roundPath: <T extends PathArray>(path: T, roundOption?: number | "
1325
1206
  * @returns The rounded segment
1326
1207
  */
1327
1208
  declare const roundSegment: <T extends PathSegment>(segment: T, roundOption: number) => T;
1328
- //#endregion
1329
- //#region src/process/segmentToCubic.d.ts
1330
1209
  /**
1331
1210
  * Converts any segment to C (cubic-bezier).
1332
1211
  *
@@ -1335,8 +1214,6 @@ declare const roundSegment: <T extends PathSegment>(segment: T, roundOption: num
1335
1214
  * @returns the cubic-bezier segment
1336
1215
  */
1337
1216
  declare const segmentToCubic: (segment: PathSegment, params: ParserParams) => MSegment | CSegment;
1338
- //#endregion
1339
- //#region src/process/shortenSegment.d.ts
1340
1217
  /**
1341
1218
  * Shorten a single segment of a `pathArray` object.
1342
1219
  *
@@ -1347,8 +1224,6 @@ declare const segmentToCubic: (segment: PathSegment, params: ParserParams) => MS
1347
1224
  * @returns the shortened segment
1348
1225
  */
1349
1226
  declare const shortenSegment: (segment: AbsoluteSegment, normalSegment: NormalSegment, params: ParserParams, prevCommand: PathCommand) => ShortSegment;
1350
- //#endregion
1351
- //#region src/morph/fixPath.d.ts
1352
1227
  /**
1353
1228
  * Checks a `PathArray` for an unnecessary `Z` segment
1354
1229
  * and removes it. The `PathArray` is modified in place.
@@ -1364,8 +1239,6 @@ declare const shortenSegment: (segment: AbsoluteSegment, normalSegment: NormalSe
1364
1239
  * @returns void
1365
1240
  */
1366
1241
  declare const fixPath: <T extends PathArray>(pathInput: T | string) => void;
1367
- //#endregion
1368
- //#region src/morph/splitCubicSegment.d.ts
1369
1242
  /**
1370
1243
  * Split a cubic Bézier into two cubics at parameter t [0–1].
1371
1244
  *
@@ -1381,8 +1254,6 @@ declare const fixPath: <T extends PathArray>(pathInput: T | string) => void;
1381
1254
  * @returns Array of two cubic segments, each as [x1,y1, x2,y2, x3,y3, x4,y4]
1382
1255
  */
1383
1256
  declare function splitCubicSegment(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): [CubicCoordinates, CubicCoordinates];
1384
- //#endregion
1385
- //#region src/morph/equalizeSegments.d.ts
1386
1257
  /**
1387
1258
  * Equalizes two paths for morphing (single subpath only).
1388
1259
  *
@@ -1399,8 +1270,6 @@ declare function splitCubicSegment(x1: number, y1: number, x2: number, y2: numbe
1399
1270
  * ```
1400
1271
  */
1401
1272
  declare const equalizeSegments: (path1: PathArray | string, path2: PathArray | string, initialCfg?: EqualizationOptions) => [MorphPathArray, MorphPathArray];
1402
- //#endregion
1403
- //#region src/morph/equalizePaths.d.ts
1404
1273
  /**
1405
1274
  * Equalizes two paths for morphing (single/multi subpath).
1406
1275
  *
@@ -1417,8 +1286,6 @@ declare const equalizeSegments: (path1: PathArray | string, path2: PathArray | s
1417
1286
  * ```
1418
1287
  */
1419
1288
  declare const equalizePaths: (pathInput1: string | PathArray, pathInput2: string | PathArray, initialCfg?: {}) => [MorphPathArray, MorphPathArray];
1420
- //#endregion
1421
- //#region src/intersect/pathIntersection.d.ts
1422
1289
  /**
1423
1290
  * Finds intersection points between two paths.
1424
1291
  *
@@ -1436,8 +1303,6 @@ declare const equalizePaths: (pathInput1: string | PathArray, pathInput2: string
1436
1303
  * ```
1437
1304
  */
1438
1305
  declare const pathsIntersection: <T extends string | PathArray>(pathInput1: T, pathInput2: T, justCount?: boolean) => number | IntersectionPoint[];
1439
- //#endregion
1440
- //#region src/intersect/boundingBoxIntersect.d.ts
1441
1306
  /**
1442
1307
  * Checks if two bounding boxes intersect.
1443
1308
  *
@@ -1446,8 +1311,6 @@ declare const pathsIntersection: <T extends string | PathArray>(pathInput1: T, p
1446
1311
  * @returns True if the bounding boxes overlap
1447
1312
  */
1448
1313
  declare const boundingBoxIntersect: (a: BBoxMaxima, b: BBoxMaxima) => boolean;
1449
- //#endregion
1450
- //#region src/intersect/isPointInsideBBox.d.ts
1451
1314
  /**
1452
1315
  * Checks if a point is inside a bounding box.
1453
1316
  *
@@ -1456,8 +1319,6 @@ declare const boundingBoxIntersect: (a: BBoxMaxima, b: BBoxMaxima) => boolean;
1456
1319
  * @returns True if the point is inside or on the edge of the bounding box
1457
1320
  */
1458
1321
  declare const isPointInsideBBox: (bbox: BBoxMaxima, [x, y]: PointTuple) => boolean;
1459
- //#endregion
1460
- //#region src/main.d.ts
1461
1322
  /**
1462
1323
  * Creates a new SVGPathCommander instance with the following properties:
1463
1324
  * * segments: `pathArray`
@@ -1468,7 +1329,7 @@ declare const isPointInsideBBox: (bbox: BBoxMaxima, [x, y]: PointTuple) => boole
1468
1329
  * @author thednp <https://github.com/thednp/svg-path-commander>
1469
1330
  * @returns a new SVGPathCommander instance
1470
1331
  */
1471
- declare class SVGPathCommander {
1332
+ export declare class SVGPathCommander {
1472
1333
  /** The parsed PathArray stored on the instance. */
1473
1334
  segments: PathArray;
1474
1335
  /** The rounding option used for the output path string. */
@@ -1933,6 +1794,5 @@ declare class SVGPathCommander {
1933
1794
  /** The library version. */
1934
1795
  static version: string;
1935
1796
  }
1936
- //#endregion
1937
- export { ACommand, ASegment, AbsoluteArray, AbsoluteCommand, AbsoluteSegment, ArcCoordinates, ArcSegment, BBoxMaxima, CCommand, CSegment, CircleAttr, CloseSegment, ClosedCurveArray, CubicCoordinates, CubicPoints, CubicSegment, CurveArray, DeriveCallback, DerivedCubicPoints, DerivedPoint, DerivedQuadPoints, DigitNumber, EllipseAttr, EqualizationOptions, GlyphAttr, HCommand, HSegment, HorLineSegment, IntersectionOptions, IntersectionPoint, IteratorCallback, LCommand, LSegment, LengthFactory, LineAttr, LineCoordinates, LineSegment, MCommand, MSegment, MorphPathArray, MoveSegment, NormalArray, NormalSegment, Options, ParserParams, PathArray, PathBBox, PathCommand, PathCommandNumber, PathEqualizationOptions, PathFeature, PathSegment, PathTransform, PathsEqualizationOptions, Point, PointAtLength, PointProperties, PointTuple, PolyAttr, PolygonArray, PolylineArray, QCommand, QSegment, QuadCoordinates, QuadPoints, QuadSegment, RectAttr, RelativeArray, RelativeCommand, RelativeSegment, SCommand, SSegment, SVGPathCommander, SVGPathCommander as default, SegmentLimits, SegmentProperties, ShapeOps, ShapeParams, ShapeTags, ShapeTypes, ShortCubicSegment, ShortQuadSegment, ShortSegment, SpaceNumber, TCommand, TSegment, TransformEntries, TransformObject, TransformObjectValues, TransformProps, VCommand, VSegment, VertLineSegment, ZCommand, ZSegment, aCommand, aSegment, cCommand, cSegment, hCommand, hSegment, lCommand, lSegment, mCommand, mSegment, qCommand, qSegment, sCommand, sSegment, tCommand, tSegment, vCommand, vSegment, zCommand, zSegment };
1797
+ export { SVGPathCommander as default };
1938
1798
  //# sourceMappingURL=index.d.ts.map