svg-path-commander 0.1.21 → 0.1.22
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/README.md +72 -12
- package/dist/svg-path-commander.esm.js +647 -190
- package/dist/svg-path-commander.esm.min.js +2 -2
- package/dist/svg-path-commander.js +670 -189
- package/dist/svg-path-commander.min.js +2 -2
- package/package.json +1 -1
- package/src/convert/pathToAbsolute.js +3 -2
- package/src/convert/pathToCurve.js +2 -1
- package/src/convert/pathToRelative.js +2 -1
- package/src/parser/paramsCount.js +1 -0
- package/src/parser/parsePathString.js +4 -3
- package/src/parser/pathParser.js +2 -1
- package/src/parser/scanSegment.js +0 -1
- package/src/process/fixPath.js +1 -1
- package/src/process/lineToCubic.js +4 -5
- package/src/process/normalizePath.js +4 -2
- package/src/util/getClosestPoint.js +12 -0
- package/src/util/getCubicSize.js +41 -39
- package/src/util/getPathArea.js +19 -19
- package/src/util/getPathBBox.js +0 -11
- package/src/util/getPathLength.js +9 -9
- package/src/util/getPointAtLength.js +6 -29
- package/src/util/getPointAtPathLength.js +44 -0
- package/src/util/getPropertiesAtLength.js +62 -0
- package/src/util/getPropertiesAtPoint.js +77 -0
- package/src/util/getSegmentAtLength.js +13 -0
- package/src/util/getSegmentOfPoint.js +14 -0
- package/src/util/getTotalLength.js +15 -0
- package/src/util/isAbsoluteArray.js +2 -1
- package/src/util/isCurveArray.js +2 -1
- package/src/util/isNormalizedArray.js +2 -1
- package/src/util/isPointInStroke.js +13 -0
- package/src/util/isRelativeArray.js +2 -1
- package/src/util/pathLengthFactory.js +99 -0
- package/src/util/segmentArcFactory.js +42 -0
- package/src/util/segmentCubicFactory.js +73 -0
- package/src/util/segmentLineFactory.js +30 -0
- package/src/util/segmentQuadFactory.js +70 -0
- package/src/util/util.js +19 -1
- package/types/index.d.ts +14 -5
- package/types/more/modules.ts +17 -5
- package/types/more/svg.d.ts +21 -0
- package/types/svg-path-commander.d.ts +242 -122
- package/src/util/getPointAtSegLength.js +0 -28
- package/src/util/getSegArcLength.js +0 -27
- package/src/util/getSegCubicLength.js +0 -52
- package/src/util/getSegLineLength.js +0 -14
- package/src/util/getSegQuadLength.js +0 -31
package/types/index.d.ts
CHANGED
|
@@ -57,12 +57,19 @@ export { default as getDrawDirection } from "svg-path-commander/src/util/getDraw
|
|
|
57
57
|
export { default as getPathArea } from "svg-path-commander/src/util/getPathArea";
|
|
58
58
|
export { default as getPathBBox } from "svg-path-commander/src/util/getPathBBox";
|
|
59
59
|
export { default as getPathLength } from "svg-path-commander/src/util/getPathLength";
|
|
60
|
+
export { default as getTotalLength } from "svg-path-commander/src/util/getTotalLength";
|
|
61
|
+
export { default as segmentLineFactory } from "svg-path-commander/src/util/segmentLineFactory";
|
|
62
|
+
export { default as segmentArcFactory } from "svg-path-commander/src/util/segmentArcFactory";
|
|
63
|
+
export { default as segmentCubicFactory } from "svg-path-commander/src/util/segmentCubicFactory";
|
|
64
|
+
export { default as segmentQuadFactory } from "svg-path-commander/src/util/segmentQuadFactory";
|
|
60
65
|
export { default as getPointAtLength } from "svg-path-commander/src/util/getPointAtLength";
|
|
61
|
-
export { default as
|
|
62
|
-
export { default as
|
|
63
|
-
export { default as
|
|
64
|
-
export { default as
|
|
65
|
-
export { default as
|
|
66
|
+
export { default as getPointAtPathLength } from "svg-path-commander/src/util/getPointAtPathLength";
|
|
67
|
+
export { default as getPropertiesAtPoint } from "svg-path-commander/src/util/getPropertiesAtPoint";
|
|
68
|
+
export { default as getPropertiesAtLength } from "svg-path-commander/src/util/getPropertiesAtLength";
|
|
69
|
+
export { default as getClosestPoint } from "svg-path-commander/src/util/getClosestPoint";
|
|
70
|
+
export { default as getSegmentAtLength } from "svg-path-commander/src/util/getSegmentAtLength";
|
|
71
|
+
export { default as getSegmentOfPoint } from "svg-path-commander/src/util/getSegmentOfPoint";
|
|
72
|
+
export { default as isPointInStroke } from "svg-path-commander/src/util/isPointInStroke";
|
|
66
73
|
export { default as isAbsoluteArray } from "svg-path-commander/src/util/isAbsoluteArray";
|
|
67
74
|
export { default as isCurveArray } from "svg-path-commander/src/util/isCurveArray";
|
|
68
75
|
export { default as isNormalizedArray } from "svg-path-commander/src/util/isNormalizedArray";
|
|
@@ -95,6 +102,7 @@ export {
|
|
|
95
102
|
QSegment, qSegment, quadSegment,
|
|
96
103
|
TSegment, tSegment, shortQuadSegment,
|
|
97
104
|
ZSegment, zSegment, closeSegment,
|
|
105
|
+
segmentProperties,
|
|
98
106
|
|
|
99
107
|
shortSegment, absoluteSegment, relativeSegment, normalSegment, pathSegment,
|
|
100
108
|
pathArray, absoluteArray, relativeArray, normalArray,
|
|
@@ -111,4 +119,5 @@ export {
|
|
|
111
119
|
|
|
112
120
|
options,
|
|
113
121
|
parserParams,
|
|
122
|
+
pointProperties,
|
|
114
123
|
} from './more/svg';
|
package/types/more/modules.ts
CHANGED
|
@@ -56,13 +56,25 @@ export { default as getCubicSize } from '../../src/util/getCubicSize';
|
|
|
56
56
|
export { default as getDrawDirection } from '../../src/util/getDrawDirection';
|
|
57
57
|
export { default as getPathArea } from '../../src/util/getPathArea';
|
|
58
58
|
export { default as getPathBBox } from '../../src/util/getPathBBox';
|
|
59
|
+
|
|
59
60
|
export { default as getPathLength } from '../../src/util/getPathLength';
|
|
61
|
+
export { default as getTotalLength } from '../../src/util/getTotalLength';
|
|
62
|
+
|
|
63
|
+
export { default as segmentLineFactory } from '../../src/util/segmentLineFactory';
|
|
64
|
+
export { default as segmentArcFactory } from '../../src/util/segmentArcFactory';
|
|
65
|
+
export { default as segmentCubicFactory } from '../../src/util/segmentCubicFactory';
|
|
66
|
+
export { default as segmentQuadFactory } from '../../src/util/segmentQuadFactory';
|
|
67
|
+
|
|
60
68
|
export { default as getPointAtLength } from '../../src/util/getPointAtLength';
|
|
61
|
-
export { default as
|
|
62
|
-
|
|
63
|
-
export { default as
|
|
64
|
-
export { default as
|
|
65
|
-
export { default as
|
|
69
|
+
export { default as getPointAtPathLength } from '../../src/util/getPointAtPathLength';
|
|
70
|
+
|
|
71
|
+
export { default as getPropertiesAtPoint } from '../../src/util/getPropertiesAtPoint';
|
|
72
|
+
export { default as getPropertiesAtLength } from '../../src/util/getPropertiesAtLength';
|
|
73
|
+
export { default as getClosestPoint } from '../../src/util/getClosestPoint';
|
|
74
|
+
export { default as getSegmentAtLength } from '../../src/util/getSegmentAtLength';
|
|
75
|
+
export { default as getSegmentOfPoint } from '../../src/util/getSegmentOfPoint';
|
|
76
|
+
export { default as isPointInStroke } from '../../src/util/isPointInStroke';
|
|
77
|
+
|
|
66
78
|
export { default as isAbsoluteArray } from '../../src/util/isAbsoluteArray';
|
|
67
79
|
export { default as isCurveArray } from '../../src/util/isCurveArray';
|
|
68
80
|
export { default as isNormalizedArray } from '../../src/util/isNormalizedArray';
|
package/types/more/svg.d.ts
CHANGED
|
@@ -79,6 +79,18 @@ export type arcSegment = ASegment | aSegment;
|
|
|
79
79
|
export type pathSegment = moveSegment | lineSegment | vertLineSegment | horLineSegment | closeSegment
|
|
80
80
|
| cubicSegment | shortCubicSegment | quadSegment | shortQuadSegment | arcSegment;
|
|
81
81
|
|
|
82
|
+
export interface segmentProperties {
|
|
83
|
+
/** the segment */
|
|
84
|
+
segment: pathSegment,
|
|
85
|
+
/** the segment index */
|
|
86
|
+
index: number,
|
|
87
|
+
/** the segment length */
|
|
88
|
+
length: number;
|
|
89
|
+
/** the length including the segment length */
|
|
90
|
+
lengthAtSegment: number,
|
|
91
|
+
[key: string]: any
|
|
92
|
+
}
|
|
93
|
+
|
|
82
94
|
export type shortSegment = vertLineSegment | horLineSegment | shortCubicSegment | shortQuadSegment | closeSegment;
|
|
83
95
|
export type absoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
|
|
84
96
|
export type relativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
|
|
@@ -179,4 +191,13 @@ export interface parserParams {
|
|
|
179
191
|
x: number; y: number;
|
|
180
192
|
qx: number | null;
|
|
181
193
|
qy: number | null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface pointProperties {
|
|
197
|
+
closest: {
|
|
198
|
+
x: number,
|
|
199
|
+
y: number,
|
|
200
|
+
}
|
|
201
|
+
distance: number,
|
|
202
|
+
segment?: segmentProperties,
|
|
182
203
|
}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
declare module "svg-path-commander/src/parser/paramsCount" {
|
|
2
2
|
export default paramsCount;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const m: number;
|
|
9
|
-
const r: number;
|
|
10
|
-
const q: number;
|
|
11
|
-
const s: number;
|
|
12
|
-
const t: number;
|
|
13
|
-
const v: number;
|
|
14
|
-
const z: number;
|
|
15
|
-
}
|
|
3
|
+
/**
|
|
4
|
+
* Segment params length
|
|
5
|
+
* @type {Record<string, number>}
|
|
6
|
+
*/
|
|
7
|
+
const paramsCount: Record<string, number>;
|
|
16
8
|
}
|
|
17
9
|
declare module "svg-path-commander/src/parser/finalizeSegment" {
|
|
18
10
|
/**
|
|
@@ -120,14 +112,16 @@ declare module "svg-path-commander/src/process/clonePath" {
|
|
|
120
112
|
}
|
|
121
113
|
declare module "svg-path-commander/src/parser/pathParser" {
|
|
122
114
|
/**
|
|
123
|
-
* The `PathParser` used by the
|
|
115
|
+
* The `PathParser` is used by the `parsePathString` static method
|
|
116
|
+
* to generate a `pathArray`.
|
|
124
117
|
*
|
|
125
118
|
* @param {string} pathString
|
|
126
119
|
*/
|
|
127
120
|
export default function PathParser(pathString: string): void;
|
|
128
121
|
export default class PathParser {
|
|
129
122
|
/**
|
|
130
|
-
* The `PathParser` used by the
|
|
123
|
+
* The `PathParser` is used by the `parsePathString` static method
|
|
124
|
+
* to generate a `pathArray`.
|
|
131
125
|
*
|
|
132
126
|
* @param {string} pathString
|
|
133
127
|
*/
|
|
@@ -174,40 +168,40 @@ declare module "svg-path-commander/src/util/isAbsoluteArray" {
|
|
|
174
168
|
* Iterates an array to check if it's a `pathArray`
|
|
175
169
|
* with all absolute values.
|
|
176
170
|
*
|
|
177
|
-
* @param {SVGPathCommander.pathArray} path the `pathArray` to be checked
|
|
171
|
+
* @param {string | SVGPathCommander.pathArray} path the `pathArray` to be checked
|
|
178
172
|
* @returns {boolean} iteration result
|
|
179
173
|
*/
|
|
180
|
-
export default function isAbsoluteArray(path: SVGPathCommander.pathArray): boolean;
|
|
174
|
+
export default function isAbsoluteArray(path: string | SVGPathCommander.pathArray): boolean;
|
|
181
175
|
}
|
|
182
176
|
declare module "svg-path-commander/src/convert/pathToAbsolute" {
|
|
183
177
|
/**
|
|
184
178
|
* Parses a path string value or object and returns an array
|
|
185
179
|
* of segments, all converted to absolute values.
|
|
186
180
|
*
|
|
187
|
-
* @param {SVGPathCommander.pathArray
|
|
181
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the path string | object
|
|
188
182
|
* @returns {SVGPathCommander.absoluteArray} the resulted `pathArray` with absolute values
|
|
189
183
|
*/
|
|
190
|
-
export default function pathToAbsolute(pathInput: SVGPathCommander.pathArray
|
|
184
|
+
export default function pathToAbsolute(pathInput: string | SVGPathCommander.pathArray): SVGPathCommander.absoluteArray;
|
|
191
185
|
}
|
|
192
186
|
declare module "svg-path-commander/src/util/isRelativeArray" {
|
|
193
187
|
/**
|
|
194
188
|
* Iterates an array to check if it's a `pathArray`
|
|
195
189
|
* with relative values.
|
|
196
190
|
*
|
|
197
|
-
* @param {SVGPathCommander.pathArray} path the `pathArray` to be checked
|
|
191
|
+
* @param {string | SVGPathCommander.pathArray} path the `pathArray` to be checked
|
|
198
192
|
* @returns {boolean} iteration result
|
|
199
193
|
*/
|
|
200
|
-
export default function isRelativeArray(path: SVGPathCommander.pathArray): boolean;
|
|
194
|
+
export default function isRelativeArray(path: string | SVGPathCommander.pathArray): boolean;
|
|
201
195
|
}
|
|
202
196
|
declare module "svg-path-commander/src/convert/pathToRelative" {
|
|
203
197
|
/**
|
|
204
198
|
* Parses a path string value or object and returns an array
|
|
205
199
|
* of segments, all converted to relative values.
|
|
206
200
|
*
|
|
207
|
-
* @param {SVGPathCommander.pathArray} pathInput the path string | object
|
|
201
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the path string | object
|
|
208
202
|
* @returns {SVGPathCommander.relativeArray} the resulted `pathArray` with relative values
|
|
209
203
|
*/
|
|
210
|
-
export default function pathToRelative(pathInput: SVGPathCommander.pathArray): SVGPathCommander.relativeArray;
|
|
204
|
+
export default function pathToRelative(pathInput: string | SVGPathCommander.pathArray): SVGPathCommander.relativeArray;
|
|
211
205
|
}
|
|
212
206
|
declare module "svg-path-commander/src/process/fixArc" {
|
|
213
207
|
/**
|
|
@@ -270,10 +264,10 @@ declare module "svg-path-commander/src/util/isNormalizedArray" {
|
|
|
270
264
|
* with all segments are in non-shorthand notation
|
|
271
265
|
* with absolute values.
|
|
272
266
|
*
|
|
273
|
-
* @param {SVGPathCommander.pathArray} path the `pathArray` to be checked
|
|
267
|
+
* @param {string | SVGPathCommander.pathArray} path the `pathArray` to be checked
|
|
274
268
|
* @returns {boolean} iteration result
|
|
275
269
|
*/
|
|
276
|
-
export default function isNormalizedArray(path: SVGPathCommander.pathArray): boolean;
|
|
270
|
+
export default function isNormalizedArray(path: string | SVGPathCommander.pathArray): boolean;
|
|
277
271
|
}
|
|
278
272
|
declare module "svg-path-commander/src/parser/paramsParser" {
|
|
279
273
|
export default paramsParser;
|
|
@@ -288,10 +282,10 @@ declare module "svg-path-commander/src/process/normalizePath" {
|
|
|
288
282
|
* * convert segments to absolute values
|
|
289
283
|
* * convert shorthand path commands to their non-shorthand notation
|
|
290
284
|
*
|
|
291
|
-
* @param {SVGPathCommander.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
285
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
292
286
|
* @returns {SVGPathCommander.normalArray} the normalized `pathArray`
|
|
293
287
|
*/
|
|
294
|
-
export default function normalizePath(pathInput: SVGPathCommander.pathArray): SVGPathCommander.normalArray;
|
|
288
|
+
export default function normalizePath(pathInput: string | SVGPathCommander.pathArray): SVGPathCommander.normalArray;
|
|
295
289
|
}
|
|
296
290
|
declare module "svg-path-commander/src/process/fixPath" {
|
|
297
291
|
/**
|
|
@@ -313,10 +307,10 @@ declare module "svg-path-commander/src/util/isCurveArray" {
|
|
|
313
307
|
* Iterates an array to check if it's a `pathArray`
|
|
314
308
|
* with all C (cubic bezier) segments.
|
|
315
309
|
*
|
|
316
|
-
* @param {SVGPathCommander.pathArray} path the `Array` to be checked
|
|
310
|
+
* @param {string | SVGPathCommander.pathArray} path the `Array` to be checked
|
|
317
311
|
* @returns {boolean} iteration result
|
|
318
312
|
*/
|
|
319
|
-
export default function isCurveArray(path: SVGPathCommander.pathArray): boolean;
|
|
313
|
+
export default function isCurveArray(path: string | SVGPathCommander.pathArray): boolean;
|
|
320
314
|
}
|
|
321
315
|
declare module "svg-path-commander/src/math/rotateVector" {
|
|
322
316
|
/**
|
|
@@ -368,27 +362,6 @@ declare module "svg-path-commander/src/process/quadToCubic" {
|
|
|
368
362
|
*/
|
|
369
363
|
export default function quadToCubic(x1: number, y1: number, qx: number, qy: number, x2: number, y2: number): number[];
|
|
370
364
|
}
|
|
371
|
-
declare module "svg-path-commander/src/util/getPointAtSegLength" {
|
|
372
|
-
/**
|
|
373
|
-
* Returns the {x,y} coordinates of a point at a
|
|
374
|
-
* given length of a cubic-bezier segment.
|
|
375
|
-
*
|
|
376
|
-
* @param {number} p1x the starting point X
|
|
377
|
-
* @param {number} p1y the starting point Y
|
|
378
|
-
* @param {number} c1x the first control point X
|
|
379
|
-
* @param {number} c1y the first control point Y
|
|
380
|
-
* @param {number} c2x the second control point X
|
|
381
|
-
* @param {number} c2y the second control point Y
|
|
382
|
-
* @param {number} p2x the ending point X
|
|
383
|
-
* @param {number} p2y the ending point Y
|
|
384
|
-
* @param {number} t a [0-1] ratio
|
|
385
|
-
* @returns {{x: number, y: number}} the requested {x,y} coordinates
|
|
386
|
-
*/
|
|
387
|
-
export default function getPointAtSegLength(p1x: number, p1y: number, c1x: number, c1y: number, c2x: number, c2y: number, p2x: number, p2y: number, t: number): {
|
|
388
|
-
x: number;
|
|
389
|
-
y: number;
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
365
|
declare module "svg-path-commander/src/math/midPoint" {
|
|
393
366
|
/**
|
|
394
367
|
* Returns the coordinates of a specified distance
|
|
@@ -401,6 +374,34 @@ declare module "svg-path-commander/src/math/midPoint" {
|
|
|
401
374
|
*/
|
|
402
375
|
export default function midPoint(a: [number, number], b: [number, number], t: number): [number, number];
|
|
403
376
|
}
|
|
377
|
+
declare module "svg-path-commander/src/math/distanceSquareRoot" {
|
|
378
|
+
/**
|
|
379
|
+
* Returns the square root of the distance
|
|
380
|
+
* between two given points.
|
|
381
|
+
*
|
|
382
|
+
* @param {[number, number]} a the first point coordinates
|
|
383
|
+
* @param {[number, number]} b the second point coordinates
|
|
384
|
+
* @returns {number} the distance value
|
|
385
|
+
*/
|
|
386
|
+
export default function distanceSquareRoot(a: [number, number], b: [number, number]): number;
|
|
387
|
+
}
|
|
388
|
+
declare module "svg-path-commander/src/util/segmentLineFactory" {
|
|
389
|
+
/**
|
|
390
|
+
* Returns the length of a line (L,V,H,Z) segment,
|
|
391
|
+
* or a point at a given length.
|
|
392
|
+
*
|
|
393
|
+
* @param {number} x1 the starting point X
|
|
394
|
+
* @param {number} y1 the starting point Y
|
|
395
|
+
* @param {number} x2 the ending point X
|
|
396
|
+
* @param {number} y2 the ending point Y
|
|
397
|
+
* @param {number=} distance the distance to point
|
|
398
|
+
* @returns {{x: number, y: number} | number} the segment length or point
|
|
399
|
+
*/
|
|
400
|
+
export default function segmentLineFactory(x1: number, y1: number, x2: number, y2: number, distance?: number | undefined): {
|
|
401
|
+
x: number;
|
|
402
|
+
y: number;
|
|
403
|
+
} | number;
|
|
404
|
+
}
|
|
404
405
|
declare module "svg-path-commander/src/process/lineToCubic" {
|
|
405
406
|
/**
|
|
406
407
|
* Converts an L (line-to) segment to C (cubic-bezier).
|
|
@@ -431,10 +432,10 @@ declare module "svg-path-commander/src/convert/pathToCurve" {
|
|
|
431
432
|
* In addition, un-necessary `Z` segment is removed if previous segment
|
|
432
433
|
* extends to the `M` segment.
|
|
433
434
|
*
|
|
434
|
-
* @param {SVGPathCommander.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
435
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
435
436
|
* @returns {SVGPathCommander.curveArray} the resulted `pathArray` converted to cubic-bezier
|
|
436
437
|
*/
|
|
437
|
-
export default function pathToCurve(pathInput: SVGPathCommander.pathArray): SVGPathCommander.curveArray;
|
|
438
|
+
export default function pathToCurve(pathInput: string | SVGPathCommander.pathArray): SVGPathCommander.curveArray;
|
|
438
439
|
}
|
|
439
440
|
declare module "svg-path-commander/src/options/options" {
|
|
440
441
|
export default defaultOptions;
|
|
@@ -466,17 +467,6 @@ declare module "svg-path-commander/src/convert/pathToString" {
|
|
|
466
467
|
*/
|
|
467
468
|
export default function pathToString(path: SVGPathCommander.pathArray, round: any): string;
|
|
468
469
|
}
|
|
469
|
-
declare module "svg-path-commander/src/math/distanceSquareRoot" {
|
|
470
|
-
/**
|
|
471
|
-
* Returns the square root of the distance
|
|
472
|
-
* between two given points.
|
|
473
|
-
*
|
|
474
|
-
* @param {[number, number]} a the first point coordinates
|
|
475
|
-
* @param {[number, number]} b the second point coordinates
|
|
476
|
-
* @returns {number} the distance value
|
|
477
|
-
*/
|
|
478
|
-
export default function distanceSquareRoot(a: [number, number], b: [number, number]): number;
|
|
479
|
-
}
|
|
480
470
|
declare module "svg-path-commander/src/math/epsilon" {
|
|
481
471
|
export default epsilon;
|
|
482
472
|
/**
|
|
@@ -704,28 +694,49 @@ declare module "svg-path-commander/src/util/createPath" {
|
|
|
704
694
|
*/
|
|
705
695
|
export default function createPath(pathInput: SVGPathCommander.shapeTypes): SVGPathElement | boolean;
|
|
706
696
|
}
|
|
697
|
+
declare module "svg-path-commander/src/util/segmentCubicFactory" {
|
|
698
|
+
/**
|
|
699
|
+
* Returns the length of a C (cubic-bezier) segment,
|
|
700
|
+
* or an {x,y} point at a given length.
|
|
701
|
+
*
|
|
702
|
+
* @param {number} x1 the starting point X
|
|
703
|
+
* @param {number} y1 the starting point Y
|
|
704
|
+
* @param {number} c1x the first control point X
|
|
705
|
+
* @param {number} c1y the first control point Y
|
|
706
|
+
* @param {number} c2x the second control point X
|
|
707
|
+
* @param {number} c2y the second control point Y
|
|
708
|
+
* @param {number} x2 the ending point X
|
|
709
|
+
* @param {number} y2 the ending point Y
|
|
710
|
+
* @param {number=} distance the point distance
|
|
711
|
+
* @returns {{x: number, y: number} | number} the segment length or point
|
|
712
|
+
*/
|
|
713
|
+
export default function segmentCubicFactory(x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number, distance?: number | undefined): number | {
|
|
714
|
+
x: number;
|
|
715
|
+
y: number;
|
|
716
|
+
};
|
|
717
|
+
}
|
|
707
718
|
declare module "svg-path-commander/src/util/getCubicSize" {
|
|
708
719
|
/**
|
|
709
720
|
* Returns the cubic-bezier segment length.
|
|
710
721
|
*
|
|
711
|
-
* @param {number}
|
|
712
|
-
* @param {number}
|
|
722
|
+
* @param {number} x1 the starting point X
|
|
723
|
+
* @param {number} y1 the starting point Y
|
|
713
724
|
* @param {number} c1x the first control point X
|
|
714
725
|
* @param {number} c1y the first control point Y
|
|
715
726
|
* @param {number} c2x the second control point X
|
|
716
727
|
* @param {number} c2y the second control point Y
|
|
717
|
-
* @param {number}
|
|
718
|
-
* @param {number}
|
|
728
|
+
* @param {number} x2 the ending point X
|
|
729
|
+
* @param {number} y2 the ending point Y
|
|
719
730
|
* @returns {SVGPathCommander.segmentLimits} the length of the cubic-bezier segment
|
|
720
731
|
*/
|
|
721
|
-
export default function getCubicSize(
|
|
732
|
+
export default function getCubicSize(x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number): SVGPathCommander.segmentLimits;
|
|
722
733
|
}
|
|
723
734
|
declare module "svg-path-commander/src/util/getPathArea" {
|
|
724
735
|
/**
|
|
725
736
|
* Returns the area of a shape.
|
|
726
737
|
* @author Jürg Lehni & Jonathan Puckey
|
|
727
738
|
*
|
|
728
|
-
*
|
|
739
|
+
* @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
|
|
729
740
|
*
|
|
730
741
|
* @param {SVGPathCommander.pathArray} path the shape `pathArray`
|
|
731
742
|
* @returns {number} the length of the cubic-bezier segment
|
|
@@ -751,80 +762,185 @@ declare module "svg-path-commander/src/util/getPathBBox" {
|
|
|
751
762
|
*/
|
|
752
763
|
export default function getPathBBox(path: SVGPathCommander.pathArray): SVGPathCommander.pathBBox;
|
|
753
764
|
}
|
|
754
|
-
declare module "svg-path-commander/src/util/
|
|
765
|
+
declare module "svg-path-commander/src/util/getPathLength" {
|
|
766
|
+
/**
|
|
767
|
+
* Returns the shape total length, or the equivalent to `shape.getTotalLength()`.
|
|
768
|
+
*
|
|
769
|
+
* This is the `pathToCurve` version which is faster and more efficient for
|
|
770
|
+
* paths that are `curveArray`.
|
|
771
|
+
*
|
|
772
|
+
* @param {string | SVGPathCommander.curveArray} path the target `pathArray`
|
|
773
|
+
* @returns {number} the `curveArray` total length
|
|
774
|
+
*/
|
|
775
|
+
export default function getPathLength(path: string | SVGPathCommander.curveArray): number;
|
|
776
|
+
}
|
|
777
|
+
declare module "svg-path-commander/src/util/segmentArcFactory" {
|
|
755
778
|
/**
|
|
756
|
-
* Returns the
|
|
779
|
+
* Returns the length of a A (arc-to) segment,
|
|
780
|
+
* or an {x,y} point at a given length.
|
|
781
|
+
*
|
|
782
|
+
* @param {number} X1 the starting x position
|
|
783
|
+
* @param {number} Y1 the starting y position
|
|
784
|
+
* @param {number} RX x-radius of the arc
|
|
785
|
+
* @param {number} RY y-radius of the arc
|
|
786
|
+
* @param {number} angle x-axis-rotation of the arc
|
|
787
|
+
* @param {number} LAF large-arc-flag of the arc
|
|
788
|
+
* @param {number} SF sweep-flag of the arc
|
|
789
|
+
* @param {number} X2 the ending x position
|
|
790
|
+
* @param {number} Y2 the ending y position
|
|
791
|
+
* @param {number} distance the point distance
|
|
792
|
+
* @returns {{x: number, y: number} | number} the segment length or point
|
|
793
|
+
*/
|
|
794
|
+
export default function segmentArcFactory(X1: number, Y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, X2: number, Y2: number, distance: number): {
|
|
795
|
+
x: number;
|
|
796
|
+
y: number;
|
|
797
|
+
} | number;
|
|
798
|
+
}
|
|
799
|
+
declare module "svg-path-commander/src/util/segmentQuadFactory" {
|
|
800
|
+
/**
|
|
801
|
+
* Returns the Q (quadratic-bezier) segment length,
|
|
802
|
+
* or an {x,y} point at a given length.
|
|
757
803
|
*
|
|
758
804
|
* @param {number} x1 the starting point X
|
|
759
805
|
* @param {number} y1 the starting point Y
|
|
760
|
-
* @param {number}
|
|
761
|
-
* @param {number}
|
|
762
|
-
* @param {number}
|
|
763
|
-
* @param {number}
|
|
764
|
-
* @param {number}
|
|
765
|
-
* @
|
|
766
|
-
* @param {number} z a [0-1] ratio
|
|
767
|
-
* @returns {number} the cubic-bezier segment length
|
|
806
|
+
* @param {number} qx the control point X
|
|
807
|
+
* @param {number} qy the control point Y
|
|
808
|
+
* @param {number} x2 the ending point X
|
|
809
|
+
* @param {number} y2 the ending point Y
|
|
810
|
+
* @param {number=} distance the distance to point
|
|
811
|
+
* @returns {{x: number, y: number} | number} the segment length or point
|
|
768
812
|
*/
|
|
769
|
-
export default function
|
|
813
|
+
export default function segmentQuadFactory(x1: number, y1: number, qx: number, qy: number, x2: number, y2: number, distance?: number | undefined): number | {
|
|
814
|
+
x: number;
|
|
815
|
+
y: number;
|
|
816
|
+
};
|
|
770
817
|
}
|
|
771
|
-
declare module "svg-path-commander/src/util/
|
|
818
|
+
declare module "svg-path-commander/src/util/pathLengthFactory" {
|
|
819
|
+
/**
|
|
820
|
+
* Returns a {x,y} point at a given length of a shape or the shape total length.
|
|
821
|
+
*
|
|
822
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the `pathArray` to look into
|
|
823
|
+
* @param {number=} distance the length of the shape to look at
|
|
824
|
+
* @returns {{x: number, y: number} | number} the total length or point
|
|
825
|
+
*/
|
|
826
|
+
export default function pathLengthFactory(pathInput: string | SVGPathCommander.pathArray, distance?: number | undefined): number | {
|
|
827
|
+
x: number;
|
|
828
|
+
y: number;
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
declare module "svg-path-commander/src/util/getTotalLength" {
|
|
772
832
|
/**
|
|
773
|
-
* Returns the shape total length,
|
|
774
|
-
*
|
|
775
|
-
*
|
|
833
|
+
* Returns the shape total length, or the equivalent to `shape.getTotalLength()`.
|
|
834
|
+
*
|
|
835
|
+
* The `normalizePath` version is lighter, faster, more efficient and more accurate
|
|
836
|
+
* with paths that are not `curveArray`.
|
|
776
837
|
*
|
|
777
|
-
* @param {SVGPathCommander.pathArray}
|
|
838
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the target `pathArray`
|
|
778
839
|
* @returns {number} the shape total length
|
|
779
840
|
*/
|
|
780
|
-
export default function
|
|
841
|
+
export default function getTotalLength(pathInput: string | SVGPathCommander.pathArray): number;
|
|
781
842
|
}
|
|
782
843
|
declare module "svg-path-commander/src/util/getPointAtLength" {
|
|
783
844
|
/**
|
|
784
845
|
* Returns [x,y] coordinates of a point at a given length of a shape.
|
|
785
846
|
*
|
|
786
|
-
* @param {string | SVGPathCommander.pathArray}
|
|
847
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the `pathArray` to look into
|
|
848
|
+
* @param {number} distance the length of the shape to look at
|
|
849
|
+
* @returns {{x: number, y: number}} the requested {x, y} point coordinates
|
|
850
|
+
*/
|
|
851
|
+
export default function getPointAtLength(pathInput: string | SVGPathCommander.pathArray, distance: number): {
|
|
852
|
+
x: number;
|
|
853
|
+
y: number;
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
declare module "svg-path-commander/src/util/getPointAtPathLength" {
|
|
857
|
+
/**
|
|
858
|
+
* Returns [x,y] coordinates of a point at a given length of a shape.
|
|
859
|
+
* `pathToCurve` version.
|
|
860
|
+
*
|
|
861
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the `pathArray` to look into
|
|
787
862
|
* @param {number} length the length of the shape to look at
|
|
788
|
-
* @returns {number
|
|
863
|
+
* @returns {{x: number, y: number}} the requested {x, y} point coordinates
|
|
789
864
|
*/
|
|
790
|
-
export default function
|
|
865
|
+
export default function getPointAtPathLength(pathInput: string | SVGPathCommander.pathArray, length: number): {
|
|
866
|
+
x: number;
|
|
867
|
+
y: number;
|
|
868
|
+
};
|
|
791
869
|
}
|
|
792
|
-
declare module "svg-path-commander/src/util/
|
|
870
|
+
declare module "svg-path-commander/src/util/getPropertiesAtLength" {
|
|
793
871
|
/**
|
|
794
|
-
* Returns the
|
|
872
|
+
* Returns the properties at a given length in path.
|
|
795
873
|
*
|
|
796
|
-
* @param {
|
|
797
|
-
* @
|
|
874
|
+
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
875
|
+
* @param {number=} distance the given length
|
|
876
|
+
* @returns {SVGPathCommander.segmentProperties=} the requested properties
|
|
798
877
|
*/
|
|
799
|
-
export default function
|
|
878
|
+
export default function getPropertiesAtLength(pathInput: string | SVGPathCommander.pathArray, distance?: number | undefined): SVGPathCommander.segmentProperties | undefined;
|
|
800
879
|
}
|
|
801
|
-
declare module "svg-path-commander/src/util/
|
|
880
|
+
declare module "svg-path-commander/src/util/getPropertiesAtPoint" {
|
|
802
881
|
/**
|
|
803
|
-
* Returns the
|
|
882
|
+
* Returns the point in path closest to a given point.
|
|
883
|
+
* @see https://bl.ocks.org/mbostock/8027637
|
|
804
884
|
*
|
|
805
|
-
* @param {
|
|
806
|
-
* @param {number}
|
|
807
|
-
* @
|
|
808
|
-
* @param {number} by the ending point Y
|
|
809
|
-
* @returns {number} the line-to segment length
|
|
885
|
+
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
886
|
+
* @param {{x: number, y: number}} point the given point
|
|
887
|
+
* @returns {SVGPathCommander.pointProperties} the requested properties
|
|
810
888
|
*/
|
|
811
|
-
export default function
|
|
889
|
+
export default function getPropertiesAtPoint(pathInput: string | SVGPathCommander.pathArray, point: {
|
|
890
|
+
x: number;
|
|
891
|
+
y: number;
|
|
892
|
+
}): SVGPathCommander.pointProperties;
|
|
812
893
|
}
|
|
813
|
-
declare module "svg-path-commander/src/util/
|
|
894
|
+
declare module "svg-path-commander/src/util/getClosestPoint" {
|
|
814
895
|
/**
|
|
815
|
-
* Returns the
|
|
816
|
-
* https://gist.github.com/tunght13488/6744e77c242cc7a94859#gistcomment-2047251
|
|
896
|
+
* Returns the point in path closest to a given point.
|
|
817
897
|
*
|
|
818
|
-
* @param {
|
|
819
|
-
* @param {number}
|
|
820
|
-
* @
|
|
821
|
-
* @param {number} qy the control point Y
|
|
822
|
-
* @param {number} x2 the ending point X
|
|
823
|
-
* @param {number} y2 the ending point Y
|
|
824
|
-
* @param {number} z a [0-1] ratio
|
|
825
|
-
* @returns {number} the quadratic-bezier segment length
|
|
898
|
+
* @param {string | SVGPathCommander.pathArray} pathInput target `pathArray`
|
|
899
|
+
* @param {{x: number, y: number}} point the given point
|
|
900
|
+
* @returns {{x: number, y: number}} the best match
|
|
826
901
|
*/
|
|
827
|
-
export default function
|
|
902
|
+
export default function getClosestPoint(pathInput: string | SVGPathCommander.pathArray, point: {
|
|
903
|
+
x: number;
|
|
904
|
+
y: number;
|
|
905
|
+
}): {
|
|
906
|
+
x: number;
|
|
907
|
+
y: number;
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
declare module "svg-path-commander/src/util/getSegmentAtLength" {
|
|
911
|
+
/**
|
|
912
|
+
* Returns the segment at a given length.
|
|
913
|
+
* @param {string | SVGPathCommander.pathArray} pathInput the target `pathArray`
|
|
914
|
+
* @param {number} distance the distance in path to look at
|
|
915
|
+
* @returns {SVGPathCommander.pathSegment?} the requested segment
|
|
916
|
+
*/
|
|
917
|
+
export default function getSegmentAtLength(pathInput: string | SVGPathCommander.pathArray, distance: number): SVGPathCommander.pathSegment | null;
|
|
918
|
+
}
|
|
919
|
+
declare module "svg-path-commander/src/util/getSegmentOfPoint" {
|
|
920
|
+
/**
|
|
921
|
+
* Returns the path segment which contains a given point.
|
|
922
|
+
*
|
|
923
|
+
* @param {string | SVGPathCommander.pathArray} path the `pathArray` to look into
|
|
924
|
+
* @param {{x: number, y: number}} point the point of the shape to look for
|
|
925
|
+
* @returns {SVGPathCommander.pathSegment?} the requested segment
|
|
926
|
+
*/
|
|
927
|
+
export default function getSegmentOfPoint(path: string | SVGPathCommander.pathArray, point: {
|
|
928
|
+
x: number;
|
|
929
|
+
y: number;
|
|
930
|
+
}): SVGPathCommander.pathSegment | null;
|
|
931
|
+
}
|
|
932
|
+
declare module "svg-path-commander/src/util/isPointInStroke" {
|
|
933
|
+
/**
|
|
934
|
+
* Checks if a given point is in the stroke of a path.
|
|
935
|
+
*
|
|
936
|
+
* @param {string | SVGPathCommander.pathArray} pathInput target path
|
|
937
|
+
* @param {{x: number, y: number}} point
|
|
938
|
+
* @returns {boolean} the query result
|
|
939
|
+
*/
|
|
940
|
+
export default function isPointInStroke(pathInput: string | SVGPathCommander.pathArray, point: {
|
|
941
|
+
x: number;
|
|
942
|
+
y: number;
|
|
943
|
+
}): boolean;
|
|
828
944
|
}
|
|
829
945
|
declare module "svg-path-commander/src/util/isValidPath" {
|
|
830
946
|
/**
|
|
@@ -872,9 +988,6 @@ declare module "svg-path-commander/src/svg-path-commander" {
|
|
|
872
988
|
* @default 4
|
|
873
989
|
*/
|
|
874
990
|
round: number | boolean;
|
|
875
|
-
/**
|
|
876
|
-
* @default [0,0]
|
|
877
|
-
*/
|
|
878
991
|
origin: number[];
|
|
879
992
|
/**
|
|
880
993
|
* Convert path to absolute values
|
|
@@ -996,12 +1109,19 @@ declare module "svg-path-commander/types/more/modules" {
|
|
|
996
1109
|
export { default as getPathArea } from "svg-path-commander/src/util/getPathArea";
|
|
997
1110
|
export { default as getPathBBox } from "svg-path-commander/src/util/getPathBBox";
|
|
998
1111
|
export { default as getPathLength } from "svg-path-commander/src/util/getPathLength";
|
|
1112
|
+
export { default as getTotalLength } from "svg-path-commander/src/util/getTotalLength";
|
|
1113
|
+
export { default as segmentLineFactory } from "svg-path-commander/src/util/segmentLineFactory";
|
|
1114
|
+
export { default as segmentArcFactory } from "svg-path-commander/src/util/segmentArcFactory";
|
|
1115
|
+
export { default as segmentCubicFactory } from "svg-path-commander/src/util/segmentCubicFactory";
|
|
1116
|
+
export { default as segmentQuadFactory } from "svg-path-commander/src/util/segmentQuadFactory";
|
|
999
1117
|
export { default as getPointAtLength } from "svg-path-commander/src/util/getPointAtLength";
|
|
1000
|
-
export { default as
|
|
1001
|
-
export { default as
|
|
1002
|
-
export { default as
|
|
1003
|
-
export { default as
|
|
1004
|
-
export { default as
|
|
1118
|
+
export { default as getPointAtPathLength } from "svg-path-commander/src/util/getPointAtPathLength";
|
|
1119
|
+
export { default as getPropertiesAtPoint } from "svg-path-commander/src/util/getPropertiesAtPoint";
|
|
1120
|
+
export { default as getPropertiesAtLength } from "svg-path-commander/src/util/getPropertiesAtLength";
|
|
1121
|
+
export { default as getClosestPoint } from "svg-path-commander/src/util/getClosestPoint";
|
|
1122
|
+
export { default as getSegmentAtLength } from "svg-path-commander/src/util/getSegmentAtLength";
|
|
1123
|
+
export { default as getSegmentOfPoint } from "svg-path-commander/src/util/getSegmentOfPoint";
|
|
1124
|
+
export { default as isPointInStroke } from "svg-path-commander/src/util/isPointInStroke";
|
|
1005
1125
|
export { default as isAbsoluteArray } from "svg-path-commander/src/util/isAbsoluteArray";
|
|
1006
1126
|
export { default as isCurveArray } from "svg-path-commander/src/util/isCurveArray";
|
|
1007
1127
|
export { default as isNormalizedArray } from "svg-path-commander/src/util/isNormalizedArray";
|