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.
@@ -0,0 +1,733 @@
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
+ import CSSMatrix from "@thednp/dommatrix";
7
+
8
+ //#region src/interface.d.ts
9
+ type SegmentProperties = {
10
+ segment: PathSegment;
11
+ index: number;
12
+ length: number;
13
+ lengthAtSegment: number;
14
+ };
15
+ type PointProperties = {
16
+ closest: {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ distance: number;
21
+ segment?: SegmentProperties;
22
+ };
23
+ type LineAttr = {
24
+ type: "line";
25
+ x1: number;
26
+ y1: number;
27
+ x2: number;
28
+ y2: number;
29
+ [key: string]: string | number;
30
+ };
31
+ type PolyAttr = {
32
+ type: "polygon" | "polyline";
33
+ points: string;
34
+ [key: string]: string | number;
35
+ };
36
+ type CircleAttr = {
37
+ type: "circle";
38
+ cx: number;
39
+ cy: number;
40
+ r: number;
41
+ [key: string]: string | number;
42
+ };
43
+ type EllipseAttr = {
44
+ type: "ellipse";
45
+ cx: number;
46
+ cy: number;
47
+ rx: number;
48
+ ry?: number;
49
+ [key: string]: string | number | undefined;
50
+ };
51
+ type RectAttr = {
52
+ type: "rect";
53
+ width: number;
54
+ height: number;
55
+ x: number;
56
+ y: number;
57
+ rx?: number;
58
+ ry?: number;
59
+ [key: string]: string | number | undefined;
60
+ };
61
+ type GlyphAttr = {
62
+ type: "glyph";
63
+ d: string;
64
+ [key: string]: string | number;
65
+ };
66
+ type ShapeParams = {
67
+ line: ["x1", "y1", "x2", "y2"];
68
+ circle: ["cx", "cy", "r"];
69
+ ellipse: ["cx", "cy", "rx", "ry"];
70
+ rect: ["width", "height", "x", "y", "rx", "ry"];
71
+ polygon: ["points"];
72
+ polyline: ["points"];
73
+ glyph: ["d"];
74
+ };
75
+ type PathBBox = {
76
+ width: number;
77
+ height: number;
78
+ x: number;
79
+ y: number;
80
+ x2: number;
81
+ y2: number;
82
+ cx: number;
83
+ cy: number;
84
+ cz: number;
85
+ };
86
+ type SegmentLimits = {
87
+ min: {
88
+ x: number;
89
+ y: number;
90
+ };
91
+ max: {
92
+ x: number;
93
+ y: number;
94
+ };
95
+ };
96
+ type ParserParams = {
97
+ mx: number;
98
+ my: number;
99
+ x1: number;
100
+ y1: number;
101
+ x2: number;
102
+ y2: number;
103
+ x: number;
104
+ y: number;
105
+ qx: number | null;
106
+ qy: number | null;
107
+ };
108
+ type LengthFactory = {
109
+ length: number;
110
+ point: {
111
+ x: number;
112
+ y: number;
113
+ };
114
+ min: {
115
+ x: number;
116
+ y: number;
117
+ };
118
+ max: {
119
+ x: number;
120
+ y: number;
121
+ };
122
+ };
123
+ type Options = {
124
+ round: "off" | number;
125
+ origin: number[];
126
+ };
127
+ type PathTransform = {
128
+ s: PathSegment;
129
+ c: string;
130
+ x: number;
131
+ y: number;
132
+ };
133
+ type TransformObject = {
134
+ translate: number | number[];
135
+ rotate: number | number[];
136
+ scale: number | number[];
137
+ skew: number | number[];
138
+ origin: number[];
139
+ };
140
+ type TransformProps = keyof TransformObject;
141
+ type TransformEntries = [TransformProps, TransformObject[TransformProps]][];
142
+ //#endregion
143
+ //#region src/types.d.ts
144
+ 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;
145
+ type PathCommandNumber = 0x6d | 0x7a | 0x6c | 0x68 | 0x76 | 0x63 | 0x73 | 0x71 | 0x74 | 0x61;
146
+ type DigitNumber = 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39;
147
+ type MCommand = "M";
148
+ type mCommand = "m";
149
+ type LCommand = "L";
150
+ type lCommand = "l";
151
+ type VCommand = "V";
152
+ type vCommand = "v";
153
+ type HCommand = "H";
154
+ type hCommand = "h";
155
+ type ZCommand = "Z";
156
+ type zCommand = "z";
157
+ type CCommand = "C";
158
+ type cCommand = "c";
159
+ type SCommand = "S";
160
+ type sCommand = "s";
161
+ type QCommand = "Q";
162
+ type qCommand = "q";
163
+ type TCommand = "T";
164
+ type tCommand = "t";
165
+ type ACommand = "A";
166
+ type aCommand = "a";
167
+ type AbsoluteCommand = MCommand | LCommand | VCommand | HCommand | ZCommand | CCommand | SCommand | QCommand | TCommand | ACommand;
168
+ type RelativeCommand = mCommand | lCommand | vCommand | hCommand | zCommand | cCommand | sCommand | qCommand | tCommand | aCommand;
169
+ type PathCommand = AbsoluteCommand | RelativeCommand;
170
+ type MSegment = [MCommand, number, number];
171
+ type mSegment = [mCommand, number, number];
172
+ type MoveSegment = MSegment | mSegment;
173
+ type LSegment = [LCommand, number, number];
174
+ type lSegment = [lCommand, number, number];
175
+ type LineSegment = LSegment | lSegment;
176
+ type VSegment = [VCommand, number];
177
+ type vSegment = [vCommand, number];
178
+ type VertLineSegment = vSegment | VSegment;
179
+ type HSegment = [HCommand, number];
180
+ type hSegment = [hCommand, number];
181
+ type HorLineSegment = HSegment | hSegment;
182
+ type ZSegment = [ZCommand];
183
+ type zSegment = [zCommand];
184
+ type CloseSegment = ZSegment | zSegment;
185
+ type CSegment = [CCommand, number, number, number, number, number, number];
186
+ type cSegment = [cCommand, number, number, number, number, number, number];
187
+ type CubicSegment = CSegment | cSegment;
188
+ type SSegment = [SCommand, number, number, number, number];
189
+ type sSegment = [sCommand, number, number, number, number];
190
+ type ShortCubicSegment = SSegment | sSegment;
191
+ type QSegment = [QCommand, number, number, number, number];
192
+ type qSegment = [qCommand, number, number, number, number];
193
+ type QuadSegment = QSegment | qSegment;
194
+ type TSegment = [TCommand, number, number];
195
+ type tSegment = [tCommand, number, number];
196
+ type ShortQuadSegment = TSegment | tSegment;
197
+ type ASegment = [ACommand, number, number, number, number, number, number, number];
198
+ type aSegment = [aCommand, number, number, number, number, number, number, number];
199
+ type ArcSegment = ASegment | aSegment;
200
+ type PathSegment = MoveSegment | LineSegment | VertLineSegment | HorLineSegment | CloseSegment | CubicSegment | ShortCubicSegment | QuadSegment | ShortQuadSegment | ArcSegment;
201
+ type ShortSegment = VertLineSegment | HorLineSegment | ShortCubicSegment | ShortQuadSegment | CloseSegment;
202
+ type AbsoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
203
+ type RelativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
204
+ type NormalSegment = MSegment | LSegment | CSegment | QSegment | ASegment | ZSegment;
205
+ type PathArray = [MSegment | mSegment, ...PathSegment[]];
206
+ type AbsoluteArray = [MSegment, ...AbsoluteSegment[]];
207
+ type RelativeArray = [MSegment, ...RelativeSegment[]];
208
+ type NormalArray = [MSegment, ...NormalSegment[]];
209
+ type CurveArray = [MSegment, ...CSegment[]];
210
+ type ClosedCurveArray = [MSegment, ...CSegment[], ZSegment];
211
+ type PolygonArray = [MSegment, ...LSegment[], ZSegment];
212
+ type PolylineArray = [MSegment, ...LSegment[]];
213
+ type MorphPathArray = PolygonArray | PolylineArray | CurveArray | ClosedCurveArray;
214
+ type ShapeTypes = SVGPolylineElement | SVGPolygonElement | SVGLineElement | SVGEllipseElement | SVGCircleElement | SVGRectElement;
215
+ type ShapeTags = "line" | "polyline" | "polygon" | "ellipse" | "circle" | "rect" | "glyph";
216
+ type ShapeOps = LineAttr | PolyAttr | PolyAttr | EllipseAttr | CircleAttr | RectAttr | GlyphAttr;
217
+ type TransformObjectValues = Partial<TransformObject> & {
218
+ origin: [number, number, number];
219
+ };
220
+ type Point = {
221
+ x: number;
222
+ y: number;
223
+ };
224
+ type PointTuple = [number, number];
225
+ type DerivedPoint = Point & {
226
+ t: number;
227
+ };
228
+ type QuadPoints = [Point, Point, Point, Point, Point, Point];
229
+ type CubicPoints = [Point, Point, Point, Point, Point, Point, Point, Point];
230
+ type DerivedQuadPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
231
+ type DerivedCubicPoints = [DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint, DerivedPoint];
232
+ type QuadCoordinates = [number, number, number, number, number, number];
233
+ type CubicCoordinates = [number, number, number, number, number, number, number, number];
234
+ type ArcCoordinates = [number, number, number, number, number, number, number, number, number];
235
+ type LineCoordinates = [number, number, number, number];
236
+ type DeriveCallback = (t: number) => Point;
237
+ 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;
238
+ type BBoxMaxima = [minX: number, minY: number, maxX: number, maxY: number];
239
+ type PointAtLength = {
240
+ x: number;
241
+ y: number;
242
+ t: number;
243
+ };
244
+ type IntersectionPoint = {
245
+ x: number;
246
+ y: number;
247
+ t1: number;
248
+ t2: number;
249
+ };
250
+ interface IntersectionOptions {
251
+ justCount?: boolean;
252
+ epsilon?: number;
253
+ }
254
+ interface PathEqualizationOptions {
255
+ /** @default "auto" */
256
+ mode?: "line" | "curve" | "auto";
257
+ sampleSize?: number;
258
+ roundValues?: number;
259
+ close?: boolean;
260
+ }
261
+ interface EqualizationOptions {
262
+ /** @default "auto" */
263
+ mode?: "curve" | "auto";
264
+ sampleSize?: number;
265
+ roundValues?: number;
266
+ reverse?: boolean;
267
+ close?: boolean;
268
+ target?: number;
269
+ }
270
+ type PathsEqualizationOptions = Omit<EqualizationOptions, "reverse" | "target">;
271
+ interface PathFeature {
272
+ isPoly: boolean;
273
+ path: NormalArray;
274
+ size: number;
275
+ area: number;
276
+ signedArea: number;
277
+ bbox: PathBBox;
278
+ }
279
+ //#endregion
280
+ //#region src/parser/pathParser.d.ts
281
+ /**
282
+ * The `PathParser` is used by the `parsePathString` static method
283
+ * to generate a `pathArray`.
284
+ *
285
+ * @param pathString - The SVG path string to parse
286
+ */
287
+ declare class PathParser {
288
+ segments: PathArray | PathSegment[];
289
+ pathValue: string;
290
+ max: number;
291
+ index: number;
292
+ param: number;
293
+ segmentStart: number;
294
+ data: (string | number)[];
295
+ err: string;
296
+ constructor(pathString: string);
297
+ }
298
+ //#endregion
299
+ //#region src/morph/samplePolygon.d.ts
300
+ /**
301
+ * Samples points from a path to form a polygon approximation.
302
+ * Collects endpoints of each segment (M start + ends of L/C/etc).
303
+ *
304
+ * If `sampleSize` parameter is provided, it will return a polygon
305
+ * equivalent to the original `PathArray`.
306
+ * @param path `PolygonPathArray` or `CurvePathArray`
307
+ * @returns Array of [x, y] points
308
+ */
309
+ declare function samplePolygon<T extends NormalArray>(path: T): PointTuple[];
310
+ //#endregion
311
+ //#region src/util/isPolylineArray.d.ts
312
+ /**
313
+ * Checks if a path is a polyline (only M, L, H, V commands).
314
+ * @param pathArray PathArray (pre-normalize if needed)
315
+ * @returns boolean
316
+ */
317
+ declare function isPolylineArray(path: PathArray): path is PolylineArray;
318
+ //#endregion
319
+ //#region src/morph/splitCubicSegment.d.ts
320
+ /**
321
+ * Split a cubic Bézier into two cubics at parameter t [0–1].
322
+ *
323
+ * @param x1 - Start point X
324
+ * @param y1 - Start point Y
325
+ * @param x2 - First control point X
326
+ * @param y2 - First control point Y
327
+ * @param x3 - Second control point X
328
+ * @param y3 - Second control point Y
329
+ * @param x4 - End point X
330
+ * @param y4 - End point Y
331
+ * @param t - Parameter in range [0, 1] at which to split
332
+ * @returns Array of two cubic segments, each as [x1,y1, x2,y2, x3,y3, x4,y4]
333
+ */
334
+ declare function splitCubicSegment(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): [CubicCoordinates, CubicCoordinates];
335
+ //#endregion
336
+ //#region src/main.d.ts
337
+ /**
338
+ * Creates a new SVGPathCommander instance with the following properties:
339
+ * * segments: `pathArray`
340
+ * * round: number
341
+ * * origin: [number, number, number?]
342
+ *
343
+ * @class
344
+ * @author thednp <https://github.com/thednp/svg-path-commander>
345
+ * @returns a new SVGPathCommander instance
346
+ */
347
+ declare class SVGPathCommander {
348
+ segments: PathArray;
349
+ round: number | "off";
350
+ origin: [number, number, number];
351
+ /**
352
+ * @constructor
353
+ * @param pathValue the path string
354
+ * @param config instance options
355
+ */
356
+ constructor(pathValue: string, config?: Partial<Options>);
357
+ get bbox(): {
358
+ x: number;
359
+ y: number;
360
+ width: number;
361
+ height: number;
362
+ x2: number;
363
+ y2: number;
364
+ cx: number;
365
+ cy: number;
366
+ cz: number;
367
+ };
368
+ get length(): number;
369
+ /**
370
+ * Returns the path bounding box, equivalent to native `path.getBBox()`.
371
+ *
372
+ * @public
373
+ * @returns the pathBBox
374
+ */
375
+ getBBox(): {
376
+ x: number;
377
+ y: number;
378
+ width: number;
379
+ height: number;
380
+ x2: number;
381
+ y2: number;
382
+ cx: number;
383
+ cy: number;
384
+ cz: number;
385
+ };
386
+ /**
387
+ * Returns the total path length, equivalent to native `path.getTotalLength()`.
388
+ *
389
+ * @public
390
+ * @returns the path total length
391
+ */
392
+ getTotalLength(): number;
393
+ /**
394
+ * Returns an `{x,y}` point in the path stroke at a given length,
395
+ * equivalent to the native `path.getPointAtLength()`.
396
+ *
397
+ * @public
398
+ * @param length the length
399
+ * @returns the requested point
400
+ */
401
+ getPointAtLength(length: number): {
402
+ x: number;
403
+ y: number;
404
+ };
405
+ /**
406
+ * Convert path to absolute values.
407
+ *
408
+ * @example
409
+ * ```ts
410
+ * new SVGPathCommander('M10 10l80 80').toAbsolute().toString()
411
+ * // => 'M10 10L90 90'
412
+ * ```
413
+ *
414
+ * @returns this for chaining
415
+ * @public
416
+ */
417
+ toAbsolute(): this;
418
+ /**
419
+ * Convert path to relative values.
420
+ *
421
+ * @example
422
+ * ```ts
423
+ * new SVGPathCommander('M10 10L90 90').toRelative().toString()
424
+ * // => 'M10 10l80 80'
425
+ * ```
426
+ *
427
+ * @returns this for chaining
428
+ * @public
429
+ */
430
+ toRelative(): this;
431
+ /**
432
+ * Convert path to cubic-bezier values. In addition, un-necessary `Z`
433
+ * segment is removed if previous segment extends to the `M` segment.
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * new SVGPathCommander('M10 50q15 -25 30 0').toCurve().toString()
438
+ * // => 'M10 50C25 25 40 50 40 50'
439
+ * ```
440
+ *
441
+ * @returns this for chaining
442
+ * @public
443
+ */
444
+ toCurve(): this;
445
+ /**
446
+ * Reverse the order of the segments and their values.
447
+ *
448
+ * @example
449
+ * ```ts
450
+ * new SVGPathCommander('M0 0L100 0L100 100L0 100Z').reverse().toString()
451
+ * // => 'M0 100L0 0L100 0L100 100Z'
452
+ * ```
453
+ *
454
+ * @param onlySubpath - option to reverse all sub-paths except first
455
+ * @returns this for chaining
456
+ * @public
457
+ */
458
+ reverse(onlySubpath?: boolean): this;
459
+ /**
460
+ * Normalize path in 2 steps:
461
+ * * convert `pathArray`(s) to absolute values
462
+ * * convert shorthand notation to standard notation
463
+ *
464
+ * @example
465
+ * ```ts
466
+ * new SVGPathCommander('M10 90s20 -80 40 -80s20 80 40 80').normalize().toString()
467
+ * // => 'M10 90C30 90 25 10 50 10C75 10 70 90 90 90'
468
+ * ```
469
+ *
470
+ * @returns this for chaining
471
+ * @public
472
+ */
473
+ normalize(): this;
474
+ /**
475
+ * Optimize `pathArray` values:
476
+ * * convert segments to absolute and/or relative values
477
+ * * select segments with shortest resulted string
478
+ * * round values to the specified `decimals` option value
479
+ *
480
+ * @example
481
+ * ```ts
482
+ * new SVGPathCommander('M10 10L10 10L90 90').optimize().toString()
483
+ * // => 'M10 10l0 0 80 80'
484
+ * ```
485
+ *
486
+ * @returns this for chaining
487
+ * @public
488
+ */
489
+ optimize(): this;
490
+ /**
491
+ * Transform path using values from an `Object` defined as `transformObject`.
492
+ *
493
+ * @see TransformObject for a quick reference
494
+ *
495
+ * @param source a `transformObject` as described above
496
+ * @returns this for chaining
497
+ * @public
498
+ */
499
+ transform(source?: Partial<TransformObject>): this;
500
+ /**
501
+ * Rotate path 180deg vertically.
502
+ *
503
+ * @example
504
+ * ```ts
505
+ * const path = new SVGPathCommander('M0 0L100 0L100 100L0 100Z')
506
+ * path.flipX().toString()
507
+ * ```
508
+ *
509
+ * @returns this for chaining
510
+ * @public
511
+ */
512
+ flipX(): this;
513
+ /**
514
+ * Rotate path 180deg horizontally.
515
+ *
516
+ * @example
517
+ * ```ts
518
+ * const path = new SVGPathCommander('M0 0L100 0L100 100L0 100Z')
519
+ * path.flipY().toString()
520
+ * ```
521
+ *
522
+ * @returns this for chaining
523
+ * @public
524
+ */
525
+ flipY(): this;
526
+ /**
527
+ * Export the current path to be used
528
+ * for the `d` (description) attribute.
529
+ *
530
+ * @public
531
+ * @returns the path string
532
+ */
533
+ toString(): string;
534
+ /**
535
+ * Remove the instance.
536
+ *
537
+ * @public
538
+ * @returns void
539
+ */
540
+ dispose(): void;
541
+ static options: Options;
542
+ static CSSMatrix: typeof CSSMatrix;
543
+ static arcTools: {
544
+ angleBetween: (v0: Point, v1: Point) => number;
545
+ arcLength: (rx: number, ry: number, theta: number) => number;
546
+ arcPoint: (cx: number, cy: number, rx: number, ry: number, alpha: number, theta: number) => PointTuple;
547
+ getArcBBox: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => [number, number, number, number];
548
+ getArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => number;
549
+ getArcProps: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number) => {
550
+ rx: number;
551
+ ry: number;
552
+ startAngle: number;
553
+ endAngle: number;
554
+ center: {
555
+ x: number;
556
+ y: number;
557
+ };
558
+ };
559
+ getPointAtArcLength: (x1: number, y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, x: number, y: number, distance?: number) => {
560
+ x: number;
561
+ y: number;
562
+ };
563
+ };
564
+ static bezierTools: {
565
+ bezierLength: (derivativeFn: DeriveCallback) => number;
566
+ calculateBezier: (derivativeFn: DeriveCallback, t: number) => number;
567
+ CBEZIER_MINMAX_EPSILON: number;
568
+ computeBezier: (points: DerivedQuadPoints | DerivedCubicPoints, t: number) => DerivedPoint;
569
+ Cvalues: number[];
570
+ deriveBezier: (points: QuadPoints | CubicPoints) => (DerivedQuadPoints | DerivedCubicPoints)[];
571
+ getBezierLength: (curve: CubicCoordinates | QuadCoordinates) => number;
572
+ minmaxC: ([v1, cp1, cp2, v2]: [number, number, number, number]) => PointTuple;
573
+ minmaxQ: ([v1, cp, v2]: [number, number, number]) => PointTuple;
574
+ Tvalues: number[];
575
+ };
576
+ static cubicTools: {
577
+ getCubicBBox: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => BBoxMaxima;
578
+ getCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => number;
579
+ getPointAtCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number, distance?: number) => {
580
+ x: number;
581
+ y: number;
582
+ };
583
+ getPointAtCubicSegmentLength: ([x1, y1, c1x, c1y, c2x, c2y, x2, y2]: CubicCoordinates, t: number) => {
584
+ x: number;
585
+ y: number;
586
+ };
587
+ };
588
+ static lineTools: {
589
+ getLineBBox: (x1: number, y1: number, x2: number, y2: number) => [number, number, number, number];
590
+ getLineLength: (x1: number, y1: number, x2: number, y2: number) => number;
591
+ getPointAtLineLength: (x1: number, y1: number, x2: number, y2: number, distance?: number) => {
592
+ x: number;
593
+ y: number;
594
+ };
595
+ };
596
+ static polygonTools: {
597
+ polygonArea: (polygon: PointTuple[]) => number;
598
+ polygonLength: (polygon: PointTuple[]) => number;
599
+ polygonCentroid: (polygon: PointTuple[]) => PointTuple;
600
+ };
601
+ static quadTools: {
602
+ getPointAtQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number, distance?: number) => {
603
+ x: number;
604
+ y: number;
605
+ };
606
+ getPointAtQuadSegmentLength: ([x1, y1, cx, cy, x2, y2]: QuadCoordinates, t: number) => {
607
+ x: number;
608
+ y: number;
609
+ };
610
+ getQuadBBox: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => [number, number, number, number];
611
+ getQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => number;
612
+ };
613
+ static pathToAbsolute: <T extends PathArray>(pathInput: string | T) => AbsoluteArray;
614
+ static pathToRelative: <T extends PathArray>(pathInput: string | T) => RelativeArray;
615
+ static pathToCurve: <T extends PathArray>(pathInput: string | T) => CurveArray;
616
+ static pathToString: <T extends PathArray>(path: T, roundOption?: number | "off") => string;
617
+ static distanceSquareRoot: (a: PointTuple, b: PointTuple) => number;
618
+ static midPoint: ([ax, ay]: PointTuple, [bx, by]: PointTuple, t: number) => PointTuple;
619
+ static rotateVector: (x: number, y: number, rad: number) => {
620
+ x: number;
621
+ y: number;
622
+ };
623
+ static roundTo: (n: number, round: number) => number;
624
+ static parsePathString: <T extends PathArray>(pathInput: string | T) => PathArray;
625
+ static finalizeSegment: (path: PathParser) => void;
626
+ static invalidPathValue: string;
627
+ static isArcCommand: (code: number) => code is 97;
628
+ static isDigit: (code: number) => code is DigitNumber;
629
+ static isDigitStart: (code: number) => code is DigitNumber | 43 | 45 | 46;
630
+ static isMoveCommand: (code: number) => code is 109 | 77;
631
+ static isPathCommand: (code: number) => code is PathCommandNumber;
632
+ static isSpace: (ch: number) => ch is SpaceNumber;
633
+ static paramsCount: {
634
+ a: number;
635
+ c: number;
636
+ h: number;
637
+ l: number;
638
+ m: number;
639
+ r: number;
640
+ q: number;
641
+ s: number;
642
+ t: number;
643
+ v: number;
644
+ z: number;
645
+ };
646
+ static paramsParser: ParserParams;
647
+ static PathParser: typeof PathParser;
648
+ static scanFlag: (path: PathParser) => void;
649
+ static scanParam: (path: PathParser) => void;
650
+ static scanSegment: (path: PathParser) => void;
651
+ static skipSpaces: (path: PathParser) => void;
652
+ static distanceEpsilon: number;
653
+ static fixPath: <T extends PathArray>(pathInput: T | string) => void;
654
+ static getClosestPoint: (pathInput: string | PathArray, point: {
655
+ x: number;
656
+ y: number;
657
+ }) => {
658
+ x: number;
659
+ y: number;
660
+ };
661
+ static getDrawDirection: (path: string | PathArray) => boolean;
662
+ static getPathArea: <T extends PathArray>(path: T) => number;
663
+ static getPathBBox: <T extends PathArray>(pathInput: T | string) => {
664
+ x: number;
665
+ y: number;
666
+ width: number;
667
+ height: number;
668
+ x2: number;
669
+ y2: number;
670
+ cx: number;
671
+ cy: number;
672
+ cz: number;
673
+ };
674
+ static getPointAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => {
675
+ x: number;
676
+ y: number;
677
+ };
678
+ static getPropertiesAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => SegmentProperties;
679
+ static getPropertiesAtPoint: <T extends PathArray>(pathInput: string | T, point: Point) => PointProperties;
680
+ static getSegmentAtLength: <T extends PathArray>(pathInput: string | T, distance?: number) => PathSegment | undefined;
681
+ static getSegmentOfPoint: <T extends PathArray>(path: string | T, point: {
682
+ x: number;
683
+ y: number;
684
+ }) => SegmentProperties | undefined;
685
+ static getTotalLength: <T extends PathArray>(pathInput: string | T) => number;
686
+ static isAbsoluteArray: (path: unknown) => path is AbsoluteArray;
687
+ static isCurveArray: (path: unknown) => path is CurveArray;
688
+ static isPolygonArray: (path: PathArray) => path is PolygonArray;
689
+ static isNormalizedArray: (path: unknown) => path is NormalArray;
690
+ static isPathArray: (path: unknown) => path is PathArray;
691
+ static isPointInStroke: <T extends PathArray>(pathInput: string | T, point: {
692
+ x: number;
693
+ y: number;
694
+ }) => boolean;
695
+ static isRelativeArray: (path: unknown) => path is RelativeArray;
696
+ static isValidPath: (pathString: string) => boolean;
697
+ static samplePolygon: typeof samplePolygon;
698
+ static shapeParams: ShapeParams;
699
+ static shapeToPath: (element: ShapeTypes | ShapeOps, replace?: boolean, ownerDocument?: Document) => SVGPathElement | false;
700
+ static shapeToPathArray: (element: ShapeTypes | ShapeOps) => false | PathArray;
701
+ static absolutizeSegment: (segment: PathSegment, index: number, lastX: number, lastY: number) => AbsoluteSegment;
702
+ static 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[];
703
+ static getSVGMatrix: (transform: TransformObjectValues) => CSSMatrix;
704
+ static iterate: <T extends PathArray>(path: T, iterator: IteratorCallback<T>) => T;
705
+ static lineToCubic: (x1: number, y1: number, x2: number, y2: number) => number[];
706
+ static normalizePath: (pathInput: string | PathArray) => NormalArray;
707
+ static normalizeSegment: (segment: PathSegment, params: ParserParams) => NormalSegment;
708
+ static optimizePath: <T extends PathArray>(pathInput: T, roundOption?: number) => PathArray;
709
+ static projection2d: (m: CSSMatrix, point2D: PointTuple, origin: [number, number, number]) => PointTuple;
710
+ static quadToCubic: (x1: number, y1: number, qx: number, qy: number, x2: number, y2: number) => [number, number, number, number, number, number];
711
+ static relativizeSegment: (segment: PathSegment, index: number, lastX: number, lastY: number) => MSegment | RelativeSegment;
712
+ static reverseCurve: (path: CurveArray) => CurveArray;
713
+ static reversePath: <T extends PathArray>(pathInput: T) => T;
714
+ static roundPath: <T extends PathArray>(path: T, roundOption?: number | "off") => T;
715
+ static roundSegment: <T extends PathSegment>(segment: T, roundOption: number) => T;
716
+ static segmentToCubic: (segment: PathSegment, params: ParserParams) => MSegment | CSegment;
717
+ static shortenSegment: (segment: AbsoluteSegment, normalSegment: NormalSegment, params: ParserParams, prevCommand: PathCommand) => ShortSegment;
718
+ static splitPath: <T extends PathArray>(pathInput: T | string) => T[];
719
+ static equalizePaths: (pathInput1: string | PathArray, pathInput2: string | PathArray, initialCfg?: {}) => [MorphPathArray, MorphPathArray];
720
+ static equalizeSegments: (path1: PathArray | string, path2: PathArray | string, initialCfg?: EqualizationOptions) => [MorphPathArray, MorphPathArray];
721
+ static splitCubicSegment: typeof splitCubicSegment;
722
+ static transformPath: <T extends PathArray>(pathInput: T | string, transform?: Partial<TransformObject>) => T | AbsoluteArray;
723
+ static isPointInsideBBox: (bbox: BBoxMaxima, [x, y]: PointTuple) => boolean;
724
+ static pathsIntersection: <T extends string | PathArray>(pathInput1: T, pathInput2: T, justCount?: boolean) => number | IntersectionPoint[];
725
+ static boundingBoxIntersect: (a: BBoxMaxima, b: BBoxMaxima) => boolean;
726
+ static isMultiPath: <T extends PathArray>(path: string | T) => boolean;
727
+ static isClosedPath: <T extends PathArray>(path: T) => boolean;
728
+ static isPolylineArray: typeof isPolylineArray;
729
+ static version: string;
730
+ }
731
+ //#endregion
732
+ 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, 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, SVGPathCommander as default, hCommand, hSegment, lCommand, lSegment, mCommand, mSegment, qCommand, qSegment, sCommand, sSegment, tCommand, tSegment, vCommand, vSegment, zCommand, zSegment };
733
+ //# sourceMappingURL=index.d.ts.map