svg-path-commander 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +2 -2
- package/dist/index.d.ts +224 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +106 -6
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/util.d.ts +72 -3
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +2 -2
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.4] - 2026-08-04
|
|
4
|
+
### Fixed
|
|
5
|
+
- Build warnings: UMD bundle now uses a dedicated `src/browser.ts` entry so the `SVGPathCommander` global remains the class itself (no mixed-exports namespace), and the `output.dir`/`output.file` conflict is resolved — tree-shaking, named exports and type declarations are unaffected
|
|
6
|
+
- ESM bundle exports the `SVGPathCommander` named export alongside the default, with all types available in `dist/index.d.ts`
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [2.2.3] - 2026-08-04
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- Named `SVGPathCommander` export alongside the default export for better JSR documentation rendering
|
|
13
|
+
- Full JSDoc coverage for all class statics, instance properties, getters and every interface / type member — zero undocumented symbols per `deno doc --json` on both `index` and `util` entry points
|
|
14
|
+
- JSR `./util` subpath export in `deno.json`, mirroring the npm `svg-path-commander/util` entry
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Documentation moved from the GitHub wiki into the repository `wiki/` folder — the GitHub-hosted wiki pages are no longer available, and the README and wiki pages now reference the local `wiki/` folder instead
|
|
18
|
+
- Merged `NPM.md` and `JSR.md` into a single `Installation.md` (npm, pnpm, bun, Deno/JSR and CDN installation)
|
|
19
|
+
- Updated `Usage-Examples.md` with corrected output values verified against the current implementation
|
|
20
|
+
- Rebuilt `dist` and `docs` bundles
|
|
21
|
+
|
|
3
22
|
## [2.2.2] - 2026-08-03
|
|
4
23
|
|
|
5
24
|
### Added
|
package/README.md
CHANGED
|
@@ -284,7 +284,7 @@ const [eq1, eq2] = SVGPathCommander.equalizePaths(
|
|
|
284
284
|
```
|
|
285
285
|
|
|
286
286
|
# WIKI
|
|
287
|
-
For developer guidelines, and a complete list of static methods, head over to the [wiki
|
|
287
|
+
For developer guidelines, and a complete list of static methods, head over to the [`wiki/`](wiki/) folder in this repository.
|
|
288
288
|
|
|
289
289
|
|
|
290
290
|
# What Is It For?
|
|
@@ -324,4 +324,4 @@ For developer guidelines, and a complete list of static methods, head over to th
|
|
|
324
324
|
* a special thanks goes to [@vltansky](https://github.com/vltansky) for fixing tree-shaking in **SVGPathCommander**!
|
|
325
325
|
|
|
326
326
|
# License
|
|
327
|
-
**SVGPathCommander** is released under [MIT Licence](
|
|
327
|
+
**SVGPathCommander** is released under [MIT Licence](LICENSE).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v2.2.
|
|
2
|
+
* SVGPathCommander v2.2.4 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2026 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -7,149 +7,236 @@ import CSSMatrix from "@thednp/dommatrix";
|
|
|
7
7
|
//#region src/interface.d.ts
|
|
8
8
|
/** The properties of a path segment found by segment lookup utilities. */
|
|
9
9
|
type SegmentProperties = {
|
|
10
|
+
/** The path segment. */
|
|
10
11
|
segment: PathSegment;
|
|
12
|
+
/** The index of the segment in the path. */
|
|
11
13
|
index: number;
|
|
14
|
+
/** The length of the segment. */
|
|
12
15
|
length: number;
|
|
16
|
+
/** The distance from the start of the path to the end of the segment. */
|
|
13
17
|
lengthAtSegment: number;
|
|
14
18
|
};
|
|
15
19
|
/** The closest point on the path to a given point, with the distance and optional segment. */
|
|
16
20
|
type PointProperties = {
|
|
21
|
+
/** The closest point on the path to the given point. */
|
|
17
22
|
closest: {
|
|
23
|
+
/** The X coordinate of the closest point. */
|
|
18
24
|
x: number;
|
|
25
|
+
/** The Y coordinate of the closest point. */
|
|
19
26
|
y: number;
|
|
20
27
|
};
|
|
28
|
+
/** The distance from the given point to the closest point on the path. */
|
|
21
29
|
distance: number;
|
|
30
|
+
/** The segment which contains the closest point. */
|
|
22
31
|
segment?: SegmentProperties;
|
|
23
32
|
};
|
|
24
33
|
/** The attributes of a `<line>` element read by `shapeToPath`. */
|
|
25
34
|
type LineAttr = {
|
|
35
|
+
/** The element type. */
|
|
26
36
|
type: "line";
|
|
37
|
+
/** The X coordinate of the start point. */
|
|
27
38
|
x1: number;
|
|
39
|
+
/** The Y coordinate of the start point. */
|
|
28
40
|
y1: number;
|
|
41
|
+
/** The X coordinate of the end point. */
|
|
29
42
|
x2: number;
|
|
43
|
+
/** The Y coordinate of the end point. */
|
|
30
44
|
y2: number;
|
|
31
45
|
[key: string]: string | number;
|
|
32
46
|
};
|
|
33
47
|
/** The attributes of a `<polygon>` or `<polyline>` element read by `shapeToPath`. */
|
|
34
48
|
type PolyAttr = {
|
|
49
|
+
/** The element type. */
|
|
35
50
|
type: "polygon" | "polyline";
|
|
51
|
+
/** The points attribute value. */
|
|
36
52
|
points: string;
|
|
37
53
|
[key: string]: string | number;
|
|
38
54
|
};
|
|
39
55
|
/** The attributes of a `<circle>` element read by `shapeToPath`. */
|
|
40
56
|
type CircleAttr = {
|
|
57
|
+
/** The element type. */
|
|
41
58
|
type: "circle";
|
|
59
|
+
/** The X coordinate of the center. */
|
|
42
60
|
cx: number;
|
|
61
|
+
/** The Y coordinate of the center. */
|
|
43
62
|
cy: number;
|
|
63
|
+
/** The circle radius. */
|
|
44
64
|
r: number;
|
|
45
65
|
[key: string]: string | number;
|
|
46
66
|
};
|
|
47
67
|
/** The attributes of an `<ellipse>` element read by `shapeToPath`. */
|
|
48
68
|
type EllipseAttr = {
|
|
69
|
+
/** The element type. */
|
|
49
70
|
type: "ellipse";
|
|
71
|
+
/** The X coordinate of the center. */
|
|
50
72
|
cx: number;
|
|
73
|
+
/** The Y coordinate of the center. */
|
|
51
74
|
cy: number;
|
|
75
|
+
/** The X axis radius. */
|
|
52
76
|
rx: number;
|
|
77
|
+
/** The Y axis radius. */
|
|
53
78
|
ry?: number;
|
|
54
79
|
[key: string]: string | number | undefined;
|
|
55
80
|
};
|
|
56
81
|
/** The attributes of a `<rect>` element read by `shapeToPath`. */
|
|
57
82
|
type RectAttr = {
|
|
83
|
+
/** The element type. */
|
|
58
84
|
type: "rect";
|
|
85
|
+
/** The rectangle width. */
|
|
59
86
|
width: number;
|
|
87
|
+
/** The rectangle height. */
|
|
60
88
|
height: number;
|
|
89
|
+
/** The X coordinate of the top-left corner. */
|
|
61
90
|
x: number;
|
|
91
|
+
/** The Y coordinate of the top-left corner. */
|
|
62
92
|
y: number;
|
|
93
|
+
/** The X axis corner radius. */
|
|
63
94
|
rx?: number;
|
|
95
|
+
/** The Y axis corner radius. */
|
|
64
96
|
ry?: number;
|
|
65
97
|
[key: string]: string | number | undefined;
|
|
66
98
|
};
|
|
67
99
|
/** The attributes of a `<glyph>` element read by `shapeToPath`. */
|
|
68
100
|
type GlyphAttr = {
|
|
101
|
+
/** The element type. */
|
|
69
102
|
type: "glyph";
|
|
103
|
+
/** The path data of the glyph. */
|
|
70
104
|
d: string;
|
|
71
105
|
[key: string]: string | number;
|
|
72
106
|
};
|
|
73
107
|
/** The parameter names read from each SVG shape element by `shapeToPath`. */
|
|
74
108
|
type ShapeParams = {
|
|
109
|
+
/** The parameter names read from the `<line>` element. */
|
|
75
110
|
line: ["x1", "y1", "x2", "y2"];
|
|
111
|
+
/** The parameter names read from the `<circle>` element. */
|
|
76
112
|
circle: ["cx", "cy", "r"];
|
|
113
|
+
/** The parameter names read from the `<ellipse>` element. */
|
|
77
114
|
ellipse: ["cx", "cy", "rx", "ry"];
|
|
115
|
+
/** The parameter names read from the `<rect>` element. */
|
|
78
116
|
rect: ["width", "height", "x", "y", "rx", "ry"];
|
|
117
|
+
/** The parameter names read from the `<polygon>` element. */
|
|
79
118
|
polygon: ["points"];
|
|
119
|
+
/** The parameter names read from the `<polyline>` element. */
|
|
80
120
|
polyline: ["points"];
|
|
121
|
+
/** The parameter names read from the `<glyph>` element. */
|
|
81
122
|
glyph: ["d"];
|
|
82
123
|
};
|
|
83
124
|
/** The bounding box of a path, equivalent to the native `getBBox()` result. */
|
|
84
125
|
type PathBBox = {
|
|
126
|
+
/** The width of the bounding box. */
|
|
85
127
|
width: number;
|
|
128
|
+
/** The height of the bounding box. */
|
|
86
129
|
height: number;
|
|
130
|
+
/** The X coordinate of the top-left corner. */
|
|
87
131
|
x: number;
|
|
132
|
+
/** The Y coordinate of the top-left corner. */
|
|
88
133
|
y: number;
|
|
134
|
+
/** The X coordinate of the bottom-right corner. */
|
|
89
135
|
x2: number;
|
|
136
|
+
/** The Y coordinate of the bottom-right corner. */
|
|
90
137
|
y2: number;
|
|
138
|
+
/** The X coordinate of the center. */
|
|
91
139
|
cx: number;
|
|
140
|
+
/** The Y coordinate of the center. */
|
|
92
141
|
cy: number;
|
|
142
|
+
/** The Z coordinate of the center, used as transform origin for 3D projections. */
|
|
93
143
|
cz: number;
|
|
94
144
|
};
|
|
95
145
|
/** The minimum and maximum points of a segment bounding box. */
|
|
96
146
|
type SegmentLimits = {
|
|
147
|
+
/** The minimum coordinates of the segment. */
|
|
97
148
|
min: {
|
|
149
|
+
/** The minimum X coordinate. */
|
|
98
150
|
x: number;
|
|
151
|
+
/** The minimum Y coordinate. */
|
|
99
152
|
y: number;
|
|
100
153
|
};
|
|
154
|
+
/** The maximum coordinates of the segment. */
|
|
101
155
|
max: {
|
|
156
|
+
/** The maximum X coordinate. */
|
|
102
157
|
x: number;
|
|
158
|
+
/** The maximum Y coordinate. */
|
|
103
159
|
y: number;
|
|
104
160
|
};
|
|
105
161
|
};
|
|
106
162
|
/** The current state tracked by the SVG path string parser. */
|
|
107
163
|
type ParserParams = {
|
|
164
|
+
/** The X coordinate of the previous moveto point. */
|
|
108
165
|
mx: number;
|
|
166
|
+
/** The Y coordinate of the previous moveto point. */
|
|
109
167
|
my: number;
|
|
168
|
+
/** The X coordinate of the previous control point. */
|
|
110
169
|
x1: number;
|
|
170
|
+
/** The Y coordinate of the previous control point. */
|
|
111
171
|
y1: number;
|
|
172
|
+
/** The X coordinate of the second control point. */
|
|
112
173
|
x2: number;
|
|
174
|
+
/** The Y coordinate of the second control point. */
|
|
113
175
|
y2: number;
|
|
176
|
+
/** The X coordinate of the current point. */
|
|
114
177
|
x: number;
|
|
178
|
+
/** The Y coordinate of the current point. */
|
|
115
179
|
y: number;
|
|
180
|
+
/** The X coordinate of the previous quadratic control point. */
|
|
116
181
|
qx: number | null;
|
|
182
|
+
/** The Y coordinate of the previous quadratic control point. */
|
|
117
183
|
qy: number | null;
|
|
118
184
|
};
|
|
119
185
|
/** The result of a length computation factory: length, point and segment limits. */
|
|
120
186
|
type LengthFactory = {
|
|
187
|
+
/** The total length of the segment. */
|
|
121
188
|
length: number;
|
|
189
|
+
/** The point on the segment at the given length. */
|
|
122
190
|
point: {
|
|
191
|
+
/** The X coordinate of the point at the given length. */
|
|
123
192
|
x: number;
|
|
193
|
+
/** The Y coordinate of the point at the given length. */
|
|
124
194
|
y: number;
|
|
125
195
|
};
|
|
196
|
+
/** The minimum coordinates of the segment. */
|
|
126
197
|
min: {
|
|
198
|
+
/** The minimum X coordinate of the segment. */
|
|
127
199
|
x: number;
|
|
200
|
+
/** The minimum Y coordinate of the segment. */
|
|
128
201
|
y: number;
|
|
129
202
|
};
|
|
203
|
+
/** The maximum coordinates of the segment. */
|
|
130
204
|
max: {
|
|
205
|
+
/** The maximum X coordinate of the segment. */
|
|
131
206
|
x: number;
|
|
207
|
+
/** The maximum Y coordinate of the segment. */
|
|
132
208
|
y: number;
|
|
133
209
|
};
|
|
134
210
|
};
|
|
135
211
|
/** The `SVGPathCommander` instance options. */
|
|
136
212
|
type Options = {
|
|
213
|
+
/** The amount of decimals to round path values to, or "off" to disable rounding. */
|
|
137
214
|
round: "off" | number;
|
|
215
|
+
/** The transform origin used for path transformations. */
|
|
138
216
|
origin: number[];
|
|
139
217
|
};
|
|
140
218
|
/** A path segment and its transformation context (command letter and coordinates). */
|
|
141
219
|
type PathTransform = {
|
|
220
|
+
/** The current path segment. */
|
|
142
221
|
s: PathSegment;
|
|
222
|
+
/** The current path command letter. */
|
|
143
223
|
c: string;
|
|
224
|
+
/** The current X coordinate. */
|
|
144
225
|
x: number;
|
|
226
|
+
/** The current Y coordinate. */
|
|
145
227
|
y: number;
|
|
146
228
|
};
|
|
147
229
|
/** A transform function object with translate, rotate, scale, skew and origin. */
|
|
148
230
|
type TransformObject = {
|
|
231
|
+
/** A translate value, a number for all axes or an array of values. */
|
|
149
232
|
translate: number | number[];
|
|
233
|
+
/** A rotate value, a number for all axes or an array of values. */
|
|
150
234
|
rotate: number | number[];
|
|
235
|
+
/** A scale value, a number for all axes or an array of values. */
|
|
151
236
|
scale: number | number[];
|
|
237
|
+
/** A skew value, a number for all axes or an array of values. */
|
|
152
238
|
skew: number | number[];
|
|
239
|
+
/** The transform origin. */
|
|
153
240
|
origin: number[];
|
|
154
241
|
};
|
|
155
242
|
/** The keys of a `TransformObject`. */
|
|
@@ -306,17 +393,21 @@ type ShapeTags = "line" | "polyline" | "polygon" | "ellipse" | "circle" | "rect"
|
|
|
306
393
|
type ShapeOps = LineAttr | PolyAttr | PolyAttr | EllipseAttr | CircleAttr | RectAttr | GlyphAttr;
|
|
307
394
|
/** A `TransformObject` with a required 3D origin. */
|
|
308
395
|
type TransformObjectValues = Partial<TransformObject> & {
|
|
396
|
+
/** The transform origin. */
|
|
309
397
|
origin: [number, number, number];
|
|
310
398
|
};
|
|
311
399
|
/** A 2D point with `x` and `y` coordinates. */
|
|
312
400
|
type Point = {
|
|
401
|
+
/** The X coordinate. */
|
|
313
402
|
x: number;
|
|
403
|
+
/** The Y coordinate. */
|
|
314
404
|
y: number;
|
|
315
405
|
};
|
|
316
406
|
/** A 2D point as a tuple `[x, y]`. */
|
|
317
407
|
type PointTuple = [number, number];
|
|
318
408
|
/** A `Point` with a `t` parameter (a point on a curve at ratio `t`). */
|
|
319
409
|
type DerivedPoint = Point & {
|
|
410
|
+
/** The parameter ratio in `[0-1]`. */
|
|
320
411
|
t: number;
|
|
321
412
|
};
|
|
322
413
|
/** The six points of a quadratic Bezier curve (on-curve and off-curve control points). */
|
|
@@ -343,49 +434,72 @@ type IteratorCallback<T extends PathArray, K extends keyof T = number> = (segmen
|
|
|
343
434
|
type BBoxMaxima = [minX: number, minY: number, maxX: number, maxY: number];
|
|
344
435
|
/** A point on the path at a given length, including the `t` ratio. */
|
|
345
436
|
type PointAtLength = {
|
|
437
|
+
/** The X coordinate. */
|
|
346
438
|
x: number;
|
|
439
|
+
/** The Y coordinate. */
|
|
347
440
|
y: number;
|
|
441
|
+
/** The parameter ratio in `[0-1]`. */
|
|
348
442
|
t: number;
|
|
349
443
|
};
|
|
350
444
|
/** An intersection point between two curves, including both `t` ratios. */
|
|
351
445
|
type IntersectionPoint = {
|
|
446
|
+
/** The X coordinate of the intersection point. */
|
|
352
447
|
x: number;
|
|
448
|
+
/** The Y coordinate of the intersection point. */
|
|
353
449
|
y: number;
|
|
450
|
+
/** The parameter ratio of the first curve. */
|
|
354
451
|
t1: number;
|
|
452
|
+
/** The parameter ratio of the second curve. */
|
|
355
453
|
t2: number;
|
|
356
454
|
};
|
|
357
455
|
/** Options for computing intersections between two curves. */
|
|
358
456
|
interface IntersectionOptions {
|
|
457
|
+
/** Whether to only count the intersections without computing points. */
|
|
359
458
|
justCount?: boolean;
|
|
459
|
+
/** The epsilon value used for precision. */
|
|
360
460
|
epsilon?: number;
|
|
361
461
|
}
|
|
362
462
|
/** Options for equalizing a single path to a given segment count. */
|
|
363
463
|
interface PathEqualizationOptions {
|
|
364
|
-
/** @default "auto" */
|
|
464
|
+
/** The equalization mode. @default "auto" */
|
|
365
465
|
mode?: "line" | "curve" | "auto";
|
|
466
|
+
/** The number of sample points for the line mode. */
|
|
366
467
|
sampleSize?: number;
|
|
468
|
+
/** The amount of decimals to round values to. */
|
|
367
469
|
roundValues?: number;
|
|
470
|
+
/** Whether to close the path before equalization. */
|
|
368
471
|
close?: boolean;
|
|
369
472
|
}
|
|
370
473
|
/** Options for equalizing two paths for morphing. */
|
|
371
474
|
interface EqualizationOptions {
|
|
372
|
-
/** @default "auto" */
|
|
475
|
+
/** The equalization mode. @default "auto" */
|
|
373
476
|
mode?: "curve" | "auto";
|
|
477
|
+
/** The number of sample points for the line mode. */
|
|
374
478
|
sampleSize?: number;
|
|
479
|
+
/** The amount of decimals to round values to. */
|
|
375
480
|
roundValues?: number;
|
|
481
|
+
/** Whether to reverse the second path before equalization. */
|
|
376
482
|
reverse?: boolean;
|
|
483
|
+
/** Whether to close the path before equalization. */
|
|
377
484
|
close?: boolean;
|
|
485
|
+
/** The target segment count for both paths. */
|
|
378
486
|
target?: number;
|
|
379
487
|
}
|
|
380
488
|
/** `EqualizationOptions` without `reverse` and `target`, used for path pairs. */
|
|
381
489
|
type PathsEqualizationOptions = Omit<EqualizationOptions, "reverse" | "target">;
|
|
382
490
|
/** The geometric features of a path used for matching during morphing. */
|
|
383
491
|
interface PathFeature {
|
|
492
|
+
/** Whether the path is a polygon. */
|
|
384
493
|
isPoly: boolean;
|
|
494
|
+
/** The normalized path array. */
|
|
385
495
|
path: NormalArray;
|
|
496
|
+
/** The number of segments in the path. */
|
|
386
497
|
size: number;
|
|
498
|
+
/** The absolute area of the path. */
|
|
387
499
|
area: number;
|
|
500
|
+
/** The signed area of the path, negative for clockwise direction. */
|
|
388
501
|
signedArea: number;
|
|
502
|
+
/** The bounding box of the path. */
|
|
389
503
|
bbox: PathBBox;
|
|
390
504
|
}
|
|
391
505
|
//#endregion
|
|
@@ -1318,7 +1432,7 @@ declare const equalizePaths: (pathInput1: string | PathArray, pathInput2: string
|
|
|
1318
1432
|
* pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', true)
|
|
1319
1433
|
* // => 1
|
|
1320
1434
|
* pathsIntersection('M0 50C0 0,100 0,100 50', 'M50 0C100 0,100 100,50 100', false)
|
|
1321
|
-
* // => [{ x:
|
|
1435
|
+
* // => [{ x: 80.4136, y: 19.5864, t1: 0.7262, t2: 0.2738 }]
|
|
1322
1436
|
* ```
|
|
1323
1437
|
*/
|
|
1324
1438
|
declare const pathsIntersection: <T extends string | PathArray>(pathInput1: T, pathInput2: T, justCount?: boolean) => number | IntersectionPoint[];
|
|
@@ -1355,8 +1469,11 @@ declare const isPointInsideBBox: (bbox: BBoxMaxima, [x, y]: PointTuple) => boole
|
|
|
1355
1469
|
* @returns a new SVGPathCommander instance
|
|
1356
1470
|
*/
|
|
1357
1471
|
declare class SVGPathCommander {
|
|
1472
|
+
/** The parsed PathArray stored on the instance. */
|
|
1358
1473
|
segments: PathArray;
|
|
1474
|
+
/** The rounding option used for the output path string. */
|
|
1359
1475
|
round: number | "off";
|
|
1476
|
+
/** The transform origin used for path transformations. */
|
|
1360
1477
|
origin: [number, number, number];
|
|
1361
1478
|
/**
|
|
1362
1479
|
* @constructor
|
|
@@ -1364,6 +1481,12 @@ declare class SVGPathCommander {
|
|
|
1364
1481
|
* @param config instance options
|
|
1365
1482
|
*/
|
|
1366
1483
|
constructor(pathValue: string, config?: Partial<Options>);
|
|
1484
|
+
/**
|
|
1485
|
+
* Returns the path bounding box, equivalent to native `path.getBBox()`.
|
|
1486
|
+
*
|
|
1487
|
+
* @public
|
|
1488
|
+
* @returns the pathBBox
|
|
1489
|
+
*/
|
|
1367
1490
|
get bbox(): {
|
|
1368
1491
|
x: number;
|
|
1369
1492
|
y: number;
|
|
@@ -1375,6 +1498,12 @@ declare class SVGPathCommander {
|
|
|
1375
1498
|
cy: number;
|
|
1376
1499
|
cz: number;
|
|
1377
1500
|
};
|
|
1501
|
+
/**
|
|
1502
|
+
* Returns the total path length, equivalent to native `path.getTotalLength()`.
|
|
1503
|
+
*
|
|
1504
|
+
* @public
|
|
1505
|
+
* @returns the path total length
|
|
1506
|
+
*/
|
|
1378
1507
|
get length(): number;
|
|
1379
1508
|
/**
|
|
1380
1509
|
* Returns the path bounding box, equivalent to native `path.getBBox()`.
|
|
@@ -1458,7 +1587,7 @@ declare class SVGPathCommander {
|
|
|
1458
1587
|
* @example
|
|
1459
1588
|
* ```ts
|
|
1460
1589
|
* new SVGPathCommander('M0 0L100 0L100 100L0 100Z').reverse().toString()
|
|
1461
|
-
* // => 'M0
|
|
1590
|
+
* // => 'M0 100L100 100L100 0L0 0Z'
|
|
1462
1591
|
* ```
|
|
1463
1592
|
*
|
|
1464
1593
|
* @param onlySubpath - option to reverse all sub-paths except first
|
|
@@ -1490,7 +1619,7 @@ declare class SVGPathCommander {
|
|
|
1490
1619
|
* @example
|
|
1491
1620
|
* ```ts
|
|
1492
1621
|
* new SVGPathCommander('M10 10L10 10L90 90').optimize().toString()
|
|
1493
|
-
* // => 'M10
|
|
1622
|
+
* // => 'M10 10v0l80 80'
|
|
1494
1623
|
* ```
|
|
1495
1624
|
*
|
|
1496
1625
|
* @returns this for chaining
|
|
@@ -1548,8 +1677,14 @@ declare class SVGPathCommander {
|
|
|
1548
1677
|
* @returns void
|
|
1549
1678
|
*/
|
|
1550
1679
|
dispose(): void;
|
|
1680
|
+
/** The default instance options. */
|
|
1551
1681
|
static options: Options;
|
|
1682
|
+
/**
|
|
1683
|
+
* The DOMMatrix shim used for transformations.
|
|
1684
|
+
* @see https://github.com/thednp/dommatrix
|
|
1685
|
+
*/
|
|
1552
1686
|
static CSSMatrix: typeof CSSMatrix;
|
|
1687
|
+
/** The tools for elliptical arc computation. */
|
|
1553
1688
|
static arcTools: {
|
|
1554
1689
|
angleBetween: (v0: Point, v1: Point) => number;
|
|
1555
1690
|
arcLength: (rx: number, ry: number, theta: number) => number;
|
|
@@ -1573,6 +1708,7 @@ declare class SVGPathCommander {
|
|
|
1573
1708
|
y: number;
|
|
1574
1709
|
};
|
|
1575
1710
|
};
|
|
1711
|
+
/** The tools for Bezier curve computation. */
|
|
1576
1712
|
static bezierTools: {
|
|
1577
1713
|
bezierLength: (derivativeFn: DeriveCallback) => number;
|
|
1578
1714
|
bezierLengthAtT: (derivativeFn: DeriveCallback, t: number) => number;
|
|
@@ -1589,6 +1725,7 @@ declare class SVGPathCommander {
|
|
|
1589
1725
|
minmaxQ: ([v1, cp, v2]: [number, number, number]) => PointTuple;
|
|
1590
1726
|
Tvalues: number[];
|
|
1591
1727
|
};
|
|
1728
|
+
/** The tools for cubic Bezier computation. */
|
|
1592
1729
|
static cubicTools: {
|
|
1593
1730
|
getCubicBBox: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => BBoxMaxima;
|
|
1594
1731
|
getCubicLength: (x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number) => number;
|
|
@@ -1601,6 +1738,7 @@ declare class SVGPathCommander {
|
|
|
1601
1738
|
y: number;
|
|
1602
1739
|
};
|
|
1603
1740
|
};
|
|
1741
|
+
/** The tools for line segment computation. */
|
|
1604
1742
|
static lineTools: {
|
|
1605
1743
|
getLineBBox: (x1: number, y1: number, x2: number, y2: number) => [number, number, number, number];
|
|
1606
1744
|
getLineLength: (x1: number, y1: number, x2: number, y2: number) => number;
|
|
@@ -1609,11 +1747,13 @@ declare class SVGPathCommander {
|
|
|
1609
1747
|
y: number;
|
|
1610
1748
|
};
|
|
1611
1749
|
};
|
|
1750
|
+
/** The tools for polygon computation. */
|
|
1612
1751
|
static polygonTools: {
|
|
1613
1752
|
polygonArea: (polygon: PointTuple[]) => number;
|
|
1614
1753
|
polygonLength: (polygon: PointTuple[]) => number;
|
|
1615
1754
|
polygonCentroid: (polygon: PointTuple[]) => PointTuple;
|
|
1616
1755
|
};
|
|
1756
|
+
/** The tools for quadratic Bezier computation. */
|
|
1617
1757
|
static quadTools: {
|
|
1618
1758
|
getPointAtQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number, distance?: number) => {
|
|
1619
1759
|
x: number;
|
|
@@ -1626,23 +1766,41 @@ declare class SVGPathCommander {
|
|
|
1626
1766
|
getQuadBBox: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => [number, number, number, number];
|
|
1627
1767
|
getQuadLength: (x1: number, y1: number, cx: number, cy: number, x2: number, y2: number) => number;
|
|
1628
1768
|
};
|
|
1769
|
+
/** Parses a path string value or object and returns an array */
|
|
1629
1770
|
static pathToAbsolute: typeof pathToAbsolute;
|
|
1771
|
+
/** Parses a path string value or object and returns an array */
|
|
1630
1772
|
static pathToRelative: typeof pathToRelative;
|
|
1773
|
+
/** Parses a path string or PathArray and returns a new one */
|
|
1631
1774
|
static pathToCurve: typeof pathToCurve;
|
|
1775
|
+
/** Returns a valid `d` attribute string value created */
|
|
1632
1776
|
static pathToString: typeof pathToString;
|
|
1777
|
+
/** Returns the square root of the distance */
|
|
1633
1778
|
static distanceSquareRoot: typeof distanceSquareRoot;
|
|
1779
|
+
/** Returns the coordinates of a specified distance */
|
|
1634
1780
|
static midPoint: typeof midPoint;
|
|
1781
|
+
/** Returns an {x,y} vector rotated by a given */
|
|
1635
1782
|
static rotateVector: typeof rotateVector;
|
|
1783
|
+
/** Rounds a number to the specified number of decimal places. */
|
|
1636
1784
|
static roundTo: typeof roundTo;
|
|
1785
|
+
/** Parses a path string value and returns an array */
|
|
1637
1786
|
static parsePathString: typeof parsePathString;
|
|
1787
|
+
/** Breaks the parsing of a pathString once a segment is finalized. */
|
|
1638
1788
|
static finalizeSegment: typeof finalizeSegment;
|
|
1789
|
+
/** Error message prefix used when a path string cannot be parsed. */
|
|
1639
1790
|
static invalidPathValue: string;
|
|
1791
|
+
/** Checks if the character is an A (arc-to) path command. */
|
|
1640
1792
|
static isArcCommand: typeof isArcCommand;
|
|
1793
|
+
/** Checks if a character is a digit. */
|
|
1641
1794
|
static isDigit: typeof isDigit;
|
|
1795
|
+
/** Checks if the character is or belongs to a number. */
|
|
1642
1796
|
static isDigitStart: typeof isDigitStart;
|
|
1797
|
+
/** Checks if the character is a MoveTo command. */
|
|
1643
1798
|
static isMoveCommand: typeof isMoveCommand;
|
|
1799
|
+
/** Checks if the character is a path command. */
|
|
1644
1800
|
static isPathCommand: typeof isPathCommand;
|
|
1801
|
+
/** Checks if the character is a space. */
|
|
1645
1802
|
static isSpace: typeof isSpace;
|
|
1803
|
+
/** The number of parameters for each path command. */
|
|
1646
1804
|
static paramsCount: {
|
|
1647
1805
|
a: number;
|
|
1648
1806
|
c: number;
|
|
@@ -1656,66 +1814,125 @@ declare class SVGPathCommander {
|
|
|
1656
1814
|
v: number;
|
|
1657
1815
|
z: number;
|
|
1658
1816
|
};
|
|
1817
|
+
/** Default parser parameters object used to track position state */
|
|
1659
1818
|
static paramsParser: ParserParams;
|
|
1819
|
+
/** The `PathParser` is used by the `parsePathString` static method */
|
|
1660
1820
|
static PathParser: typeof PathParser;
|
|
1821
|
+
/** Validates an A (arc-to) specific path command value. */
|
|
1661
1822
|
static scanFlag: typeof scanFlag;
|
|
1823
|
+
/** Validates every character of the path string, */
|
|
1662
1824
|
static scanParam: typeof scanParam;
|
|
1825
|
+
/** Scans every character in the path string to determine */
|
|
1663
1826
|
static scanSegment: typeof scanSegment;
|
|
1827
|
+
/** Points the parser to the next character in the */
|
|
1664
1828
|
static skipSpaces: typeof skipSpaces;
|
|
1829
|
+
/** Small threshold value used for floating-point distance comparisons in path calculations. */
|
|
1665
1830
|
static distanceEpsilon: number;
|
|
1831
|
+
/** Checks a `PathArray` for an unnecessary `Z` segment */
|
|
1666
1832
|
static fixPath: typeof fixPath;
|
|
1833
|
+
/** Returns the point in path closest to a given point. */
|
|
1667
1834
|
static getClosestPoint: typeof getClosestPoint;
|
|
1835
|
+
/** Check if a path is drawn clockwise and returns true if so, */
|
|
1668
1836
|
static getDrawDirection: typeof getDrawDirection;
|
|
1837
|
+
/** Returns the area of a single cubic-bezier segment. */
|
|
1669
1838
|
static getPathArea: typeof getPathArea;
|
|
1839
|
+
/** Calculates the bounding box of a path. */
|
|
1670
1840
|
static getPathBBox: typeof getPathBBox;
|
|
1841
|
+
/** Returns [x,y] coordinates of a point at a given length along a path. */
|
|
1671
1842
|
static getPointAtLength: typeof getPointAtLength;
|
|
1843
|
+
/** Returns the segment, its index and length as well as */
|
|
1672
1844
|
static getPropertiesAtLength: typeof getPropertiesAtLength;
|
|
1845
|
+
/** Returns the point and segment in path closest to a given point as well as */
|
|
1673
1846
|
static getPropertiesAtPoint: typeof getPropertiesAtPoint;
|
|
1847
|
+
/** Returns the segment at a given length. */
|
|
1674
1848
|
static getSegmentAtLength: typeof getSegmentAtLength;
|
|
1849
|
+
/** Returns the path segment which contains a given point. */
|
|
1675
1850
|
static getSegmentOfPoint: typeof getSegmentOfPoint;
|
|
1851
|
+
/** Returns the total length of a path, equivalent to `shape.getTotalLength()`. */
|
|
1676
1852
|
static getTotalLength: typeof getTotalLength;
|
|
1853
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
1677
1854
|
static isAbsoluteArray: typeof isAbsoluteArray;
|
|
1855
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
1678
1856
|
static isCurveArray: typeof isCurveArray;
|
|
1857
|
+
/** Checks if a path is a polygon (only M, L, H, V, Z commands). */
|
|
1679
1858
|
static isPolygonArray: typeof isPolygonArray;
|
|
1859
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
1680
1860
|
static isNormalizedArray: typeof isNormalizedArray;
|
|
1861
|
+
/** Iterates an array to check if it's an actual `pathArray`. */
|
|
1681
1862
|
static isPathArray: typeof isPathArray;
|
|
1863
|
+
/** Checks if a given point is in the stroke of a path. */
|
|
1682
1864
|
static isPointInStroke: typeof isPointInStroke;
|
|
1865
|
+
/** Iterates an array to check if it's a `pathArray` */
|
|
1683
1866
|
static isRelativeArray: typeof isRelativeArray;
|
|
1867
|
+
/** Parses a path string value to determine its validity */
|
|
1684
1868
|
static isValidPath: typeof isValidPath;
|
|
1869
|
+
/** Samples points from a path to form a polygon approximation. */
|
|
1685
1870
|
static samplePolygon: typeof samplePolygon;
|
|
1871
|
+
/** Supported shapes and their specific parameters. */
|
|
1686
1872
|
static shapeParams: ShapeParams;
|
|
1873
|
+
/** Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`, */
|
|
1687
1874
|
static shapeToPath: typeof shapeToPath;
|
|
1875
|
+
/** Returns a new PathArray from line attributes. */
|
|
1688
1876
|
static shapeToPathArray: typeof shapeToPathArray;
|
|
1877
|
+
/** Returns an absolute segment of a `PathArray` object. */
|
|
1689
1878
|
static absolutizeSegment: typeof absolutizeSegment;
|
|
1879
|
+
/** Converts A (arc-to) segments to C (cubic-bezier-to). */
|
|
1690
1880
|
static arcToCubic: typeof arcToCubic;
|
|
1881
|
+
/** Returns a transformation matrix to apply to `<path>` elements. */
|
|
1691
1882
|
static getSVGMatrix: typeof getSVGMatrix;
|
|
1883
|
+
/** Iterates over a `PathArray`, executing a callback for each segment. */
|
|
1692
1884
|
static iterate: typeof iterate;
|
|
1885
|
+
/** Converts an L (line-to) segment to C (cubic-bezier). */
|
|
1693
1886
|
static lineToCubic: typeof lineToCubic;
|
|
1887
|
+
/** Parses a path string or PathArray, then iterates the result for: */
|
|
1694
1888
|
static normalizePath: typeof normalizePath;
|
|
1889
|
+
/** Normalizes a single segment of a `pathArray` object. */
|
|
1695
1890
|
static normalizeSegment: typeof normalizeSegment;
|
|
1891
|
+
/** Optimizes a PathArray: */
|
|
1696
1892
|
static optimizePath: typeof optimizePath;
|
|
1893
|
+
/** Transforms a specified point using a matrix, returning a new */
|
|
1697
1894
|
static projection2d: typeof projection2d;
|
|
1895
|
+
/** Converts a Q (quadratic-bezier) segment to C (cubic-bezier). */
|
|
1698
1896
|
static quadToCubic: typeof quadToCubic;
|
|
1897
|
+
/** Returns a relative segment of a `PathArray` object. */
|
|
1699
1898
|
static relativizeSegment: typeof relativizeSegment;
|
|
1899
|
+
/** Reverses all segments of a `pathArray` */
|
|
1700
1900
|
static reverseCurve: typeof reverseCurve;
|
|
1901
|
+
/** Reverses all segments of a PathArray and returns a new PathArray */
|
|
1701
1902
|
static reversePath: typeof reversePath;
|
|
1903
|
+
/** Rounds the values of a `pathArray` instance to */
|
|
1702
1904
|
static roundPath: typeof roundPath;
|
|
1905
|
+
/** Rounds the numeric values of a path segment to the specified precision. */
|
|
1703
1906
|
static roundSegment: typeof roundSegment;
|
|
1907
|
+
/** Converts any segment to C (cubic-bezier). */
|
|
1704
1908
|
static segmentToCubic: typeof segmentToCubic;
|
|
1909
|
+
/** Shorten a single segment of a `pathArray` object. */
|
|
1705
1910
|
static shortenSegment: typeof shortenSegment;
|
|
1911
|
+
/** Split a path string or PathArray into an array of sub-paths. */
|
|
1706
1912
|
static splitPath: typeof splitPath;
|
|
1913
|
+
/** Equalizes two paths for morphing (single/multi subpath). */
|
|
1707
1914
|
static equalizePaths: typeof equalizePaths;
|
|
1915
|
+
/** Equalizes two paths for morphing (single subpath only). */
|
|
1708
1916
|
static equalizeSegments: typeof equalizeSegments;
|
|
1917
|
+
/** Split a cubic Bézier into two cubics at parameter t [0–1]. */
|
|
1709
1918
|
static splitCubicSegment: typeof splitCubicSegment;
|
|
1919
|
+
/** Apply a 2D / 3D transformation to a PathArray. */
|
|
1710
1920
|
static transformPath: typeof transformPath;
|
|
1921
|
+
/** Checks if a point is inside a bounding box. */
|
|
1711
1922
|
static isPointInsideBBox: typeof isPointInsideBBox;
|
|
1923
|
+
/** Finds intersection points between two paths. */
|
|
1712
1924
|
static pathsIntersection: typeof pathsIntersection;
|
|
1925
|
+
/** Checks if two bounding boxes intersect. */
|
|
1713
1926
|
static boundingBoxIntersect: typeof boundingBoxIntersect;
|
|
1927
|
+
/** Determines if an SVG path contains multiple subpaths. */
|
|
1714
1928
|
static isMultiPath: typeof isMultiPath;
|
|
1929
|
+
/** Check if a PathArray is closed, which means its last segment is a Z. */
|
|
1715
1930
|
static isClosedPath: typeof isClosedPath;
|
|
1931
|
+
/** Checks if a path is a polyline (only M, L, H, V commands). */
|
|
1716
1932
|
static isPolylineArray: typeof isPolylineArray;
|
|
1933
|
+
/** The library version. */
|
|
1717
1934
|
static version: string;
|
|
1718
1935
|
}
|
|
1719
1936
|
//#endregion
|
|
1720
|
-
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,
|
|
1937
|
+
export { ACommand, ASegment, AbsoluteArray, AbsoluteCommand, AbsoluteSegment, ArcCoordinates, ArcSegment, BBoxMaxima, CCommand, CSegment, CircleAttr, CloseSegment, ClosedCurveArray, CubicCoordinates, CubicPoints, CubicSegment, CurveArray, DeriveCallback, DerivedCubicPoints, DerivedPoint, DerivedQuadPoints, DigitNumber, EllipseAttr, EqualizationOptions, GlyphAttr, HCommand, HSegment, HorLineSegment, IntersectionOptions, IntersectionPoint, IteratorCallback, LCommand, LSegment, LengthFactory, LineAttr, LineCoordinates, LineSegment, MCommand, MSegment, MorphPathArray, MoveSegment, NormalArray, NormalSegment, Options, ParserParams, PathArray, PathBBox, PathCommand, PathCommandNumber, PathEqualizationOptions, PathFeature, PathSegment, PathTransform, PathsEqualizationOptions, Point, PointAtLength, PointProperties, PointTuple, PolyAttr, PolygonArray, PolylineArray, QCommand, QSegment, QuadCoordinates, QuadPoints, QuadSegment, RectAttr, RelativeArray, RelativeCommand, RelativeSegment, SCommand, SSegment, SVGPathCommander, SVGPathCommander as default, SegmentLimits, SegmentProperties, ShapeOps, ShapeParams, ShapeTags, ShapeTypes, ShortCubicSegment, ShortQuadSegment, ShortSegment, SpaceNumber, TCommand, TSegment, TransformEntries, TransformObject, TransformObjectValues, TransformProps, VCommand, VSegment, VertLineSegment, ZCommand, ZSegment, aCommand, aSegment, cCommand, cSegment, hCommand, hSegment, lCommand, lSegment, mCommand, mSegment, qCommand, qSegment, sCommand, sSegment, tCommand, tSegment, vCommand, vSegment, zCommand, zSegment };
|
|
1721
1938
|
//# sourceMappingURL=index.d.ts.map
|