svg-path-commander 0.1.24 → 0.2.0-alpha2
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 +5 -3
- package/dist/svg-path-commander.es5.js +3948 -0
- package/dist/svg-path-commander.es5.min.js +2 -0
- package/dist/svg-path-commander.esm.js +428 -407
- package/dist/svg-path-commander.esm.min.js +2 -2
- package/dist/svg-path-commander.js +1434 -1515
- package/dist/svg-path-commander.min.js +2 -2
- package/package.json +15 -2
- package/src/convert/pathToAbsolute.js +4 -4
- package/src/convert/pathToCurve.js +2 -2
- package/src/convert/pathToRelative.js +4 -4
- package/src/convert/pathToString.js +2 -2
- package/src/math/polygonLength.js +1 -2
- package/src/options/options.js +1 -1
- package/src/parser/error.js +2 -0
- package/src/parser/finalizeSegment.js +1 -1
- package/src/parser/isSpace.js +1 -1
- package/src/parser/paramsParser.js +1 -1
- package/src/parser/parsePathString.js +6 -11
- package/src/parser/pathParser.js +1 -1
- package/src/parser/scanFlag.js +3 -3
- package/src/parser/scanParam.js +7 -6
- package/src/parser/scanSegment.js +3 -2
- package/src/parser/skipSpaces.js +1 -1
- package/src/process/clonePath.js +1 -1
- package/src/process/fixArc.js +1 -1
- package/src/process/fixPath.js +2 -2
- package/src/process/getSVGMatrix.js +3 -2
- package/src/process/normalizePath.js +3 -3
- package/src/process/normalizeSegment.js +2 -2
- package/src/process/optimizePath.js +2 -2
- package/src/process/projection2d.js +2 -2
- package/src/process/reverseCurve.js +3 -3
- package/src/process/reversePath.js +4 -5
- package/src/process/roundPath.js +7 -6
- package/src/process/segmentToCubic.js +3 -3
- package/src/process/shortenSegment.js +3 -3
- package/src/process/splitCubic.js +1 -1
- package/src/process/splitPath.js +1 -1
- package/src/process/transformPath.js +8 -7
- package/src/svg-path-commander.js +60 -20
- package/src/util/getClosestPoint.js +1 -1
- package/src/util/getCubicSize.js +1 -1
- package/src/util/getDrawDirection.js +1 -1
- package/src/util/getPathArea.js +1 -1
- package/src/util/getPathBBox.js +2 -2
- package/src/util/getPathLength.js +1 -1
- package/src/util/getPointAtLength.js +1 -1
- package/src/util/getPropertiesAtLength.js +3 -3
- package/src/util/getPropertiesAtPoint.js +2 -2
- package/src/util/getSegmentAtLength.js +2 -2
- package/src/util/getSegmentOfPoint.js +2 -2
- package/src/util/getTotalLength.js +1 -1
- package/src/util/isAbsoluteArray.js +1 -1
- package/src/util/isCurveArray.js +1 -1
- package/src/util/isNormalizedArray.js +1 -1
- package/src/util/isPathArray.js +1 -1
- package/src/util/isPointInStroke.js +2 -2
- package/src/util/isRelativeArray.js +1 -1
- package/src/util/pathLengthFactory.js +3 -2
- package/src/util/segmentArcFactory.js +1 -1
- package/src/util/segmentCubicFactory.js +1 -1
- package/src/util/segmentLineFactory.js +1 -1
- package/src/util/segmentQuadFactory.js +1 -1
- package/src/util/shapeToPath.js +14 -14
- package/src/util/util.js +0 -2
- package/types/index.d.ts +1 -3
- package/types/more/modules.ts +0 -3
- package/types/more/svg.d.ts +11 -10
- package/types/svg-path-commander.d.ts +214 -226
- package/src/util/createPath.js +0 -17
- package/src/util/getPointAtPathLength.js +0 -15
|
@@ -10,9 +10,9 @@ declare module "svg-path-commander/src/parser/finalizeSegment" {
|
|
|
10
10
|
/**
|
|
11
11
|
* Breaks the parsing of a pathString once a segment is finalized.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
14
14
|
*/
|
|
15
|
-
export default function finalizeSegment(path:
|
|
15
|
+
export default function finalizeSegment(path: SVGPath.PathParser): void;
|
|
16
16
|
}
|
|
17
17
|
declare module "svg-path-commander/src/parser/invalidPathValue" {
|
|
18
18
|
export default invalidPathValue;
|
|
@@ -23,9 +23,9 @@ declare module "svg-path-commander/src/parser/scanFlag" {
|
|
|
23
23
|
* Validates an A (arc-to) specific path command value.
|
|
24
24
|
* Usually a `large-arc-flag` or `sweep-flag`.
|
|
25
25
|
*
|
|
26
|
-
* @param {
|
|
26
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
27
27
|
*/
|
|
28
|
-
export default function scanFlag(path:
|
|
28
|
+
export default function scanFlag(path: SVGPath.PathParser): void;
|
|
29
29
|
}
|
|
30
30
|
declare module "svg-path-commander/src/parser/isDigit" {
|
|
31
31
|
/**
|
|
@@ -41,9 +41,9 @@ declare module "svg-path-commander/src/parser/scanParam" {
|
|
|
41
41
|
* Validates every character of the path string,
|
|
42
42
|
* every path command, negative numbers or floating point numbers.
|
|
43
43
|
*
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
45
45
|
*/
|
|
46
|
-
export default function scanParam(path:
|
|
46
|
+
export default function scanParam(path: SVGPath.PathParser): void;
|
|
47
47
|
}
|
|
48
48
|
declare module "svg-path-commander/src/parser/isSpace" {
|
|
49
49
|
/**
|
|
@@ -60,9 +60,9 @@ declare module "svg-path-commander/src/parser/skipSpaces" {
|
|
|
60
60
|
* path string every time it encounters any kind of
|
|
61
61
|
* space character.
|
|
62
62
|
*
|
|
63
|
-
* @param {
|
|
63
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
64
64
|
*/
|
|
65
|
-
export default function skipSpaces(path:
|
|
65
|
+
export default function skipSpaces(path: SVGPath.PathParser): void;
|
|
66
66
|
}
|
|
67
67
|
declare module "svg-path-commander/src/parser/isPathCommand" {
|
|
68
68
|
/**
|
|
@@ -97,18 +97,18 @@ declare module "svg-path-commander/src/parser/scanSegment" {
|
|
|
97
97
|
* Scans every character in the path string to determine
|
|
98
98
|
* where a segment starts and where it ends.
|
|
99
99
|
*
|
|
100
|
-
* @param {
|
|
100
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
101
101
|
*/
|
|
102
|
-
export default function scanSegment(path:
|
|
102
|
+
export default function scanSegment(path: SVGPath.PathParser): void;
|
|
103
103
|
}
|
|
104
104
|
declare module "svg-path-commander/src/process/clonePath" {
|
|
105
105
|
/**
|
|
106
106
|
* Returns a clone of an existing `pathArray`.
|
|
107
107
|
*
|
|
108
|
-
* @param {
|
|
108
|
+
* @param {SVGPath.pathArray | SVGPath.pathSegment} path the source `pathArray`
|
|
109
109
|
* @returns {any} the cloned `pathArray`
|
|
110
110
|
*/
|
|
111
|
-
export default function clonePath(path:
|
|
111
|
+
export default function clonePath(path: SVGPath.pathArray | SVGPath.pathSegment): any;
|
|
112
112
|
}
|
|
113
113
|
declare module "svg-path-commander/src/parser/pathParser" {
|
|
114
114
|
/**
|
|
@@ -126,8 +126,8 @@ declare module "svg-path-commander/src/parser/pathParser" {
|
|
|
126
126
|
* @param {string} pathString
|
|
127
127
|
*/
|
|
128
128
|
constructor(pathString: string);
|
|
129
|
-
/** @type {
|
|
130
|
-
segments:
|
|
129
|
+
/** @type {SVGPath.pathArray} */
|
|
130
|
+
segments: SVGPath.pathArray;
|
|
131
131
|
/** @type {string} */
|
|
132
132
|
pathValue: string;
|
|
133
133
|
/** @type {number} */
|
|
@@ -148,70 +148,70 @@ declare module "svg-path-commander/src/util/isPathArray" {
|
|
|
148
148
|
/**
|
|
149
149
|
* Iterates an array to check if it's an actual `pathArray`.
|
|
150
150
|
*
|
|
151
|
-
* @param {string |
|
|
151
|
+
* @param {string | SVGPath.pathArray} path the `pathArray` to be checked
|
|
152
152
|
* @returns {boolean} iteration result
|
|
153
153
|
*/
|
|
154
|
-
export default function isPathArray(path: string |
|
|
154
|
+
export default function isPathArray(path: string | SVGPath.pathArray): boolean;
|
|
155
155
|
}
|
|
156
156
|
declare module "svg-path-commander/src/parser/parsePathString" {
|
|
157
157
|
/**
|
|
158
158
|
* Parses a path string value and returns an array
|
|
159
159
|
* of segments we like to call `pathArray`.
|
|
160
160
|
*
|
|
161
|
-
* @param {
|
|
162
|
-
* @returns {
|
|
161
|
+
* @param {SVGPath.pathArray | string} pathInput the string to be parsed
|
|
162
|
+
* @returns {SVGPath.pathArray} the resulted `pathArray`
|
|
163
163
|
*/
|
|
164
|
-
export default function parsePathString(pathInput:
|
|
164
|
+
export default function parsePathString(pathInput: SVGPath.pathArray | string): SVGPath.pathArray;
|
|
165
165
|
}
|
|
166
166
|
declare module "svg-path-commander/src/util/isAbsoluteArray" {
|
|
167
167
|
/**
|
|
168
168
|
* Iterates an array to check if it's a `pathArray`
|
|
169
169
|
* with all absolute values.
|
|
170
170
|
*
|
|
171
|
-
* @param {string |
|
|
171
|
+
* @param {string | SVGPath.pathArray} path the `pathArray` to be checked
|
|
172
172
|
* @returns {boolean} iteration result
|
|
173
173
|
*/
|
|
174
|
-
export default function isAbsoluteArray(path: string |
|
|
174
|
+
export default function isAbsoluteArray(path: string | SVGPath.pathArray): boolean;
|
|
175
175
|
}
|
|
176
176
|
declare module "svg-path-commander/src/convert/pathToAbsolute" {
|
|
177
177
|
/**
|
|
178
178
|
* Parses a path string value or object and returns an array
|
|
179
179
|
* of segments, all converted to absolute values.
|
|
180
180
|
*
|
|
181
|
-
* @param {string |
|
|
182
|
-
* @returns {
|
|
181
|
+
* @param {string | SVGPath.pathArray} pathInput the path string | object
|
|
182
|
+
* @returns {SVGPath.absoluteArray} the resulted `pathArray` with absolute values
|
|
183
183
|
*/
|
|
184
|
-
export default function pathToAbsolute(pathInput: string |
|
|
184
|
+
export default function pathToAbsolute(pathInput: string | SVGPath.pathArray): SVGPath.absoluteArray;
|
|
185
185
|
}
|
|
186
186
|
declare module "svg-path-commander/src/util/isRelativeArray" {
|
|
187
187
|
/**
|
|
188
188
|
* Iterates an array to check if it's a `pathArray`
|
|
189
189
|
* with relative values.
|
|
190
190
|
*
|
|
191
|
-
* @param {string |
|
|
191
|
+
* @param {string | SVGPath.pathArray} path the `pathArray` to be checked
|
|
192
192
|
* @returns {boolean} iteration result
|
|
193
193
|
*/
|
|
194
|
-
export default function isRelativeArray(path: string |
|
|
194
|
+
export default function isRelativeArray(path: string | SVGPath.pathArray): boolean;
|
|
195
195
|
}
|
|
196
196
|
declare module "svg-path-commander/src/convert/pathToRelative" {
|
|
197
197
|
/**
|
|
198
198
|
* Parses a path string value or object and returns an array
|
|
199
199
|
* of segments, all converted to relative values.
|
|
200
200
|
*
|
|
201
|
-
* @param {string |
|
|
202
|
-
* @returns {
|
|
201
|
+
* @param {string | SVGPath.pathArray} pathInput the path string | object
|
|
202
|
+
* @returns {SVGPath.relativeArray} the resulted `pathArray` with relative values
|
|
203
203
|
*/
|
|
204
|
-
export default function pathToRelative(pathInput: string |
|
|
204
|
+
export default function pathToRelative(pathInput: string | SVGPath.pathArray): SVGPath.relativeArray;
|
|
205
205
|
}
|
|
206
206
|
declare module "svg-path-commander/src/process/fixArc" {
|
|
207
207
|
/**
|
|
208
208
|
* Splits an extended A (arc-to) segment into two cubic-bezier segments.
|
|
209
209
|
*
|
|
210
|
-
* @param {
|
|
210
|
+
* @param {SVGPath.pathArray} path the `pathArray` this segment belongs to
|
|
211
211
|
* @param {string[]} allPathCommands all previous path commands
|
|
212
212
|
* @param {number} i the segment index
|
|
213
213
|
*/
|
|
214
|
-
export default function fixArc(path:
|
|
214
|
+
export default function fixArc(path: SVGPath.pathArray, allPathCommands: string[], i: number): void;
|
|
215
215
|
}
|
|
216
216
|
declare module "svg-path-commander/src/process/shorthandToQuad" {
|
|
217
217
|
/**
|
|
@@ -251,12 +251,12 @@ declare module "svg-path-commander/src/process/normalizeSegment" {
|
|
|
251
251
|
/**
|
|
252
252
|
* Normalizes a single segment of a `pathArray` object.
|
|
253
253
|
*
|
|
254
|
-
* @param {
|
|
254
|
+
* @param {SVGPath.pathSegment} segment the segment object
|
|
255
255
|
* @param {any} params the coordinates of the previous segment
|
|
256
256
|
* @param {string} prevCommand the path command of the previous segment
|
|
257
|
-
* @returns {
|
|
257
|
+
* @returns {SVGPath.normalSegment} the normalized segment
|
|
258
258
|
*/
|
|
259
|
-
export default function normalizeSegment(segment:
|
|
259
|
+
export default function normalizeSegment(segment: SVGPath.pathSegment, params: any, prevCommand: string): SVGPath.normalSegment;
|
|
260
260
|
}
|
|
261
261
|
declare module "svg-path-commander/src/util/isNormalizedArray" {
|
|
262
262
|
/**
|
|
@@ -264,17 +264,17 @@ declare module "svg-path-commander/src/util/isNormalizedArray" {
|
|
|
264
264
|
* with all segments are in non-shorthand notation
|
|
265
265
|
* with absolute values.
|
|
266
266
|
*
|
|
267
|
-
* @param {string |
|
|
267
|
+
* @param {string | SVGPath.pathArray} path the `pathArray` to be checked
|
|
268
268
|
* @returns {boolean} iteration result
|
|
269
269
|
*/
|
|
270
|
-
export default function isNormalizedArray(path: string |
|
|
270
|
+
export default function isNormalizedArray(path: string | SVGPath.pathArray): boolean;
|
|
271
271
|
}
|
|
272
272
|
declare module "svg-path-commander/src/parser/paramsParser" {
|
|
273
273
|
export default paramsParser;
|
|
274
274
|
/**
|
|
275
|
-
* @type {
|
|
275
|
+
* @type {SVGPath.parserParams}
|
|
276
276
|
*/
|
|
277
|
-
const paramsParser:
|
|
277
|
+
const paramsParser: SVGPath.parserParams;
|
|
278
278
|
}
|
|
279
279
|
declare module "svg-path-commander/src/process/normalizePath" {
|
|
280
280
|
/**
|
|
@@ -282,10 +282,10 @@ declare module "svg-path-commander/src/process/normalizePath" {
|
|
|
282
282
|
* * convert segments to absolute values
|
|
283
283
|
* * convert shorthand path commands to their non-shorthand notation
|
|
284
284
|
*
|
|
285
|
-
* @param {string |
|
|
286
|
-
* @returns {
|
|
285
|
+
* @param {string | SVGPath.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
286
|
+
* @returns {SVGPath.normalArray} the normalized `pathArray`
|
|
287
287
|
*/
|
|
288
|
-
export default function normalizePath(pathInput: string |
|
|
288
|
+
export default function normalizePath(pathInput: string | SVGPath.pathArray): SVGPath.normalArray;
|
|
289
289
|
}
|
|
290
290
|
declare module "svg-path-commander/src/process/fixPath" {
|
|
291
291
|
/**
|
|
@@ -297,20 +297,20 @@ declare module "svg-path-commander/src/process/fixPath" {
|
|
|
297
297
|
* use `splitPath` first and apply this utility on each
|
|
298
298
|
* sub-path separately.
|
|
299
299
|
*
|
|
300
|
-
* @param {
|
|
301
|
-
* @return {
|
|
300
|
+
* @param {SVGPath.pathArray | string} pathInput the `pathArray` source
|
|
301
|
+
* @return {SVGPath.pathArray} a fixed `pathArray`
|
|
302
302
|
*/
|
|
303
|
-
export default function fixPath(pathInput:
|
|
303
|
+
export default function fixPath(pathInput: SVGPath.pathArray | string): SVGPath.pathArray;
|
|
304
304
|
}
|
|
305
305
|
declare module "svg-path-commander/src/util/isCurveArray" {
|
|
306
306
|
/**
|
|
307
307
|
* Iterates an array to check if it's a `pathArray`
|
|
308
308
|
* with all C (cubic bezier) segments.
|
|
309
309
|
*
|
|
310
|
-
* @param {string |
|
|
310
|
+
* @param {string | SVGPath.pathArray} path the `Array` to be checked
|
|
311
311
|
* @returns {boolean} iteration result
|
|
312
312
|
*/
|
|
313
|
-
export default function isCurveArray(path: string |
|
|
313
|
+
export default function isCurveArray(path: string | SVGPath.pathArray): boolean;
|
|
314
314
|
}
|
|
315
315
|
declare module "svg-path-commander/src/math/rotateVector" {
|
|
316
316
|
/**
|
|
@@ -387,7 +387,7 @@ declare module "svg-path-commander/src/math/distanceSquareRoot" {
|
|
|
387
387
|
}
|
|
388
388
|
declare module "svg-path-commander/src/util/segmentLineFactory" {
|
|
389
389
|
/**
|
|
390
|
-
* Returns the length of a line (L,V,H,Z) segment
|
|
390
|
+
* Returns the length of a line (L,V,H,Z) segment
|
|
391
391
|
* or a point at a given length.
|
|
392
392
|
*
|
|
393
393
|
* @param {number} x1 the starting point X
|
|
@@ -418,11 +418,11 @@ declare module "svg-path-commander/src/process/segmentToCubic" {
|
|
|
418
418
|
/**
|
|
419
419
|
* Converts any segment to C (cubic-bezier).
|
|
420
420
|
*
|
|
421
|
-
* @param {
|
|
422
|
-
* @param {
|
|
423
|
-
* @returns {
|
|
421
|
+
* @param {SVGPath.pathSegment} segment the source segment
|
|
422
|
+
* @param {SVGPath.parserParams} params the source segment parameters
|
|
423
|
+
* @returns {SVGPath.cubicSegment | SVGPath.MSegment} the cubic-bezier segment
|
|
424
424
|
*/
|
|
425
|
-
export default function segmentToCubic(segment:
|
|
425
|
+
export default function segmentToCubic(segment: SVGPath.pathSegment, params: SVGPath.parserParams): SVGPath.cubicSegment | SVGPath.MSegment;
|
|
426
426
|
}
|
|
427
427
|
declare module "svg-path-commander/src/convert/pathToCurve" {
|
|
428
428
|
/**
|
|
@@ -432,40 +432,40 @@ declare module "svg-path-commander/src/convert/pathToCurve" {
|
|
|
432
432
|
* In addition, un-necessary `Z` segment is removed if previous segment
|
|
433
433
|
* extends to the `M` segment.
|
|
434
434
|
*
|
|
435
|
-
* @param {string |
|
|
436
|
-
* @returns {
|
|
435
|
+
* @param {string | SVGPath.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
436
|
+
* @returns {SVGPath.curveArray} the resulted `pathArray` converted to cubic-bezier
|
|
437
437
|
*/
|
|
438
|
-
export default function pathToCurve(pathInput: string |
|
|
438
|
+
export default function pathToCurve(pathInput: string | SVGPath.pathArray): SVGPath.curveArray;
|
|
439
439
|
}
|
|
440
440
|
declare module "svg-path-commander/src/options/options" {
|
|
441
441
|
export default defaultOptions;
|
|
442
442
|
/**
|
|
443
443
|
* SVGPathCommander default options
|
|
444
|
-
* @type {
|
|
444
|
+
* @type {SVGPath.options}
|
|
445
445
|
*/
|
|
446
|
-
const defaultOptions:
|
|
446
|
+
const defaultOptions: SVGPath.options;
|
|
447
447
|
}
|
|
448
448
|
declare module "svg-path-commander/src/process/roundPath" {
|
|
449
449
|
/**
|
|
450
450
|
* Rounds the values of a `pathArray` instance to
|
|
451
451
|
* a specified amount of decimals and returns it.
|
|
452
452
|
*
|
|
453
|
-
* @param {
|
|
453
|
+
* @param {SVGPath.pathArray} path the source `pathArray`
|
|
454
454
|
* @param {number | boolean} roundOption the amount of decimals to round numbers to
|
|
455
|
-
* @returns {
|
|
455
|
+
* @returns {SVGPath.pathArray} the resulted `pathArray` with rounded values
|
|
456
456
|
*/
|
|
457
|
-
export default function roundPath(path:
|
|
457
|
+
export default function roundPath(path: SVGPath.pathArray, roundOption: number | boolean): SVGPath.pathArray;
|
|
458
458
|
}
|
|
459
459
|
declare module "svg-path-commander/src/convert/pathToString" {
|
|
460
460
|
/**
|
|
461
461
|
* Returns a valid `d` attribute string value created
|
|
462
462
|
* by rounding values and concatenating the `pathArray` segments.
|
|
463
463
|
*
|
|
464
|
-
* @param {
|
|
464
|
+
* @param {SVGPath.pathArray} path the `pathArray` object
|
|
465
465
|
* @param {any} round amount of decimals to round values to
|
|
466
466
|
* @returns {string} the concatenated path string
|
|
467
467
|
*/
|
|
468
|
-
export default function pathToString(path:
|
|
468
|
+
export default function pathToString(path: SVGPath.pathArray, round: any): string;
|
|
469
469
|
}
|
|
470
470
|
declare module "svg-path-commander/src/math/epsilon" {
|
|
471
471
|
export default epsilon;
|
|
@@ -495,34 +495,34 @@ declare module "svg-path-commander/src/math/polygonLength" {
|
|
|
495
495
|
*
|
|
496
496
|
* Returns the perimeter of a polygon.
|
|
497
497
|
*
|
|
498
|
-
* @param {number
|
|
498
|
+
* @param {[number,number][]} polygon an array of coordinates
|
|
499
499
|
* @returns {number} the polygon length
|
|
500
500
|
*/
|
|
501
|
-
export default function polygonLength(polygon: number
|
|
501
|
+
export default function polygonLength(polygon: [number, number][]): number;
|
|
502
502
|
}
|
|
503
503
|
declare module "svg-path-commander/src/process/getSVGMatrix" {
|
|
504
504
|
/**
|
|
505
505
|
* Returns a transformation matrix to apply to `<path>` elements.
|
|
506
506
|
*
|
|
507
|
-
* @see
|
|
507
|
+
* @see SVGPath.transformObject
|
|
508
508
|
*
|
|
509
|
-
* @param {
|
|
509
|
+
* @param {SVGPath.transformObject} transform the `transformObject`
|
|
510
510
|
* @returns {CSSMatrix} a new transformation matrix
|
|
511
511
|
*/
|
|
512
|
-
export default function getSVGMatrix(transform:
|
|
512
|
+
export default function getSVGMatrix(transform: SVGPath.transformObject): CSSMatrix;
|
|
513
513
|
import CSSMatrix from "dommatrix";
|
|
514
514
|
}
|
|
515
515
|
declare module "svg-path-commander/src/process/shortenSegment" {
|
|
516
516
|
/**
|
|
517
517
|
* Shorten a single segment of a `pathArray` object.
|
|
518
518
|
*
|
|
519
|
-
* @param {
|
|
520
|
-
* @param {
|
|
519
|
+
* @param {SVGPath.absoluteSegment} segment the `absoluteSegment` object
|
|
520
|
+
* @param {SVGPath.normalSegment} normalSegment the `normalSegment` object
|
|
521
521
|
* @param {any} params the coordinates of the previous segment
|
|
522
522
|
* @param {string} prevCommand the path command of the previous segment
|
|
523
|
-
* @returns {
|
|
523
|
+
* @returns {SVGPath.shortSegment | SVGPath.pathSegment} the shortened segment
|
|
524
524
|
*/
|
|
525
|
-
export default function shortenSegment(segment:
|
|
525
|
+
export default function shortenSegment(segment: SVGPath.absoluteSegment, normalSegment: SVGPath.normalSegment, params: any, prevCommand: string): SVGPath.shortSegment | SVGPath.pathSegment;
|
|
526
526
|
}
|
|
527
527
|
declare module "svg-path-commander/src/process/optimizePath" {
|
|
528
528
|
/**
|
|
@@ -534,11 +534,11 @@ declare module "svg-path-commander/src/process/optimizePath" {
|
|
|
534
534
|
* * implement `auto` for rounding values based on pathBBox
|
|
535
535
|
* * also revers path check if it's smaller string, maybe?
|
|
536
536
|
*
|
|
537
|
-
* @param {
|
|
537
|
+
* @param {SVGPath.pathArray} pathInput a string or `pathArray`
|
|
538
538
|
* @param {number | boolean} round the amount of decimals to round values to
|
|
539
|
-
* @returns {
|
|
539
|
+
* @returns {SVGPath.pathArray} the optimized `pathArray`
|
|
540
540
|
*/
|
|
541
|
-
export default function optimizePath(pathInput:
|
|
541
|
+
export default function optimizePath(pathInput: SVGPath.pathArray, round: number | boolean): SVGPath.pathArray;
|
|
542
542
|
}
|
|
543
543
|
declare module "svg-path-commander/src/process/projection2d" {
|
|
544
544
|
/**
|
|
@@ -550,41 +550,40 @@ declare module "svg-path-commander/src/process/projection2d" {
|
|
|
550
550
|
* Details =>
|
|
551
551
|
* https://stackoverflow.com/questions/23792505/predicted-rendering-of-css-3d-transformed-pixel
|
|
552
552
|
*
|
|
553
|
-
* @param {
|
|
553
|
+
* @param {SVGPath.CSSMatrix} m the transformation matrix
|
|
554
554
|
* @param {[number, number]} point2D the initial [x,y] coordinates
|
|
555
|
-
* @param {number[]} origin the
|
|
555
|
+
* @param {number[]} origin the [x,y,z] transform origin
|
|
556
556
|
* @returns {[number, number]} the projected [x,y] coordinates
|
|
557
557
|
*/
|
|
558
|
-
export default function projection2d(m:
|
|
558
|
+
export default function projection2d(m: SVGPath.CSSMatrix, point2D: [number, number], origin: number[]): [number, number];
|
|
559
559
|
}
|
|
560
560
|
declare module "svg-path-commander/src/process/reverseCurve" {
|
|
561
561
|
/**
|
|
562
|
-
* Reverses all segments
|
|
562
|
+
* Reverses all segments of a `pathArray`
|
|
563
563
|
* which consists of only C (cubic-bezier) path commands.
|
|
564
564
|
*
|
|
565
|
-
* @param {
|
|
566
|
-
* @returns {
|
|
565
|
+
* @param {SVGPath.curveArray} path the source `pathArray`
|
|
566
|
+
* @returns {SVGPath.curveArray} the reversed `pathArray`
|
|
567
567
|
*/
|
|
568
|
-
export default function reverseCurve(path:
|
|
568
|
+
export default function reverseCurve(path: SVGPath.curveArray): SVGPath.curveArray;
|
|
569
569
|
}
|
|
570
570
|
declare module "svg-path-commander/src/process/reversePath" {
|
|
571
571
|
/**
|
|
572
|
-
* Reverses all segments
|
|
573
|
-
* and returns a new instance.
|
|
572
|
+
* Reverses all segments of a `pathArray` and returns a new `pathArray` instance.
|
|
574
573
|
*
|
|
575
|
-
* @param {
|
|
576
|
-
* @returns {
|
|
574
|
+
* @param {SVGPath.pathArray} pathInput the source `pathArray`
|
|
575
|
+
* @returns {SVGPath.pathArray} the reversed `pathArray`
|
|
577
576
|
*/
|
|
578
|
-
export default function reversePath(pathInput:
|
|
577
|
+
export default function reversePath(pathInput: SVGPath.pathArray): SVGPath.pathArray;
|
|
579
578
|
}
|
|
580
579
|
declare module "svg-path-commander/src/process/splitCubic" {
|
|
581
580
|
/**
|
|
582
581
|
* Split a cubic-bezier segment into two.
|
|
583
582
|
*
|
|
584
583
|
* @param {number[]} pts the cubic-bezier parameters
|
|
585
|
-
* @return {
|
|
584
|
+
* @return {SVGPath.cubicSegment[]} two new cubic-bezier segments
|
|
586
585
|
*/
|
|
587
|
-
export default function splitCubic(pts: number[]):
|
|
586
|
+
export default function splitCubic(pts: number[]): SVGPath.cubicSegment[];
|
|
588
587
|
}
|
|
589
588
|
declare module "svg-path-commander/src/process/splitPath" {
|
|
590
589
|
/**
|
|
@@ -593,10 +592,10 @@ declare module "svg-path-commander/src/process/splitPath" {
|
|
|
593
592
|
* In the process, values are converted to absolute
|
|
594
593
|
* for visual consistency.
|
|
595
594
|
*
|
|
596
|
-
* @param {
|
|
595
|
+
* @param {SVGPath.pathArray | string} pathInput the source `pathArray`
|
|
597
596
|
* @return {string[]} an array with all sub-path strings
|
|
598
597
|
*/
|
|
599
|
-
export default function splitPath(pathInput:
|
|
598
|
+
export default function splitPath(pathInput: SVGPath.pathArray | string): string[];
|
|
600
599
|
}
|
|
601
600
|
declare module "svg-path-commander/src/process/transformEllipse" {
|
|
602
601
|
/**
|
|
@@ -620,83 +619,15 @@ declare module "svg-path-commander/src/process/transformPath" {
|
|
|
620
619
|
* Since *SVGElement* doesn't support 3D transformation, this function
|
|
621
620
|
* creates a 2D projection of the <path> element.
|
|
622
621
|
*
|
|
623
|
-
* @param {
|
|
624
|
-
* @param {
|
|
625
|
-
* @returns {
|
|
622
|
+
* @param {SVGPath.pathArray} path the `pathArray` to apply transformation
|
|
623
|
+
* @param {SVGPath.transformObject} transform the transform functions `Object`
|
|
624
|
+
* @returns {SVGPath.pathArray} the resulted `pathArray`
|
|
626
625
|
*/
|
|
627
|
-
export default function transformPath(path:
|
|
628
|
-
}
|
|
629
|
-
declare module "svg-path-commander/src/util/shapeToPath" {
|
|
630
|
-
/**
|
|
631
|
-
* Returns a new `pathArray` from line attributes.
|
|
632
|
-
*
|
|
633
|
-
* @param {SVGPathCommander.lineAttr} attr shape configuration
|
|
634
|
-
* @returns {SVGPathCommander.pathArray} a new line `pathArray`
|
|
635
|
-
*/
|
|
636
|
-
export function getLinePath(attr: SVGPathCommander.lineAttr): SVGPathCommander.pathArray;
|
|
637
|
-
/**
|
|
638
|
-
* Returns a new `pathArray` like from polyline/polygon attributes.
|
|
639
|
-
*
|
|
640
|
-
* @param {SVGPathCommander.polyAttr} attr shape configuration
|
|
641
|
-
* @return {SVGPathCommander.pathArray} a new polygon/polyline `pathArray`
|
|
642
|
-
*/
|
|
643
|
-
export function getPolyPath(attr: SVGPathCommander.polyAttr): SVGPathCommander.pathArray;
|
|
644
|
-
/**
|
|
645
|
-
* Returns a new `pathArray` from circle attributes.
|
|
646
|
-
*
|
|
647
|
-
* @param {SVGPathCommander.circleAttr} attr shape configuration
|
|
648
|
-
* @return {SVGPathCommander.pathArray} a circle `pathArray`
|
|
649
|
-
*/
|
|
650
|
-
export function getCirclePath(attr: SVGPathCommander.circleAttr): SVGPathCommander.pathArray;
|
|
651
|
-
/**
|
|
652
|
-
* Returns a new `pathArray` from ellipse attributes.
|
|
653
|
-
*
|
|
654
|
-
* @param {SVGPathCommander.ellipseAttr} attr shape configuration
|
|
655
|
-
* @return {SVGPathCommander.pathArray} an ellipse `pathArray`
|
|
656
|
-
*/
|
|
657
|
-
export function getEllipsePath(attr: SVGPathCommander.ellipseAttr): SVGPathCommander.pathArray;
|
|
658
|
-
/**
|
|
659
|
-
* Returns a new `pathArray` like from rect attributes.
|
|
660
|
-
*
|
|
661
|
-
* @param {SVGPathCommander.rectAttr} attr object with properties above
|
|
662
|
-
* @return {SVGPathCommander.pathArray} a new `pathArray` from `<rect>` attributes
|
|
663
|
-
*/
|
|
664
|
-
export function getRectanglePath(attr: SVGPathCommander.rectAttr): SVGPathCommander.pathArray;
|
|
665
|
-
/**
|
|
666
|
-
* Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`,
|
|
667
|
-
* `<polygon>`, `<rect>`, `<ellipse>`, `<circle>` or `<glyph>`. If `replace` parameter
|
|
668
|
-
* is `true`, it will replace the target.
|
|
669
|
-
*
|
|
670
|
-
* It can also work with an options object,
|
|
671
|
-
* @see SVGPathCommander.shapeOps
|
|
672
|
-
*
|
|
673
|
-
* The newly created `<path>` element keeps all non-specific
|
|
674
|
-
* attributes like `class`, `fill`, etc.
|
|
675
|
-
*
|
|
676
|
-
* @param {SVGPathCommander.shapeTypes | SVGPathCommander.shapeOps} element target shape
|
|
677
|
-
* @param {boolean=} replace option to replace target
|
|
678
|
-
* @return {SVGPathElement | boolean} the newly created `<path>` element
|
|
679
|
-
*/
|
|
680
|
-
export default function shapeToPath(element: SVGPathCommander.shapeTypes | SVGPathCommander.shapeOps, replace?: boolean | undefined): SVGPathElement | boolean;
|
|
681
|
-
}
|
|
682
|
-
declare module "svg-path-commander/src/util/createPath" {
|
|
683
|
-
/**
|
|
684
|
-
* Returns a new `<path>` from a `<glyph>` element, only using its `d` attribute,
|
|
685
|
-
* all other attributes are ignored.
|
|
686
|
-
*
|
|
687
|
-
* If `pathInput` is a valid path string, will create a `<path>` and return it.
|
|
688
|
-
*
|
|
689
|
-
* @deprecated
|
|
690
|
-
* @see shapeToPath a new and more flexible utility
|
|
691
|
-
*
|
|
692
|
-
* @param {SVGPathCommander.shapeTypes} pathInput a `<glyph>` element or path string
|
|
693
|
-
* @returns {SVGPathElement | boolean} a new `<path>` element
|
|
694
|
-
*/
|
|
695
|
-
export default function createPath(pathInput: SVGPathCommander.shapeTypes): SVGPathElement | boolean;
|
|
626
|
+
export default function transformPath(path: SVGPath.pathArray, transform: SVGPath.transformObject): SVGPath.pathArray;
|
|
696
627
|
}
|
|
697
628
|
declare module "svg-path-commander/src/util/segmentCubicFactory" {
|
|
698
629
|
/**
|
|
699
|
-
* Returns the length of a C (cubic-bezier) segment
|
|
630
|
+
* Returns the length of a C (cubic-bezier) segment
|
|
700
631
|
* or an {x,y} point at a given length.
|
|
701
632
|
*
|
|
702
633
|
* @param {number} x1 the starting point X
|
|
@@ -727,9 +658,9 @@ declare module "svg-path-commander/src/util/getCubicSize" {
|
|
|
727
658
|
* @param {number} c2y the second control point Y
|
|
728
659
|
* @param {number} x2 the ending point X
|
|
729
660
|
* @param {number} y2 the ending point Y
|
|
730
|
-
* @returns {
|
|
661
|
+
* @returns {SVGPath.segmentLimits} the bounding box of the cubic-bezier segment
|
|
731
662
|
*/
|
|
732
|
-
export default function getCubicSize(x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number):
|
|
663
|
+
export default function getCubicSize(x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number): SVGPath.segmentLimits;
|
|
733
664
|
}
|
|
734
665
|
declare module "svg-path-commander/src/util/getPathArea" {
|
|
735
666
|
/**
|
|
@@ -738,29 +669,29 @@ declare module "svg-path-commander/src/util/getPathArea" {
|
|
|
738
669
|
*
|
|
739
670
|
* @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
|
|
740
671
|
*
|
|
741
|
-
* @param {
|
|
672
|
+
* @param {SVGPath.pathArray} path the shape `pathArray`
|
|
742
673
|
* @returns {number} the length of the cubic-bezier segment
|
|
743
674
|
*/
|
|
744
|
-
export default function getPathArea(path:
|
|
675
|
+
export default function getPathArea(path: SVGPath.pathArray): number;
|
|
745
676
|
}
|
|
746
677
|
declare module "svg-path-commander/src/util/getDrawDirection" {
|
|
747
678
|
/**
|
|
748
679
|
* Check if a path is drawn clockwise and returns true if so,
|
|
749
680
|
* false otherwise.
|
|
750
681
|
*
|
|
751
|
-
* @param {
|
|
682
|
+
* @param {SVGPath.pathArray} path the path string or `pathArray`
|
|
752
683
|
* @returns {boolean} true when clockwise or false if not
|
|
753
684
|
*/
|
|
754
|
-
export default function getDrawDirection(path:
|
|
685
|
+
export default function getDrawDirection(path: SVGPath.pathArray): boolean;
|
|
755
686
|
}
|
|
756
687
|
declare module "svg-path-commander/src/util/getPathBBox" {
|
|
757
688
|
/**
|
|
758
689
|
* Returns the bounding box of a shape.
|
|
759
690
|
*
|
|
760
|
-
* @param {
|
|
761
|
-
* @returns {
|
|
691
|
+
* @param {SVGPath.pathArray} path the shape `pathArray`
|
|
692
|
+
* @returns {SVGPath.pathBBox} the length of the cubic-bezier segment
|
|
762
693
|
*/
|
|
763
|
-
export default function getPathBBox(path:
|
|
694
|
+
export default function getPathBBox(path: SVGPath.pathArray): SVGPath.pathBBox;
|
|
764
695
|
}
|
|
765
696
|
declare module "svg-path-commander/src/util/getPathLength" {
|
|
766
697
|
/**
|
|
@@ -769,14 +700,14 @@ declare module "svg-path-commander/src/util/getPathLength" {
|
|
|
769
700
|
* This is the `pathToCurve` version which is faster and more efficient for
|
|
770
701
|
* paths that are `curveArray`.
|
|
771
702
|
*
|
|
772
|
-
* @param {string |
|
|
703
|
+
* @param {string | SVGPath.curveArray} path the target `pathArray`
|
|
773
704
|
* @returns {number} the `curveArray` total length
|
|
774
705
|
*/
|
|
775
|
-
export default function getPathLength(path: string |
|
|
706
|
+
export default function getPathLength(path: string | SVGPath.curveArray): number;
|
|
776
707
|
}
|
|
777
708
|
declare module "svg-path-commander/src/util/segmentArcFactory" {
|
|
778
709
|
/**
|
|
779
|
-
* Returns the length of
|
|
710
|
+
* Returns the length of an A (arc-to) segment
|
|
780
711
|
* or an {x,y} point at a given length.
|
|
781
712
|
*
|
|
782
713
|
* @param {number} X1 the starting x position
|
|
@@ -798,7 +729,7 @@ declare module "svg-path-commander/src/util/segmentArcFactory" {
|
|
|
798
729
|
}
|
|
799
730
|
declare module "svg-path-commander/src/util/segmentQuadFactory" {
|
|
800
731
|
/**
|
|
801
|
-
* Returns the Q (quadratic-bezier) segment length
|
|
732
|
+
* Returns the Q (quadratic-bezier) segment length
|
|
802
733
|
* or an {x,y} point at a given length.
|
|
803
734
|
*
|
|
804
735
|
* @param {number} x1 the starting point X
|
|
@@ -817,13 +748,14 @@ declare module "svg-path-commander/src/util/segmentQuadFactory" {
|
|
|
817
748
|
}
|
|
818
749
|
declare module "svg-path-commander/src/util/pathLengthFactory" {
|
|
819
750
|
/**
|
|
820
|
-
* Returns a {x,y} point at a given length
|
|
751
|
+
* Returns a {x,y} point at a given length
|
|
752
|
+
* of a shape or the shape total length.
|
|
821
753
|
*
|
|
822
|
-
* @param {string |
|
|
754
|
+
* @param {string | SVGPath.pathArray} pathInput the `pathArray` to look into
|
|
823
755
|
* @param {number=} distance the length of the shape to look at
|
|
824
756
|
* @returns {{x: number, y: number} | number} the total length or point
|
|
825
757
|
*/
|
|
826
|
-
export default function pathLengthFactory(pathInput: string |
|
|
758
|
+
export default function pathLengthFactory(pathInput: string | SVGPath.pathArray, distance?: number | undefined): number | {
|
|
827
759
|
x: number;
|
|
828
760
|
y: number;
|
|
829
761
|
};
|
|
@@ -835,36 +767,20 @@ declare module "svg-path-commander/src/util/getTotalLength" {
|
|
|
835
767
|
* The `normalizePath` version is lighter, faster, more efficient and more accurate
|
|
836
768
|
* with paths that are not `curveArray`.
|
|
837
769
|
*
|
|
838
|
-
* @param {string |
|
|
770
|
+
* @param {string | SVGPath.pathArray} pathInput the target `pathArray`
|
|
839
771
|
* @returns {number} the shape total length
|
|
840
772
|
*/
|
|
841
|
-
export default function getTotalLength(pathInput: string |
|
|
773
|
+
export default function getTotalLength(pathInput: string | SVGPath.pathArray): number;
|
|
842
774
|
}
|
|
843
775
|
declare module "svg-path-commander/src/util/getPointAtLength" {
|
|
844
776
|
/**
|
|
845
777
|
* Returns [x,y] coordinates of a point at a given length of a shape.
|
|
846
778
|
*
|
|
847
|
-
* @param {string |
|
|
779
|
+
* @param {string | SVGPath.pathArray} pathInput the `pathArray` to look into
|
|
848
780
|
* @param {number} distance the length of the shape to look at
|
|
849
781
|
* @returns {{x: number, y: number}} the requested {x, y} point coordinates
|
|
850
782
|
*/
|
|
851
|
-
export default function getPointAtLength(pathInput: string |
|
|
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
|
-
* @deprecated
|
|
862
|
-
*
|
|
863
|
-
* @param {string | SVGPathCommander.pathArray} pathInput the `pathArray` to look into
|
|
864
|
-
* @param {number} distance the length of the shape to look at
|
|
865
|
-
* @returns {{x: number, y: number}} the requested {x, y} point coordinates
|
|
866
|
-
*/
|
|
867
|
-
export default function getPointAtPathLength(pathInput: string | SVGPathCommander.pathArray, distance: number): {
|
|
783
|
+
export default function getPointAtLength(pathInput: string | SVGPath.pathArray, distance: number): {
|
|
868
784
|
x: number;
|
|
869
785
|
y: number;
|
|
870
786
|
};
|
|
@@ -874,11 +790,11 @@ declare module "svg-path-commander/src/util/getPropertiesAtLength" {
|
|
|
874
790
|
* Returns the segment, its index and length as well as
|
|
875
791
|
* the length to that segment at a given length in a path.
|
|
876
792
|
*
|
|
877
|
-
* @param {string |
|
|
793
|
+
* @param {string | SVGPath.pathArray} pathInput target `pathArray`
|
|
878
794
|
* @param {number=} distance the given length
|
|
879
|
-
* @returns {
|
|
795
|
+
* @returns {SVGPath.segmentProperties=} the requested properties
|
|
880
796
|
*/
|
|
881
|
-
export default function getPropertiesAtLength(pathInput: string |
|
|
797
|
+
export default function getPropertiesAtLength(pathInput: string | SVGPath.pathArray, distance?: number | undefined): SVGPath.segmentProperties | undefined;
|
|
882
798
|
}
|
|
883
799
|
declare module "svg-path-commander/src/util/getPropertiesAtPoint" {
|
|
884
800
|
/**
|
|
@@ -886,24 +802,24 @@ declare module "svg-path-commander/src/util/getPropertiesAtPoint" {
|
|
|
886
802
|
* the distance to the path stroke.
|
|
887
803
|
* @see https://bl.ocks.org/mbostock/8027637
|
|
888
804
|
*
|
|
889
|
-
* @param {string |
|
|
805
|
+
* @param {string | SVGPath.pathArray} pathInput target `pathArray`
|
|
890
806
|
* @param {{x: number, y: number}} point the given point
|
|
891
|
-
* @returns {
|
|
807
|
+
* @returns {SVGPath.pointProperties} the requested properties
|
|
892
808
|
*/
|
|
893
|
-
export default function getPropertiesAtPoint(pathInput: string |
|
|
809
|
+
export default function getPropertiesAtPoint(pathInput: string | SVGPath.pathArray, point: {
|
|
894
810
|
x: number;
|
|
895
811
|
y: number;
|
|
896
|
-
}):
|
|
812
|
+
}): SVGPath.pointProperties;
|
|
897
813
|
}
|
|
898
814
|
declare module "svg-path-commander/src/util/getClosestPoint" {
|
|
899
815
|
/**
|
|
900
816
|
* Returns the point in path closest to a given point.
|
|
901
817
|
*
|
|
902
|
-
* @param {string |
|
|
818
|
+
* @param {string | SVGPath.pathArray} pathInput target `pathArray`
|
|
903
819
|
* @param {{x: number, y: number}} point the given point
|
|
904
820
|
* @returns {{x: number, y: number}} the best match
|
|
905
821
|
*/
|
|
906
|
-
export default function getClosestPoint(pathInput: string |
|
|
822
|
+
export default function getClosestPoint(pathInput: string | SVGPath.pathArray, point: {
|
|
907
823
|
x: number;
|
|
908
824
|
y: number;
|
|
909
825
|
}): {
|
|
@@ -914,34 +830,34 @@ declare module "svg-path-commander/src/util/getClosestPoint" {
|
|
|
914
830
|
declare module "svg-path-commander/src/util/getSegmentAtLength" {
|
|
915
831
|
/**
|
|
916
832
|
* Returns the segment at a given length.
|
|
917
|
-
* @param {string |
|
|
833
|
+
* @param {string | SVGPath.pathArray} pathInput the target `pathArray`
|
|
918
834
|
* @param {number} distance the distance in path to look at
|
|
919
|
-
* @returns {
|
|
835
|
+
* @returns {SVGPath.pathSegment?} the requested segment
|
|
920
836
|
*/
|
|
921
|
-
export default function getSegmentAtLength(pathInput: string |
|
|
837
|
+
export default function getSegmentAtLength(pathInput: string | SVGPath.pathArray, distance: number): SVGPath.pathSegment | null;
|
|
922
838
|
}
|
|
923
839
|
declare module "svg-path-commander/src/util/getSegmentOfPoint" {
|
|
924
840
|
/**
|
|
925
841
|
* Returns the path segment which contains a given point.
|
|
926
842
|
*
|
|
927
|
-
* @param {string |
|
|
843
|
+
* @param {string | SVGPath.pathArray} path the `pathArray` to look into
|
|
928
844
|
* @param {{x: number, y: number}} point the point of the shape to look for
|
|
929
|
-
* @returns {
|
|
845
|
+
* @returns {SVGPath.pathSegment?} the requested segment
|
|
930
846
|
*/
|
|
931
|
-
export default function getSegmentOfPoint(path: string |
|
|
847
|
+
export default function getSegmentOfPoint(path: string | SVGPath.pathArray, point: {
|
|
932
848
|
x: number;
|
|
933
849
|
y: number;
|
|
934
|
-
}):
|
|
850
|
+
}): SVGPath.pathSegment | null;
|
|
935
851
|
}
|
|
936
852
|
declare module "svg-path-commander/src/util/isPointInStroke" {
|
|
937
853
|
/**
|
|
938
854
|
* Checks if a given point is in the stroke of a path.
|
|
939
855
|
*
|
|
940
|
-
* @param {string |
|
|
941
|
-
* @param {{x: number, y: number}} point
|
|
856
|
+
* @param {string | SVGPath.pathArray} pathInput target path
|
|
857
|
+
* @param {{x: number, y: number}} point the given `{x,y}` point
|
|
942
858
|
* @returns {boolean} the query result
|
|
943
859
|
*/
|
|
944
|
-
export default function isPointInStroke(pathInput: string |
|
|
860
|
+
export default function isPointInStroke(pathInput: string | SVGPath.pathArray, point: {
|
|
945
861
|
x: number;
|
|
946
862
|
y: number;
|
|
947
863
|
}): boolean;
|
|
@@ -956,6 +872,59 @@ declare module "svg-path-commander/src/util/isValidPath" {
|
|
|
956
872
|
*/
|
|
957
873
|
export default function isValidPath(pathString: string): boolean;
|
|
958
874
|
}
|
|
875
|
+
declare module "svg-path-commander/src/util/shapeToPath" {
|
|
876
|
+
/**
|
|
877
|
+
* Returns a new `pathArray` from line attributes.
|
|
878
|
+
*
|
|
879
|
+
* @param {SVGPath.lineAttr} attr shape configuration
|
|
880
|
+
* @returns {SVGPath.pathArray} a new line `pathArray`
|
|
881
|
+
*/
|
|
882
|
+
export function getLinePath(attr: SVGPath.lineAttr): SVGPath.pathArray;
|
|
883
|
+
/**
|
|
884
|
+
* Returns a new `pathArray` like from polyline/polygon attributes.
|
|
885
|
+
*
|
|
886
|
+
* @param {SVGPath.polyAttr} attr shape configuration
|
|
887
|
+
* @return {SVGPath.pathArray} a new polygon/polyline `pathArray`
|
|
888
|
+
*/
|
|
889
|
+
export function getPolyPath(attr: SVGPath.polyAttr): SVGPath.pathArray;
|
|
890
|
+
/**
|
|
891
|
+
* Returns a new `pathArray` from circle attributes.
|
|
892
|
+
*
|
|
893
|
+
* @param {SVGPath.circleAttr} attr shape configuration
|
|
894
|
+
* @return {SVGPath.pathArray} a circle `pathArray`
|
|
895
|
+
*/
|
|
896
|
+
export function getCirclePath(attr: SVGPath.circleAttr): SVGPath.pathArray;
|
|
897
|
+
/**
|
|
898
|
+
* Returns a new `pathArray` from ellipse attributes.
|
|
899
|
+
*
|
|
900
|
+
* @param {SVGPath.ellipseAttr} attr shape configuration
|
|
901
|
+
* @return {SVGPath.pathArray} an ellipse `pathArray`
|
|
902
|
+
*/
|
|
903
|
+
export function getEllipsePath(attr: SVGPath.ellipseAttr): SVGPath.pathArray;
|
|
904
|
+
/**
|
|
905
|
+
* Returns a new `pathArray` like from rect attributes.
|
|
906
|
+
*
|
|
907
|
+
* @param {SVGPath.rectAttr} attr object with properties above
|
|
908
|
+
* @return {SVGPath.pathArray} a new `pathArray` from `<rect>` attributes
|
|
909
|
+
*/
|
|
910
|
+
export function getRectanglePath(attr: SVGPath.rectAttr): SVGPath.pathArray;
|
|
911
|
+
/**
|
|
912
|
+
* Returns a new `<path>` element created from attributes of a `<line>`, `<polyline>`,
|
|
913
|
+
* `<polygon>`, `<rect>`, `<ellipse>`, `<circle>` or `<glyph>`. If `replace` parameter
|
|
914
|
+
* is `true`, it will replace the target.
|
|
915
|
+
*
|
|
916
|
+
* It can also work with an options object,
|
|
917
|
+
* @see SVGPath.shapeOps
|
|
918
|
+
*
|
|
919
|
+
* The newly created `<path>` element keeps all non-specific
|
|
920
|
+
* attributes like `class`, `fill`, etc.
|
|
921
|
+
*
|
|
922
|
+
* @param {SVGPath.shapeTypes | SVGPath.shapeOps} element target shape
|
|
923
|
+
* @param {boolean=} replace option to replace target
|
|
924
|
+
* @return {SVGPathElement | boolean} the newly created `<path>` element
|
|
925
|
+
*/
|
|
926
|
+
export default function shapeToPath(element: SVGPath.shapeTypes | SVGPath.shapeOps, replace?: boolean | undefined): SVGPathElement | boolean;
|
|
927
|
+
}
|
|
959
928
|
declare module "svg-path-commander/src/version" {
|
|
960
929
|
export default Version;
|
|
961
930
|
/**
|
|
@@ -984,15 +953,36 @@ declare module "svg-path-commander/src/svg-path-commander" {
|
|
|
984
953
|
*/
|
|
985
954
|
constructor(pathValue: string, config: any);
|
|
986
955
|
/**
|
|
987
|
-
* @type {
|
|
956
|
+
* @type {SVGPath.pathArray}
|
|
988
957
|
*/
|
|
989
|
-
segments:
|
|
958
|
+
segments: SVGPath.pathArray;
|
|
990
959
|
/**
|
|
991
960
|
* @type {number | boolean}
|
|
992
961
|
* @default 4
|
|
993
962
|
*/
|
|
994
|
-
round: number |
|
|
995
|
-
origin: number
|
|
963
|
+
round: number | false;
|
|
964
|
+
origin: [number, number, number];
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Returns the path bounding box, equivalent to native `path.getBBox()`.
|
|
968
|
+
* @public
|
|
969
|
+
* @returns {SVGPath.pathBBox}
|
|
970
|
+
*/
|
|
971
|
+
public getBBox(): SVGPath.pathBBox;
|
|
972
|
+
/**
|
|
973
|
+
* Returns the total path length, equivalent to native `path.getTotalLength()`.
|
|
974
|
+
* @public
|
|
975
|
+
* @returns {number}
|
|
976
|
+
*/
|
|
977
|
+
public getTotalLength(): number;
|
|
978
|
+
/**
|
|
979
|
+
* Returns an `{x,y}` point in the path stroke at a given length,
|
|
980
|
+
* equivalent to the native `path.getPointAtLength()`.
|
|
981
|
+
* @public
|
|
982
|
+
* @param {number} length the length
|
|
983
|
+
* @returns {{x: number, y:number}} the requested point
|
|
984
|
+
*/
|
|
985
|
+
public getPointAtLength(length: number): {x: number, y:number};
|
|
996
986
|
/**
|
|
997
987
|
* Convert path to absolute values
|
|
998
988
|
* @public
|
|
@@ -1033,12 +1023,12 @@ declare module "svg-path-commander/src/svg-path-commander" {
|
|
|
1033
1023
|
public optimize(): SVGPathCommander;
|
|
1034
1024
|
/**
|
|
1035
1025
|
* Transform path using values from an `Object` defined as `transformObject`.
|
|
1036
|
-
* @see
|
|
1026
|
+
* @see SVGPath.transformObject for a quick refference
|
|
1037
1027
|
*
|
|
1038
|
-
* @param {
|
|
1028
|
+
* @param {SVGPath.transformObject} source a `transformObject`as described above
|
|
1039
1029
|
* @public
|
|
1040
1030
|
*/
|
|
1041
|
-
public transform(source:
|
|
1031
|
+
public transform(source: SVGPath.transformObject): SVGPathCommander;
|
|
1042
1032
|
/**
|
|
1043
1033
|
* Rotate path 180deg horizontally
|
|
1044
1034
|
* @public
|
|
@@ -1107,7 +1097,6 @@ declare module "svg-path-commander/types/more/modules" {
|
|
|
1107
1097
|
export { default as splitPath } from "svg-path-commander/src/process/splitPath";
|
|
1108
1098
|
export { default as transformEllipse } from "svg-path-commander/src/process/transformEllipse";
|
|
1109
1099
|
export { default as transformPath } from "svg-path-commander/src/process/transformPath";
|
|
1110
|
-
export { default as createPath } from "svg-path-commander/src/util/createPath";
|
|
1111
1100
|
export { default as getCubicSize } from "svg-path-commander/src/util/getCubicSize";
|
|
1112
1101
|
export { default as getDrawDirection } from "svg-path-commander/src/util/getDrawDirection";
|
|
1113
1102
|
export { default as getPathArea } from "svg-path-commander/src/util/getPathArea";
|
|
@@ -1119,7 +1108,6 @@ declare module "svg-path-commander/types/more/modules" {
|
|
|
1119
1108
|
export { default as segmentCubicFactory } from "svg-path-commander/src/util/segmentCubicFactory";
|
|
1120
1109
|
export { default as segmentQuadFactory } from "svg-path-commander/src/util/segmentQuadFactory";
|
|
1121
1110
|
export { default as getPointAtLength } from "svg-path-commander/src/util/getPointAtLength";
|
|
1122
|
-
export { default as getPointAtPathLength } from "svg-path-commander/src/util/getPointAtPathLength";
|
|
1123
1111
|
export { default as getPropertiesAtPoint } from "svg-path-commander/src/util/getPropertiesAtPoint";
|
|
1124
1112
|
export { default as getPropertiesAtLength } from "svg-path-commander/src/util/getPropertiesAtLength";
|
|
1125
1113
|
export { default as getClosestPoint } from "svg-path-commander/src/util/getClosestPoint";
|