svg-path-commander 2.1.11 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/util.d.ts ADDED
@@ -0,0 +1,1261 @@
1
+ /*!
2
+ * SVGPathCommander v2.2.0 (http://thednp.github.io/svg-path-commander)
3
+ * Copyright 2026 © thednp
4
+ * Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
5
+ */
6
+ //#region src/interface.d.ts
7
+ type SegmentProperties = {
8
+ segment: PathSegment;
9
+ index: number;
10
+ length: number;
11
+ lengthAtSegment: number;
12
+ };
13
+ type PointProperties = {
14
+ closest: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ distance: number;
19
+ segment?: SegmentProperties;
20
+ };
21
+ type LineAttr = {
22
+ type: "line";
23
+ x1: number;
24
+ y1: number;
25
+ x2: number;
26
+ y2: number;
27
+ [key: string]: string | number;
28
+ };
29
+ type PolyAttr = {
30
+ type: "polygon" | "polyline";
31
+ points: string;
32
+ [key: string]: string | number;
33
+ };
34
+ type CircleAttr = {
35
+ type: "circle";
36
+ cx: number;
37
+ cy: number;
38
+ r: number;
39
+ [key: string]: string | number;
40
+ };
41
+ type EllipseAttr = {
42
+ type: "ellipse";
43
+ cx: number;
44
+ cy: number;
45
+ rx: number;
46
+ ry?: number;
47
+ [key: string]: string | number | undefined;
48
+ };
49
+ type RectAttr = {
50
+ type: "rect";
51
+ width: number;
52
+ height: number;
53
+ x: number;
54
+ y: number;
55
+ rx?: number;
56
+ ry?: number;
57
+ [key: string]: string | number | undefined;
58
+ };
59
+ type GlyphAttr = {
60
+ type: "glyph";
61
+ d: string;
62
+ [key: string]: string | number;
63
+ };
64
+ type ShapeParams = {
65
+ line: ["x1", "y1", "x2", "y2"];
66
+ circle: ["cx", "cy", "r"];
67
+ ellipse: ["cx", "cy", "rx", "ry"];
68
+ rect: ["width", "height", "x", "y", "rx", "ry"];
69
+ polygon: ["points"];
70
+ polyline: ["points"];
71
+ glyph: ["d"];
72
+ };
73
+ type ParserParams = {
74
+ mx: number;
75
+ my: number;
76
+ x1: number;
77
+ y1: number;
78
+ x2: number;
79
+ y2: number;
80
+ x: number;
81
+ y: number;
82
+ qx: number | null;
83
+ qy: number | null;
84
+ };
85
+ type TransformObject = {
86
+ translate: number | number[];
87
+ rotate: number | number[];
88
+ scale: number | number[];
89
+ skew: number | number[];
90
+ origin: number[];
91
+ };
92
+ //#endregion
93
+ //#region src/types.d.ts
94
+ 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;
95
+ type PathCommandNumber = 0x6d | 0x7a | 0x6c | 0x68 | 0x76 | 0x63 | 0x73 | 0x71 | 0x74 | 0x61;
96
+ type DigitNumber = 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39;
97
+ type MCommand = "M";
98
+ type mCommand = "m";
99
+ type LCommand = "L";
100
+ type lCommand = "l";
101
+ type VCommand = "V";
102
+ type vCommand = "v";
103
+ type HCommand = "H";
104
+ type hCommand = "h";
105
+ type ZCommand = "Z";
106
+ type zCommand = "z";
107
+ type CCommand = "C";
108
+ type cCommand = "c";
109
+ type SCommand = "S";
110
+ type sCommand = "s";
111
+ type QCommand = "Q";
112
+ type qCommand = "q";
113
+ type TCommand = "T";
114
+ type tCommand = "t";
115
+ type ACommand = "A";
116
+ type aCommand = "a";
117
+ type AbsoluteCommand = MCommand | LCommand | VCommand | HCommand | ZCommand | CCommand | SCommand | QCommand | TCommand | ACommand;
118
+ type RelativeCommand = mCommand | lCommand | vCommand | hCommand | zCommand | cCommand | sCommand | qCommand | tCommand | aCommand;
119
+ type PathCommand = AbsoluteCommand | RelativeCommand;
120
+ type MSegment = [MCommand, number, number];
121
+ type mSegment = [mCommand, number, number];
122
+ type MoveSegment = MSegment | mSegment;
123
+ type LSegment = [LCommand, number, number];
124
+ type lSegment = [lCommand, number, number];
125
+ type LineSegment = LSegment | lSegment;
126
+ type VSegment = [VCommand, number];
127
+ type vSegment = [vCommand, number];
128
+ type VertLineSegment = vSegment | VSegment;
129
+ type HSegment = [HCommand, number];
130
+ type hSegment = [hCommand, number];
131
+ type HorLineSegment = HSegment | hSegment;
132
+ type ZSegment = [ZCommand];
133
+ type zSegment = [zCommand];
134
+ type CloseSegment = ZSegment | zSegment;
135
+ type CSegment = [CCommand, number, number, number, number, number, number];
136
+ type cSegment = [cCommand, number, number, number, number, number, number];
137
+ type CubicSegment = CSegment | cSegment;
138
+ type SSegment = [SCommand, number, number, number, number];
139
+ type sSegment = [sCommand, number, number, number, number];
140
+ type ShortCubicSegment = SSegment | sSegment;
141
+ type QSegment = [QCommand, number, number, number, number];
142
+ type qSegment = [qCommand, number, number, number, number];
143
+ type QuadSegment = QSegment | qSegment;
144
+ type TSegment = [TCommand, number, number];
145
+ type tSegment = [tCommand, number, number];
146
+ type ShortQuadSegment = TSegment | tSegment;
147
+ type ASegment = [ACommand, number, number, number, number, number, number, number];
148
+ type aSegment = [aCommand, number, number, number, number, number, number, number];
149
+ type ArcSegment = ASegment | aSegment;
150
+ type PathSegment = MoveSegment | LineSegment | VertLineSegment | HorLineSegment | CloseSegment | CubicSegment | ShortCubicSegment | QuadSegment | ShortQuadSegment | ArcSegment;
151
+ type ShortSegment = VertLineSegment | HorLineSegment | ShortCubicSegment | ShortQuadSegment | CloseSegment;
152
+ type AbsoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
153
+ type RelativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
154
+ type NormalSegment = MSegment | LSegment | CSegment | QSegment | ASegment | ZSegment;
155
+ type PathArray = [MSegment | mSegment, ...PathSegment[]];
156
+ type AbsoluteArray = [MSegment, ...AbsoluteSegment[]];
157
+ type RelativeArray = [MSegment, ...RelativeSegment[]];
158
+ type NormalArray = [MSegment, ...NormalSegment[]];
159
+ type CurveArray = [MSegment, ...CSegment[]];
160
+ type ClosedCurveArray = [MSegment, ...CSegment[], ZSegment];
161
+ type PolygonArray = [MSegment, ...LSegment[], ZSegment];
162
+ type PolylineArray = [MSegment, ...LSegment[]];
163
+ type MorphPathArray = PolygonArray | PolylineArray | CurveArray | ClosedCurveArray;
164
+ type ShapeTypes = SVGPolylineElement | SVGPolygonElement | SVGLineElement | SVGEllipseElement | SVGCircleElement | SVGRectElement;
165
+ type ShapeOps = LineAttr | PolyAttr | PolyAttr | EllipseAttr | CircleAttr | RectAttr | GlyphAttr;
166
+ type TransformObjectValues = Partial<TransformObject> & {
167
+ origin: [number, number, number];
168
+ };
169
+ type Point = {
170
+ x: number;
171
+ y: number;
172
+ };
173
+ type PointTuple = [number, number];
174
+ type DerivedPoint = Point & {
175
+ t: number;
176
+ };
177
+ type QuadPoints = [Point, Point, Point, Point, Point, Point];
178
+ type CubicPoints = [Point, Point, Point, Point, Point, Point, Point, Point];
179
+ type DerivedQuadPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
180
+ type DerivedCubicPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
181
+ type QuadCoordinates = [number, number, number, number, number, number];
182
+ type CubicCoordinates = [number, number, number, number, number, number, number, number];
183
+ type DeriveCallback = (t: number) => Point;
184
+ 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;
185
+ type BBoxMaxima = [minX: number, minY: number, maxX: number, maxY: number];
186
+ type IntersectionPoint = {
187
+ x: number;
188
+ y: number;
189
+ t1: number;
190
+ t2: number;
191
+ };
192
+ interface EqualizationOptions {
193
+ /** @default "auto" */
194
+ mode?: "curve" | "auto";
195
+ sampleSize?: number;
196
+ roundValues?: number;
197
+ reverse?: boolean;
198
+ close?: boolean;
199
+ target?: number;
200
+ }
201
+ //#endregion
202
+ //#region src/math/arcTools.d.ts
203
+ declare const arcTools: {
204
+ angleBetween: (v0: Point, v1: Point) => number;
205
+ arcLength: (rx: number, ry: number, theta: number) => number;
206
+ arcPoint: (cx: number, cy: number, rx: number, ry: number, alpha: number, theta: number) => PointTuple;
207
+ getArcBBox: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => [number, number, number, number];
208
+ getArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => number;
209
+ getArcProps: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => {
210
+ rx: number;
211
+ ry: number;
212
+ startAngle: number;
213
+ endAngle: number;
214
+ center: {
215
+ x: number;
216
+ y: number;
217
+ };
218
+ };
219
+ getPointAtArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number, distance?: number) => {
220
+ x: number;
221
+ y: number;
222
+ };
223
+ };
224
+ //#endregion
225
+ //#region src/math/bezier.d.ts
226
+ declare const bezierTools: {
227
+ bezierLength: (derivativeFn: DeriveCallback) => number;
228
+ calculateBezier: (derivativeFn: DeriveCallback, t: number) => number;
229
+ CBEZIER_MINMAX_EPSILON: number;
230
+ computeBezier: (points: DerivedQuadPoints | DerivedCubicPoints, t: number) => DerivedPoint;
231
+ Cvalues: number[];
232
+ deriveBezier: (points: QuadPoints | CubicPoints) => (DerivedCubicPoints | DerivedQuadPoints)[];
233
+ getBezierLength: (curve: CubicCoordinates | QuadCoordinates) => number;
234
+ minmaxC: ([v1, cp1, cp2, v2]: [number, number, number, number]) => PointTuple;
235
+ minmaxQ: ([v1, cp, v2]: [number, number, number]) => PointTuple;
236
+ Tvalues: number[];
237
+ };
238
+ //#endregion
239
+ //#region src/math/cubicTools.d.ts
240
+ declare const cubicTools: {
241
+ getCubicBBox: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => BBoxMaxima;
242
+ getCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => number;
243
+ getPointAtCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number, distance?: number) => {
244
+ x: number;
245
+ y: number;
246
+ };
247
+ getPointAtCubicSegmentLength: ([x1, y1, c1x, c1y, c2x, c2y, x2, y2]: CubicCoordinates, t: number) => {
248
+ x: number;
249
+ y: number;
250
+ };
251
+ };
252
+ //#endregion
253
+ //#region src/math/lineTools.d.ts
254
+ declare const lineTools: {
255
+ getLineBBox: (x1: number, y1: number, x2: number, y2: number) => [number, number, number, number];
256
+ getLineLength: (x1: number, y1: number, x2: number, y2: number) => number;
257
+ getPointAtLineLength: (x1: number, y1: number, x2: number, y2: number, distance?: number) => {
258
+ x: number;
259
+ y: number;
260
+ };
261
+ };
262
+ //#endregion
263
+ //#region src/math/quadTools.d.ts
264
+ declare const quadTools: {
265
+ getPointAtQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number, distance?: number) => {
266
+ x: number;
267
+ y: number;
268
+ };
269
+ getPointAtQuadSegmentLength: ([x1, y1, cx, cy, x2, y2]: QuadCoordinates, t: number) => {
270
+ x: number;
271
+ y: number;
272
+ };
273
+ getQuadBBox: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => [number, number, number, number];
274
+ getQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => number;
275
+ };
276
+ //#endregion
277
+ //#region src/math/polygonTools.d.ts
278
+ declare const polygonTools: {
279
+ polygonArea: (polygon: PointTuple[]) => number;
280
+ polygonLength: (polygon: PointTuple[]) => number;
281
+ polygonCentroid: (polygon: PointTuple[]) => PointTuple;
282
+ };
283
+ //#endregion
284
+ //#region src/math/distanceSquareRoot.d.ts
285
+ /**
286
+ * Returns the square root of the distance
287
+ * between two given points.
288
+ *
289
+ * @param a the first point coordinates
290
+ * @param b the second point coordinates
291
+ * @returns the distance value
292
+ */
293
+ declare const distanceSquareRoot: (a: PointTuple, b: PointTuple) => number;
294
+ //#endregion
295
+ //#region src/math/midPoint.d.ts
296
+ /**
297
+ * Returns the coordinates of a specified distance
298
+ * ratio between two points.
299
+ *
300
+ * @param a the first point coordinates
301
+ * @param b the second point coordinates
302
+ * @param t the ratio
303
+ * @returns the midpoint coordinates
304
+ */
305
+ declare const midPoint: ([ax, ay]: PointTuple, [bx, by]: PointTuple, t: number) => PointTuple;
306
+ //#endregion
307
+ //#region src/math/rotateVector.d.ts
308
+ /**
309
+ * Returns an {x,y} vector rotated by a given
310
+ * angle in radian.
311
+ *
312
+ * @param x the initial vector x
313
+ * @param y the initial vector y
314
+ * @param rad the radian vector angle
315
+ * @returns the rotated vector
316
+ */
317
+ declare const rotateVector: (x: number, y: number, rad: number) => {
318
+ x: number;
319
+ y: number;
320
+ };
321
+ //#endregion
322
+ //#region src/math/roundTo.d.ts
323
+ /**
324
+ * Rounds a number to the specified number of decimal places.
325
+ *
326
+ * @param n - The number to round
327
+ * @param round - Number of decimal places
328
+ * @returns The rounded number
329
+ */
330
+ declare const roundTo: (n: number, round: number) => number;
331
+ //#endregion
332
+ //#region src/convert/pathToAbsolute.d.ts
333
+ /**
334
+ * Parses a path string value or object and returns an array
335
+ * of segments, all converted to absolute values.
336
+ *
337
+ * @param pathInput - The path string or PathArray
338
+ * @returns The resulted PathArray with absolute values
339
+ *
340
+ * @example
341
+ * ```ts
342
+ * pathToAbsolute('M10 10l80 80')
343
+ * // => [['M', 10, 10], ['L', 90, 90]]
344
+ * ```
345
+ */
346
+ declare const pathToAbsolute: <T extends PathArray>(pathInput: string | T) => AbsoluteArray;
347
+ //#endregion
348
+ //#region src/convert/pathToRelative.d.ts
349
+ /**
350
+ * Parses a path string value or object and returns an array
351
+ * of segments, all converted to relative values.
352
+ *
353
+ * @param pathInput - The path string or PathArray
354
+ * @returns The resulted PathArray with relative values
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * pathToRelative('M10 10L90 90')
359
+ * // => [['M', 10, 10], ['l', 80, 80]]
360
+ * ```
361
+ */
362
+ declare const pathToRelative: <T extends PathArray>(pathInput: string | T) => RelativeArray;
363
+ //#endregion
364
+ //#region src/convert/pathToCurve.d.ts
365
+ /**
366
+ * Parses a path string or PathArray and returns a new one
367
+ * in which all segments are converted to cubic-bezier.
368
+ *
369
+ * @param pathInput - The path string or PathArray
370
+ * @returns The resulted CurveArray with all segments as cubic beziers
371
+ *
372
+ * @example
373
+ * ```ts
374
+ * pathToCurve('M10 50q15 -25 30 0')
375
+ * // => [['M', 10, 50], ['C', 25, 25, 40, 50, 40, 50]]
376
+ * ```
377
+ */
378
+ declare const pathToCurve: <T extends PathArray>(pathInput: string | T) => CurveArray;
379
+ //#endregion
380
+ //#region src/convert/pathToString.d.ts
381
+ /**
382
+ * Returns a valid `d` attribute string value created
383
+ * by rounding values and concatenating the PathArray segments.
384
+ *
385
+ * @param path - The PathArray object
386
+ * @param roundOption - Amount of decimals to round values to, or "off"
387
+ * @returns The concatenated path string
388
+ *
389
+ * @example
390
+ * ```ts
391
+ * pathToString([['M', 10, 10], ['L', 90, 90]], 2)
392
+ * // => 'M10 10L90 90'
393
+ * ```
394
+ */
395
+ declare const pathToString: <T extends PathArray>(path: T, roundOption?: number | "off") => string;
396
+ //#endregion
397
+ //#region src/parser/parsePathString.d.ts
398
+ /**
399
+ * Parses a path string value and returns an array
400
+ * of segments we like to call `PathArray`.
401
+ *
402
+ * If parameter value is already a `PathArray`,
403
+ * return a clone of it.
404
+
405
+ * @example
406
+ * parsePathString("M 0 0L50 50")
407
+ * // => [["M",0,0],["L",50,50]]
408
+ *
409
+ * @param pathInput the string to be parsed
410
+ * @returns the resulted `pathArray` or error string
411
+ */
412
+ declare const parsePathString: <T extends PathArray>(pathInput: string | T) => PathArray;
413
+ //#endregion
414
+ //#region src/parser/pathParser.d.ts
415
+ /**
416
+ * The `PathParser` is used by the `parsePathString` static method
417
+ * to generate a `pathArray`.
418
+ *
419
+ * @param pathString - The SVG path string to parse
420
+ */
421
+ declare class PathParser {
422
+ segments: PathArray | PathSegment[];
423
+ pathValue: string;
424
+ max: number;
425
+ index: number;
426
+ param: number;
427
+ segmentStart: number;
428
+ data: (string | number)[];
429
+ err: string;
430
+ constructor(pathString: string);
431
+ }
432
+ //#endregion
433
+ //#region src/parser/finalizeSegment.d.ts
434
+ /**
435
+ * Breaks the parsing of a pathString once a segment is finalized.
436
+ *
437
+ * @param path - The PathParser instance
438
+ */
439
+ declare const finalizeSegment: (path: PathParser) => void;
440
+ //#endregion
441
+ //#region src/parser/invalidPathValue.d.ts
442
+ /** Error message prefix used when a path string cannot be parsed. */
443
+ declare const invalidPathValue = "Invalid path value";
444
+ //#endregion
445
+ //#region src/parser/isArcCommand.d.ts
446
+ /**
447
+ * Checks if the character is an A (arc-to) path command.
448
+ *
449
+ * @param code the character to check
450
+ * @returns check result
451
+ */
452
+ declare const isArcCommand: (code: number) => code is 97;
453
+ //#endregion
454
+ //#region src/parser/isDigit.d.ts
455
+ /**
456
+ * Checks if a character is a digit.
457
+ *
458
+ * @param code the character to check
459
+ * @returns check result
460
+ */
461
+ declare const isDigit: (code: number) => code is DigitNumber;
462
+ //#endregion
463
+ //#region src/parser/isDigitStart.d.ts
464
+ /**
465
+ * Checks if the character is or belongs to a number.
466
+ * [0-9]|+|-|.
467
+ *
468
+ * @param code the character to check
469
+ * @returns check result
470
+ */
471
+ declare const isDigitStart: (code: number) => code is DigitNumber | 43 | 45 | 46;
472
+ //#endregion
473
+ //#region src/parser/isMoveCommand.d.ts
474
+ /**
475
+ * Checks if the character is a MoveTo command.
476
+ *
477
+ * @param code the character to check
478
+ * @returns check result
479
+ */
480
+ declare const isMoveCommand: (code: number) => code is 109 | 77;
481
+ //#endregion
482
+ //#region src/parser/isPathCommand.d.ts
483
+ /**
484
+ * Checks if the character is a path command.
485
+ *
486
+ * @param code the character to check
487
+ * @returns check result
488
+ */
489
+ declare const isPathCommand: (code: number) => code is PathCommandNumber;
490
+ //#endregion
491
+ //#region src/parser/isSpace.d.ts
492
+ /**
493
+ * Checks if the character is a space.
494
+ *
495
+ * @param ch the character to check
496
+ * @returns check result
497
+ */
498
+ declare const isSpace: (ch: number) => ch is SpaceNumber;
499
+ //#endregion
500
+ //#region src/parser/paramsCount.d.ts
501
+ /** Segment params length */
502
+ declare const paramsCounts: {
503
+ a: number;
504
+ c: number;
505
+ h: number;
506
+ l: number;
507
+ m: number;
508
+ r: number;
509
+ q: number;
510
+ s: number;
511
+ t: number;
512
+ v: number;
513
+ z: number;
514
+ };
515
+ //#endregion
516
+ //#region src/parser/paramsParser.d.ts
517
+ /**
518
+ * Default parser parameters object used to track position state
519
+ * while iterating through path segments.
520
+ */
521
+ declare const paramsParser: ParserParams;
522
+ //#endregion
523
+ //#region src/parser/scanFlag.d.ts
524
+ /**
525
+ * Validates an A (arc-to) specific path command value.
526
+ * Usually a `large-arc-flag` or `sweep-flag`.
527
+ *
528
+ * @param path - The PathParser instance
529
+ */
530
+ declare const scanFlag: (path: PathParser) => void;
531
+ //#endregion
532
+ //#region src/parser/scanParam.d.ts
533
+ /**
534
+ * Validates every character of the path string,
535
+ * every path command, negative numbers or floating point numbers.
536
+ *
537
+ * @param path - The PathParser instance
538
+ */
539
+ declare const scanParam: (path: PathParser) => void;
540
+ //#endregion
541
+ //#region src/parser/scanSegment.d.ts
542
+ /**
543
+ * Scans every character in the path string to determine
544
+ * where a segment starts and where it ends.
545
+ *
546
+ * @param path - The PathParser instance
547
+ */
548
+ declare const scanSegment: (path: PathParser) => void;
549
+ //#endregion
550
+ //#region src/parser/skipSpaces.d.ts
551
+ /**
552
+ * Points the parser to the next character in the
553
+ * path string every time it encounters any kind of
554
+ * space character.
555
+ *
556
+ * @param path - The PathParser instance
557
+ */
558
+ declare const skipSpaces: (path: PathParser) => void;
559
+ //#endregion
560
+ //#region src/util/getPathBBox.d.ts
561
+ /**
562
+ * Calculates the bounding box of a path.
563
+ *
564
+ * @param pathInput - The path string or PathArray
565
+ * @returns An object with width, height, x, y, x2, y2, cx, cy, cz properties
566
+ *
567
+ * @example
568
+ * ```ts
569
+ * getPathBBox('M0 0L100 0L100 100L0 100Z')
570
+ * // => { x: 0, y: 0, width: 100, height: 100, x2: 100, y2: 100, cx: 50, cy: 50, cz: 150 }
571
+ * ```
572
+ */
573
+ declare const getPathBBox: <T extends PathArray>(pathInput: T | string) => {
574
+ x: number;
575
+ y: number;
576
+ width: number;
577
+ height: number;
578
+ x2: number;
579
+ y2: number;
580
+ cx: number;
581
+ cy: number;
582
+ cz: number;
583
+ };
584
+ //#endregion
585
+ //#region src/util/getTotalLength.d.ts
586
+ /**
587
+ * Returns the total length of a path, equivalent to `shape.getTotalLength()`.
588
+ *
589
+ * @param pathInput - The target path string or PathArray
590
+ * @returns The total length of the path
591
+ *
592
+ * @example
593
+ * ```ts
594
+ * getTotalLength('M0 0L100 0L100 100L0 100Z')
595
+ * // => 300
596
+ * ```
597
+ */
598
+ declare const getTotalLength: <T extends PathArray>(pathInput: string | T) => number;
599
+ //#endregion
600
+ //#region src/util/distanceEpsilon.d.ts
601
+ /** Small threshold value used for floating-point distance comparisons in path calculations. */
602
+ declare const DISTANCE_EPSILON = 0.00001;
603
+ //#endregion
604
+ //#region src/util/getClosestPoint.d.ts
605
+ /**
606
+ * Returns the point in path closest to a given point.
607
+ *
608
+ * @param pathInput target `pathArray`
609
+ * @param point the given point
610
+ * @returns the best match
611
+ */
612
+ declare const getClosestPoint: (pathInput: string | PathArray, point: {
613
+ x: number;
614
+ y: number;
615
+ }) => {
616
+ x: number;
617
+ y: number;
618
+ };
619
+ //#endregion
620
+ //#region src/util/getDrawDirection.d.ts
621
+ /**
622
+ * Check if a path is drawn clockwise and returns true if so,
623
+ * false otherwise.
624
+ *
625
+ * @param path the path string or `pathArray`
626
+ * @returns true when clockwise or false if not
627
+ */
628
+ declare const getDrawDirection: (path: string | PathArray) => boolean;
629
+ //#endregion
630
+ //#region src/util/getPathArea.d.ts
631
+ /**
632
+ * Returns the signed area of a shape.
633
+ *
634
+ * @author Jürg Lehni & Jonathan Puckey
635
+ *
636
+ * @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
637
+ *
638
+ * @param path - The shape PathArray
639
+ * @returns The signed area of the shape (positive for clockwise, negative for counter-clockwise)
640
+ *
641
+ * @example
642
+ * ```ts
643
+ * getPathArea([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])
644
+ * // => -10000 (counter-clockwise square)
645
+ * ```
646
+ */
647
+ declare const getPathArea: <T extends PathArray>(path: T) => number;
648
+ //#endregion
649
+ //#region src/util/getPointAtLength.d.ts
650
+ /**
651
+ * Returns [x,y] coordinates of a point at a given length along a path.
652
+ *
653
+ * @param pathInput - The PathArray or path string to look into
654
+ * @param distance - The distance along the path
655
+ * @returns The requested {x, y} point coordinates
656
+ *
657
+ * @example
658
+ * ```ts
659
+ * getPointAtLength('M0 0L100 0L100 100Z', 50)
660
+ * // => { x: 50, y: 0 }
661
+ * ```
662
+ */
663
+ declare const getPointAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => {
664
+ x: number;
665
+ y: number;
666
+ };
667
+ //#endregion
668
+ //#region src/util/getPropertiesAtLength.d.ts
669
+ /**
670
+ * Returns the segment, its index and length as well as
671
+ * the length to that segment at a given length in a path.
672
+ *
673
+ * @param pathInput target `pathArray`
674
+ * @param distance the given length
675
+ * @returns the requested properties
676
+ */
677
+ declare const getPropertiesAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => SegmentProperties;
678
+ //#endregion
679
+ //#region src/util/getPropertiesAtPoint.d.ts
680
+ /**
681
+ * Returns the point and segment in path closest to a given point as well as
682
+ * the distance to the path stroke.
683
+ *
684
+ * @see https://bl.ocks.org/mbostock/8027637
685
+ *
686
+ * @param pathInput target `pathArray`
687
+ * @param point the given point
688
+ * @returns the requested properties
689
+ */
690
+ declare const getPropertiesAtPoint: <T extends PathArray>(pathInput: string | T, point: Point) => PointProperties;
691
+ //#endregion
692
+ //#region src/util/getSegmentAtLength.d.ts
693
+ /**
694
+ * Returns the segment at a given length.
695
+ *
696
+ * @param pathInput the target `pathArray`
697
+ * @param distance the distance in path to look at
698
+ * @returns the requested segment
699
+ */
700
+ declare const getSegmentAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => PathSegment | undefined;
701
+ //#endregion
702
+ //#region src/util/getSegmentOfPoint.d.ts
703
+ /**
704
+ * Returns the path segment which contains a given point.
705
+ *
706
+ * @param path the `pathArray` to look into
707
+ * @param point the point of the shape to look for
708
+ * @returns the requested segment
709
+ */
710
+ declare const getSegmentOfPoint: <T extends PathArray>(path: string | T, point: {
711
+ x: number;
712
+ y: number;
713
+ }) => SegmentProperties | undefined;
714
+ //#endregion
715
+ //#region src/util/isAbsoluteArray.d.ts
716
+ /**
717
+ * Iterates an array to check if it's a `pathArray`
718
+ * with all absolute values.
719
+ *
720
+ * @param path the `pathArray` to be checked
721
+ * @returns iteration result
722
+ */
723
+ declare const isAbsoluteArray: (path: unknown) => path is AbsoluteArray;
724
+ //#endregion
725
+ //#region src/util/isCurveArray.d.ts
726
+ /**
727
+ * Iterates an array to check if it's a `pathArray`
728
+ * with all C (cubic bezier) segments.
729
+ *
730
+ * @param path the `Array` to be checked
731
+ * @returns iteration result
732
+ */
733
+ declare const isCurveArray: (path: unknown) => path is CurveArray;
734
+ //#endregion
735
+ //#region src/util/isNormalizedArray.d.ts
736
+ /**
737
+ * Iterates an array to check if it's a `pathArray`
738
+ * with all segments in non-shorthand notation
739
+ * with absolute values.
740
+ *
741
+ * @param path - the array to be checked
742
+ * @returns true if the array is a normalized path array
743
+ */
744
+ declare const isNormalizedArray: (path: unknown) => path is NormalArray;
745
+ //#endregion
746
+ //#region src/util/isPathArray.d.ts
747
+ /**
748
+ * Iterates an array to check if it's an actual `pathArray`.
749
+ *
750
+ * @param path the `pathArray` to be checked
751
+ * @returns iteration result
752
+ */
753
+ declare const isPathArray: (path: unknown) => path is PathArray;
754
+ //#endregion
755
+ //#region src/util/isPointInStroke.d.ts
756
+ /**
757
+ * Checks if a given point is in the stroke of a path.
758
+ *
759
+ * @param pathInput target path
760
+ * @param point the given `{x,y}` point
761
+ * @returns the query result
762
+ */
763
+ declare const isPointInStroke: <T extends PathArray>(pathInput: string | T, point: {
764
+ x: number;
765
+ y: number;
766
+ }) => boolean;
767
+ //#endregion
768
+ //#region src/util/isPolygonArray.d.ts
769
+ /**
770
+ * Checks if a path is a polygon (only M, L, H, V, Z commands).
771
+ * @param pathArray PathArray (pre-normalize if needed)
772
+ * @returns boolean
773
+ */
774
+ declare const isPolygonArray: (path: PathArray) => path is PolygonArray;
775
+ //#endregion
776
+ //#region src/util/isPolylineArray.d.ts
777
+ /**
778
+ * Checks if a path is a polyline (only M, L, H, V commands).
779
+ * @param pathArray PathArray (pre-normalize if needed)
780
+ * @returns boolean
781
+ */
782
+ declare function isPolylineArray(path: PathArray): path is PolylineArray;
783
+ //#endregion
784
+ //#region src/util/isRelativeArray.d.ts
785
+ /**
786
+ * Iterates an array to check if it's a `pathArray`
787
+ * with relative values.
788
+ *
789
+ * @param path the `pathArray` to be checked
790
+ * @returns iteration result
791
+ */
792
+ declare const isRelativeArray: (path: unknown) => path is RelativeArray;
793
+ //#endregion
794
+ //#region src/util/isValidPath.d.ts
795
+ /**
796
+ * Parses a path string value to determine its validity
797
+ * then returns true if it's valid or false otherwise.
798
+ *
799
+ * @param pathString the path string to be parsed
800
+ * @returns the path string validity
801
+ */
802
+ declare const isValidPath: (pathString: string) => boolean;
803
+ //#endregion
804
+ //#region src/util/isMultiPath.d.ts
805
+ /**
806
+ * Determines if an SVG path contains multiple subpaths.
807
+ * Accepts path string or PathArray.
808
+ * @param path - 'M10,10 L20,20 Z M30,30 L40,40' → true
809
+ * @returns boolean
810
+ */
811
+ declare const isMultiPath: <T extends PathArray>(path: string | T) => boolean;
812
+ //#endregion
813
+ //#region src/util/isClosedPath.d.ts
814
+ /**
815
+ * Check if a PathArray is closed, which means its last segment is a Z.
816
+ * @param path
817
+ * @returns true if the path is closed
818
+ */
819
+ declare const isClosedPath: <T extends PathArray>(path: T) => boolean;
820
+ //#endregion
821
+ //#region src/util/shapeParams.d.ts
822
+ /**
823
+ * Supported shapes and their specific parameters.
824
+ */
825
+ declare const shapeParams: ShapeParams;
826
+ //#endregion
827
+ //#region src/util/shapeToPath.d.ts
828
+ /**
829
+ * Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`,
830
+ * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>` or `<glyph>`. If `replace` parameter
831
+ * is `true`, it will replace the target. The default `ownerDocument` is your current
832
+ * `document` browser page, if you want to use in server-side using `jsdom`, you can
833
+ * pass the `jsdom` `document` to `ownDocument`.
834
+ *
835
+ * It can also work with an options object, see the type below
836
+ * @see ShapeOps
837
+ *
838
+ * The newly created `<path>` element keeps all non-specific
839
+ * attributes like `class`, `fill`, etc.
840
+ *
841
+ * @param element - Target shape element or shape options object
842
+ * @param replace - Option to replace target element
843
+ * @param ownerDocument - Document for creating the element
844
+ * @returns The newly created `<path>` element, or false if the path is invalid
845
+ *
846
+ * @example
847
+ * ```ts
848
+ * const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle')
849
+ * circle.setAttribute('cx', '50')
850
+ * circle.setAttribute('cy', '50')
851
+ * circle.setAttribute('r', '25')
852
+ * const path = shapeToPath(circle)
853
+ * path.getAttribute('d')
854
+ * // => 'M50 25A25 25 0 1 1 50 75A25 25 0 1 1 50 25Z'
855
+ * ```
856
+ */
857
+ declare const shapeToPath: (element: ShapeTypes | ShapeOps, replace?: boolean, ownerDocument?: Document) => SVGPathElement | false;
858
+ //#endregion
859
+ //#region src/util/shapeToPathArray.d.ts
860
+ /**
861
+ * Returns a new `pathArray` created from attributes of a `<line>`, `<polyline>`,
862
+ * `<polygon>`, `<rect>`, `<ellipse>`, `<circle>`, <path> or `<glyph>`.
863
+ *
864
+ * It can also work with an options object, see the type below
865
+ * @see ShapeOps
866
+ *
867
+ * @param element target shape
868
+ * @returns the newly created `<path>` element
869
+ */
870
+ declare const shapeToPathArray: (element: ShapeTypes | ShapeOps) => false | PathArray;
871
+ //#endregion
872
+ //#region src/process/normalizePath.d.ts
873
+ /**
874
+ * Parses a path string or PathArray, then iterates the result for:
875
+ * * converting segments to absolute values
876
+ * * converting shorthand commands to their non-shorthand notation
877
+ *
878
+ * @param pathInput - The path string or PathArray
879
+ * @returns The normalized PathArray
880
+ *
881
+ * @example
882
+ * ```ts
883
+ * normalizePath('M10 90s20 -80 40 -80s20 80 40 80')
884
+ * // => [['M', 10, 90], ['C', 30, 90, 25, 10, 50, 10], ['C', 75, 10, 70, 90, 90, 90]]
885
+ * ```
886
+ */
887
+ declare const normalizePath: (pathInput: string | PathArray) => NormalArray;
888
+ //#endregion
889
+ //#region src/process/optimizePath.d.ts
890
+ /**
891
+ * Optimizes a PathArray:
892
+ * * converts segments to shorthand if possible
893
+ * * selects shortest representation from absolute and relative forms
894
+ *
895
+ * @param pathInput - A path string or PathArray
896
+ * @param roundOption - Number of decimal places for rounding
897
+ * @returns The optimized PathArray
898
+ *
899
+ * @example
900
+ * ```ts
901
+ * optimizePath('M10 10L10 10L90 90', 2)
902
+ * // => [['M', 10, 10], ['l', 0, 0], ['l', 80, 80]]
903
+ * ```
904
+ */
905
+ declare const optimizePath: <T extends PathArray>(pathInput: T, roundOption?: number) => PathArray;
906
+ //#endregion
907
+ //#region src/process/reversePath.d.ts
908
+ /**
909
+ * Reverses all segments of a PathArray and returns a new PathArray
910
+ * with absolute values.
911
+ *
912
+ * @param pathInput - The source PathArray
913
+ * @returns The reversed PathArray
914
+ *
915
+ * @example
916
+ * ```ts
917
+ * reversePath([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])
918
+ * // => [['M', 0, 100], ['L', 0, 0], ['L', 100, 0], ['L', 100, 100], ['Z']]
919
+ * ```
920
+ */
921
+ declare const reversePath: <T extends PathArray>(pathInput: T) => T;
922
+ //#endregion
923
+ //#region src/process/splitPath.d.ts
924
+ /**
925
+ * Split a path string or PathArray into an array of sub-paths.
926
+ *
927
+ * In the process, values are converted to absolute
928
+ * for visual consistency.
929
+ *
930
+ * @param pathInput - The source path string or PathArray
931
+ * @returns An array of sub-path PathArrays
932
+ *
933
+ * @example
934
+ * ```ts
935
+ * splitPath('M0 0L100 0ZM200 0L300 0Z')
936
+ * // => [
937
+ * // [['M', 0, 0], ['L', 100, 0], ['Z']],
938
+ * // [['M', 200, 0], ['L', 300, 0], ['Z']]
939
+ * // ]
940
+ * ```
941
+ */
942
+ declare const splitPath: <T extends PathArray>(pathInput: T | string) => T[];
943
+ //#endregion
944
+ //#region src/process/transformPath.d.ts
945
+ /**
946
+ * Apply a 2D / 3D transformation to a PathArray.
947
+ *
948
+ * Since SVGElement doesn't support 3D transformation, this function
949
+ * creates a 2D projection of the path element.
950
+ *
951
+ * @param pathInput - The PathArray or path string to transform
952
+ * @param transform - The transform functions object (translate, rotate, skew, scale, origin)
953
+ * @returns The transformed PathArray
954
+ *
955
+ * @example
956
+ * ```ts
957
+ * transformPath('M0 0L100 0L100 100L0 100Z', { translate: [10, 20], scale: 2 })
958
+ * // => [['M', 10, 20], ['L', 210, 20], ['L', 210, 220], ['L', 10, 220], ['Z']]
959
+ * ```
960
+ */
961
+ declare const transformPath: <T extends PathArray>(pathInput: T | string, transform?: Partial<TransformObject>) => T | AbsoluteArray;
962
+ //#endregion
963
+ //#region src/process/absolutizeSegment.d.ts
964
+ /**
965
+ * Returns an absolute segment of a `PathArray` object.
966
+ *
967
+ * @param segment the segment object
968
+ * @param index the segment index
969
+ * @param lastX the last known X value
970
+ * @param lastY the last known Y value
971
+ * @returns the absolute segment
972
+ */
973
+ declare const absolutizeSegment: (segment: PathSegment, index: number, lastX: number, lastY: number) => AbsoluteSegment;
974
+ //#endregion
975
+ //#region src/process/arcToCubic.d.ts
976
+ /**
977
+ * Converts A (arc-to) segments to C (cubic-bezier-to).
978
+ *
979
+ * For more information of where this math came from visit:
980
+ * http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
981
+ *
982
+ * @param X1 the starting x position
983
+ * @param Y1 the starting y position
984
+ * @param RX x-radius of the arc
985
+ * @param RY y-radius of the arc
986
+ * @param angle x-axis-rotation of the arc
987
+ * @param LAF large-arc-flag of the arc
988
+ * @param SF sweep-flag of the arc
989
+ * @param X2 the ending x position
990
+ * @param Y2 the ending y position
991
+ * @param recursive the parameters needed to split arc into 2 segments
992
+ * @returns the resulting cubic-bezier segment(s)
993
+ */
994
+ 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[];
995
+ //#endregion
996
+ //#region src/process/getSVGMatrix.d.ts
997
+ /**
998
+ * Returns a transformation matrix to apply to `<path>` elements.
999
+ *
1000
+ * @see TransformObjectValues
1001
+ *
1002
+ * @param transform the `transformObject`
1003
+ * @returns a new transformation matrix
1004
+ */
1005
+ declare const getSVGMatrix: (transform: TransformObjectValues) => CSSMatrix;
1006
+ //#endregion
1007
+ //#region src/process/iterate.d.ts
1008
+ /**
1009
+ * Iterates over a `PathArray`, executing a callback for each segment.
1010
+ * The callback can:
1011
+ * - Read current position (`x`, `y`)
1012
+ * - Modify the segment (return new segment)
1013
+ * - Stop early (return `false`)
1014
+ *
1015
+ * The iterator maintains accurate current point (`x`, `y`) and subpath start (`mx`, `my`)
1016
+ * while correctly handling relative/absolute commands, including H/V and Z.
1017
+ *
1018
+ * **Important**: If the callback returns a new segment with more coordinates (e.g., Q → C),
1019
+ * the path length may increase, and iteration will continue over new segments.
1020
+ *
1021
+ * @template T - Specific PathArray type (e.g., CurveArray, PolylineArray)
1022
+ * @param path - The source `PathArray` to iterate over
1023
+ * @param iterator - Callback function for each segment
1024
+ * @param iterator.segment - Current path segment
1025
+ * @param iterator.index - Index of current segment
1026
+ * @param iterator.x - Current X position (after applying relative offset)
1027
+ * @param iterator.y - Current Y position (after applying relative offset)
1028
+ * @returns The modified `path` (or original if no changes)
1029
+ *
1030
+ * @example
1031
+ * iterate(path, (seg, i, x, y) => {
1032
+ * if (seg[0] === 'L') return ['C', x, y, seg[1], seg[2], seg[1], seg[2]];
1033
+ * });
1034
+ */
1035
+ declare const iterate: <T extends PathArray>(path: T, iterator: IteratorCallback<T>) => T;
1036
+ //#endregion
1037
+ //#region src/process/lineToCubic.d.ts
1038
+ /**
1039
+ * Converts an L (line-to) segment to C (cubic-bezier).
1040
+ *
1041
+ * @param x1 line start x
1042
+ * @param y1 line start y
1043
+ * @param x2 line end x
1044
+ * @param y2 line end y
1045
+ * @returns the cubic-bezier segment
1046
+ */
1047
+ declare const lineToCubic: (x1: number, y1: number, x2: number, y2: number) => number[];
1048
+ //#endregion
1049
+ //#region src/process/normalizeSegment.d.ts
1050
+ /**
1051
+ * Normalizes a single segment of a `pathArray` object.
1052
+ *
1053
+ * @param segment the segment object
1054
+ * @param params the normalization parameters
1055
+ * @returns the normalized segment
1056
+ */
1057
+ declare const normalizeSegment: (segment: PathSegment, params: ParserParams) => NormalSegment;
1058
+ //#endregion
1059
+ //#region src/process/projection2d.d.ts
1060
+ /**
1061
+ * Returns the [x,y] projected coordinates for a given an [x,y] point
1062
+ * and an [x,y,z] perspective origin point.
1063
+ *
1064
+ * Equation found here =>
1065
+ * http://en.wikipedia.org/wiki/3D_projection#Diagram
1066
+ * Details =>
1067
+ * https://stackoverflow.com/questions/23792505/predicted-rendering-of-css-3d-transformed-pixel
1068
+ *
1069
+ * @param m the transformation matrix
1070
+ * @param point2D the initial [x,y] coordinates
1071
+ * @param origin the [x,y,z] transform origin
1072
+ * @returns the projected [x,y] coordinates
1073
+ */
1074
+ declare const projection2d: (m: CSSMatrix, point2D: PointTuple, origin: [number, number, number]) => PointTuple;
1075
+ //#endregion
1076
+ //#region src/process/quadToCubic.d.ts
1077
+ /**
1078
+ * Converts a Q (quadratic-bezier) segment to C (cubic-bezier).
1079
+ *
1080
+ * @param x1 curve start x
1081
+ * @param y1 curve start y
1082
+ * @param qx control point x
1083
+ * @param qy control point y
1084
+ * @param x2 curve end x
1085
+ * @param y2 curve end y
1086
+ * @returns the cubic-bezier segment
1087
+ */
1088
+ declare const quadToCubic: (x1: number, y1: number, qx: number, qy: number, x2: number, y2: number) => [number, number, number, number, number, number];
1089
+ //#endregion
1090
+ //#region src/process/relativizeSegment.d.ts
1091
+ /**
1092
+ * Returns a relative segment of a `PathArray` object.
1093
+ *
1094
+ * @param segment the segment object
1095
+ * @param index the segment index
1096
+ * @param lastX the last known X value
1097
+ * @param lastY the last known Y value
1098
+ * @returns the relative segment
1099
+ */
1100
+ declare const relativizeSegment: (segment: PathSegment, index: number, lastX: number, lastY: number) => MSegment | RelativeSegment;
1101
+ //#endregion
1102
+ //#region src/process/reverseCurve.d.ts
1103
+ /**
1104
+ * Reverses all segments of a `pathArray`
1105
+ * which consists of only C (cubic-bezier) path commands.
1106
+ *
1107
+ * @param path the source `pathArray`
1108
+ * @returns the reversed `pathArray`
1109
+ */
1110
+ declare const reverseCurve: (path: CurveArray) => CurveArray;
1111
+ //#endregion
1112
+ //#region src/process/roundPath.d.ts
1113
+ /**
1114
+ * Rounds the values of a `pathArray` instance to
1115
+ * a specified amount of decimals and returns it.
1116
+ *
1117
+ * @param path the source `pathArray`
1118
+ * @param roundOption the amount of decimals to round numbers to
1119
+ * @returns the resulted `pathArray` with rounded values
1120
+ */
1121
+ declare const roundPath: <T extends PathArray>(path: T, roundOption?: number | "off") => T;
1122
+ //#endregion
1123
+ //#region src/process/roundSegment.d.ts
1124
+ /**
1125
+ * Rounds the numeric values of a path segment to the specified precision.
1126
+ *
1127
+ * @param segment - The path segment to round
1128
+ * @param roundOption - Number of decimal places
1129
+ * @returns The rounded segment
1130
+ */
1131
+ declare const roundSegment: <T extends PathSegment>(segment: T, roundOption: number) => T;
1132
+ //#endregion
1133
+ //#region src/process/segmentToCubic.d.ts
1134
+ /**
1135
+ * Converts any segment to C (cubic-bezier).
1136
+ *
1137
+ * @param segment the source segment
1138
+ * @param params the source segment parameters
1139
+ * @returns the cubic-bezier segment
1140
+ */
1141
+ declare const segmentToCubic: (segment: PathSegment, params: ParserParams) => MSegment | CSegment;
1142
+ //#endregion
1143
+ //#region src/process/shortenSegment.d.ts
1144
+ /**
1145
+ * Shorten a single segment of a `pathArray` object.
1146
+ *
1147
+ * @param segment the `absoluteSegment` object
1148
+ * @param normalSegment the `normalSegment` object
1149
+ * @param params the coordinates of the previous segment
1150
+ * @param prevCommand the path command of the previous segment
1151
+ * @returns the shortened segment
1152
+ */
1153
+ declare const shortenSegment: (segment: AbsoluteSegment, normalSegment: NormalSegment, params: ParserParams, prevCommand: PathCommand) => ShortSegment;
1154
+ //#endregion
1155
+ //#region src/morph/fixPath.d.ts
1156
+ /**
1157
+ * Checks a `PathArray` for an unnecessary `Z` segment
1158
+ * and returns a new `PathArray` without it.
1159
+ * In short, if the segment before `Z` extends to `M`,
1160
+ * the `Z` segment must be removed.
1161
+ *
1162
+ * The `pathInput` must be a single path, without
1163
+ * sub-paths. For multi-path `<path>` elements,
1164
+ * use `splitPath` first and apply this utility on each
1165
+ * sub-path separately.
1166
+ *
1167
+ * @param pathInput the `pathArray` source
1168
+ * @returns void
1169
+ */
1170
+ declare const fixPath: <T extends PathArray>(pathInput: T | string) => void;
1171
+ //#endregion
1172
+ //#region src/morph/splitCubicSegment.d.ts
1173
+ /**
1174
+ * Split a cubic Bézier into two cubics at parameter t [0–1].
1175
+ *
1176
+ * @param x1 - Start point X
1177
+ * @param y1 - Start point Y
1178
+ * @param x2 - First control point X
1179
+ * @param y2 - First control point Y
1180
+ * @param x3 - Second control point X
1181
+ * @param y3 - Second control point Y
1182
+ * @param x4 - End point X
1183
+ * @param y4 - End point Y
1184
+ * @param t - Parameter in range [0, 1] at which to split
1185
+ * @returns Array of two cubic segments, each as [x1,y1, x2,y2, x3,y3, x4,y4]
1186
+ */
1187
+ declare function splitCubicSegment(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): [CubicCoordinates, CubicCoordinates];
1188
+ //#endregion
1189
+ //#region src/morph/equalizeSegments.d.ts
1190
+ /**
1191
+ * Equalizes two paths for morphing (single subpath only).
1192
+ *
1193
+ * @see https://minus-ze.ro/posts/morphing-arbitrary-paths-in-svg/
1194
+ * @param path1 - First path string or PathArray
1195
+ * @param path2 - Second path string or PathArray
1196
+ * @param initialCfg - Equalization options
1197
+ * @returns Tuple of two equalized MorphPathArrays
1198
+ *
1199
+ * @example
1200
+ * ```ts
1201
+ * const [eq1, eq2] = equalizeSegments('M0 0L100 0L50 100Z', 'M0 0L100 0L100 100L0 100Z')
1202
+ * // eq1.length === eq2.length
1203
+ * ```
1204
+ */
1205
+ declare const equalizeSegments: (path1: PathArray | string, path2: PathArray | string, initialCfg?: EqualizationOptions) => [MorphPathArray, MorphPathArray];
1206
+ //#endregion
1207
+ //#region src/morph/equalizePaths.d.ts
1208
+ /**
1209
+ * Equalizes two paths for morphing (single/multi subpath).
1210
+ *
1211
+ * @see https://minus-ze.ro/posts/morphing-arbitrary-paths-in-svg/
1212
+ * @param pathInput1 - First path string or PathArray
1213
+ * @param pathInput2 - Second path string or PathArray
1214
+ * @param initialCfg - Configuration options for equalization
1215
+ * @returns Tuple of two equalized MorphPathArrays
1216
+ *
1217
+ * @example
1218
+ * ```ts
1219
+ * const [eq1, eq2] = equalizePaths('M0 0L100 0L50 100Z', 'M0 0L100 0L100 100L0 100Z')
1220
+ * // eq1.length === eq2.length — ready for morphing
1221
+ * ```
1222
+ */
1223
+ declare const equalizePaths: (pathInput1: string | PathArray, pathInput2: string | PathArray, initialCfg?: {}) => [MorphPathArray, MorphPathArray];
1224
+ //#endregion
1225
+ //#region src/util/pathIntersection.d.ts
1226
+ /**
1227
+ * Checks if a point is inside a bounding box.
1228
+ *
1229
+ * @param bbox - The bounding box as [minX, minY, maxX, maxY]
1230
+ * @param point - The point as [x, y]
1231
+ * @returns True if the point is inside or on the edge of the bounding box
1232
+ */
1233
+ declare const isPointInsideBBox: (bbox: BBoxMaxima, [x, y]: PointTuple) => boolean;
1234
+ /**
1235
+ * Checks if two bounding boxes intersect.
1236
+ *
1237
+ * @param a - First bounding box as [minX, minY, maxX, maxY]
1238
+ * @param b - Second bounding box as [minX, minY, maxX, maxY]
1239
+ * @returns True if the bounding boxes overlap
1240
+ */
1241
+ declare const boundingBoxIntersect: (a: BBoxMaxima, b: BBoxMaxima) => boolean;
1242
+ /**
1243
+ * Finds intersection points between two paths.
1244
+ *
1245
+ * @param pathInput1 - First path string or PathArray
1246
+ * @param pathInput2 - Second path string or PathArray
1247
+ * @param justCount - If true, returns the count of intersections; if false, returns the intersection points
1248
+ * @returns The number of intersections (when justCount is true) or an array of IntersectionPoint objects
1249
+ *
1250
+ * @example
1251
+ * ```ts
1252
+ * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)
1253
+ * // => 1
1254
+ * pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)
1255
+ * // => [{ x: 50, y: 25, t1: 0.5, t2: 0.5 }]
1256
+ * ```
1257
+ */
1258
+ declare const pathsIntersection: <T extends string | PathArray>(pathInput1: T, pathInput2: T, justCount?: boolean) => number | IntersectionPoint[];
1259
+ //#endregion
1260
+ export { PathParser, absolutizeSegment, arcToCubic, arcTools, bezierTools, boundingBoxIntersect, cubicTools, DISTANCE_EPSILON as distanceEpsilon, distanceSquareRoot, equalizePaths, equalizeSegments, finalizeSegment, fixPath, getClosestPoint, getDrawDirection, getPathArea, getPathBBox, getPointAtLength, getPropertiesAtLength, getPropertiesAtPoint, getSVGMatrix, getSegmentAtLength, getSegmentOfPoint, getTotalLength, invalidPathValue, isAbsoluteArray, isArcCommand, isClosedPath, isCurveArray, isDigit, isDigitStart, isMoveCommand, isMultiPath, isNormalizedArray, isPathArray, isPathCommand, isPointInStroke, isPointInsideBBox, isPolygonArray, isPolylineArray, isRelativeArray, isSpace, isValidPath, iterate, lineToCubic, lineTools, midPoint, normalizePath, normalizeSegment, optimizePath, paramsCounts, paramsParser, parsePathString, pathToAbsolute, pathToCurve, pathToRelative, pathToString, pathsIntersection, polygonTools, projection2d, quadToCubic, quadTools, relativizeSegment, reverseCurve, reversePath, rotateVector, roundPath, roundSegment, roundTo, scanFlag, scanParam, scanSegment, segmentToCubic, shapeParams, shapeToPath, shapeToPathArray, shortenSegment, skipSpaces, splitCubicSegment, splitPath, transformPath };
1261
+ //# sourceMappingURL=util.d.ts.map