svg-path-commander 2.1.8 → 2.1.9

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