plotboilerplate 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.esm.js +81 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +81 -39
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Bounds.d.ts +4 -5
- package/src/cjs/Bounds.js +6 -8
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +2 -1
- package/src/cjs/PlotBoilerplate.js +9 -3
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/VEllipseSector.d.ts +4 -3
- package/src/cjs/VEllipseSector.js +15 -8
- package/src/cjs/VEllipseSector.js.map +1 -1
- package/src/cjs/Vertex.d.ts +33 -1
- package/src/cjs/Vertex.js +43 -1
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +2 -1
- package/src/cjs/drawutilssvg.js +7 -19
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/entry.js +1 -0
- package/src/cjs/interfaces/core.d.ts +3 -0
- package/src/cjs/interfaces/core.js +1 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/algorithms/detectPaths.d.ts +3 -2
- package/src/cjs/utils/creategui.js +7 -0
- package/src/cjs/utils/datastructures/Color.d.ts +1 -1
- package/src/cjs/utils/datastructures/Color.js +4 -2
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/cjs/utils/io/FileDrop.d.ts +11 -1
- package/src/cjs/utils/io/FileDrop.js +41 -10
- package/src/cjs/utils/io/FileDrop.js.map +1 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.d.ts +26 -0
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js +463 -0
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -0
- package/src/cjs/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js +49 -0
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -0
- package/src/cjs/utils/parsers/svg/types.d.ts +43 -0
- package/src/cjs/utils/parsers/svg/types.js +16 -0
- package/src/cjs/utils/parsers/svg/types.js.map +1 -0
- package/src/esm/Bounds.d.ts +4 -5
- package/src/esm/Bounds.js +6 -8
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +2 -1
- package/src/esm/PlotBoilerplate.js +10 -4
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/VEllipseSector.d.ts +4 -3
- package/src/esm/VEllipseSector.js +15 -8
- package/src/esm/VEllipseSector.js.map +1 -1
- package/src/esm/Vertex.d.ts +33 -1
- package/src/esm/Vertex.js +43 -1
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +2 -1
- package/src/esm/drawutilssvg.js +7 -19
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/entry.js +1 -0
- package/src/esm/interfaces/core.d.ts +3 -0
- package/src/esm/interfaces/core.js +1 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/algorithms/detectPaths.d.ts +3 -2
- package/src/esm/utils/algorithms/detectPaths.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +1 -1
- package/src/esm/utils/datastructures/Color.js +4 -2
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/esm/utils/io/FileDrop.d.ts +11 -1
- package/src/esm/utils/io/FileDrop.js +41 -10
- package/src/esm/utils/io/FileDrop.js.map +1 -1
- package/src/esm/utils/parsers/svg/parseSVGPathData.d.ts +26 -0
- package/src/esm/utils/parsers/svg/parseSVGPathData.js +459 -0
- package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -0
- package/src/esm/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
- package/src/esm/utils/parsers/svg/splitSVGPathData.js +45 -0
- package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -0
- package/src/esm/utils/parsers/svg/types.d.ts +43 -0
- package/src/esm/utils/parsers/svg/types.js +15 -0
- package/src/esm/utils/parsers/svg/types.js.map +1 -0
- package/src/ts/Bounds.ts +6 -8
- package/src/ts/PlotBoilerplate.ts +11 -4
- package/src/ts/VEllipseSector.ts +22 -15
- package/src/ts/Vertex.ts +46 -1
- package/src/ts/drawutilssvg.ts +8 -19
- package/src/ts/interfaces/core.ts +3 -0
- package/src/ts/utils/algorithms/detectPaths.ts +1 -1
- package/src/ts/utils/datastructures/Color.ts +8 -4
- package/src/ts/utils/io/FileDrop.ts +51 -10
- package/src/ts/utils/parsers/svg/parseSVGPathData.ts +572 -0
- package/src/ts/utils/parsers/svg/splitSVGPathData.ts +50 -0
- package/src/ts/utils/parsers/svg/types.ts +70 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse SVG path data strings and convert to PlotBoilerplate path objects.
|
|
3
|
+
*
|
|
4
|
+
* As this parser function does not detect all possible path data strings it should cover the most daily use-cases.
|
|
5
|
+
*
|
|
6
|
+
* For more insight see
|
|
7
|
+
* https://www.w3.org/TR/SVG/paths.html
|
|
8
|
+
*
|
|
9
|
+
* @author Ikaros Kappler
|
|
10
|
+
* @date 2022-11-06
|
|
11
|
+
* @modified 2022-12-21 (winter solstice) Porting this to Typescript.
|
|
12
|
+
* @version 0.0.1-alpha
|
|
13
|
+
**/
|
|
14
|
+
import { CubicBezierCurve } from "../../../CubicBezierCurve";
|
|
15
|
+
import { Line } from "../../../Line";
|
|
16
|
+
import { VEllipseSector } from "../../../VEllipseSector";
|
|
17
|
+
import { Vertex } from "../../../Vertex";
|
|
18
|
+
import { splitSVGPathData } from "./splitSVGPathData";
|
|
19
|
+
const DEG_TO_RAD = Math.PI / 180;
|
|
20
|
+
/**
|
|
21
|
+
* Transform the given path data (translate and scale. rotating is not intended here).
|
|
22
|
+
*
|
|
23
|
+
* @date 2022-11-06
|
|
24
|
+
*
|
|
25
|
+
* @name parseSVGPathData
|
|
26
|
+
* @static
|
|
27
|
+
* @param {string} data - The data to parse.
|
|
28
|
+
* @return An array of straight line segments (Line) or curve segments (CubicBezierCurve) representing the path.
|
|
29
|
+
*/
|
|
30
|
+
export const parseSVGPathData = (dataString) => {
|
|
31
|
+
const dataElements = splitSVGPathData(dataString);
|
|
32
|
+
if (!dataElements) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
// Array<PathSegments>
|
|
36
|
+
const result = [];
|
|
37
|
+
var i = 0;
|
|
38
|
+
const firstPoint = { x: NaN, y: NaN };
|
|
39
|
+
const lastPoint = { x: NaN, y: NaN };
|
|
40
|
+
const lastControlPoint = { x: NaN, y: NaN };
|
|
41
|
+
while (i < dataElements.length) {
|
|
42
|
+
// Could this also be SVGPathShorthandQuadraticCurveToCommand?
|
|
43
|
+
const data = dataElements[i];
|
|
44
|
+
const cmd = data[0];
|
|
45
|
+
// console.log("cmd", cmd, "data", data);
|
|
46
|
+
switch (data[0]) {
|
|
47
|
+
case "M":
|
|
48
|
+
// MoveTo: M|m x y
|
|
49
|
+
_handleMove(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
50
|
+
break;
|
|
51
|
+
case "m":
|
|
52
|
+
// MoveTo: M|m x y
|
|
53
|
+
_handleMove(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
54
|
+
break;
|
|
55
|
+
case "L":
|
|
56
|
+
// LineTo L|l x y
|
|
57
|
+
_handleLineTo(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
58
|
+
break;
|
|
59
|
+
case "l":
|
|
60
|
+
// LineTo L|l x y
|
|
61
|
+
_handleLineTo(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
62
|
+
break;
|
|
63
|
+
case "H":
|
|
64
|
+
// HorizontalLineTo: H|h x
|
|
65
|
+
_handleHorizontalLineTo(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
66
|
+
break;
|
|
67
|
+
case "h":
|
|
68
|
+
// HorizontalLineTo: H|h x
|
|
69
|
+
_handleHorizontalLineTo(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
70
|
+
break;
|
|
71
|
+
case "V":
|
|
72
|
+
// VerticalLineTo: V|v y
|
|
73
|
+
_handleVerticalLineTo(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
74
|
+
break;
|
|
75
|
+
case "v":
|
|
76
|
+
// VerticalLineTo: V|v y
|
|
77
|
+
_handleVerticalLineTo(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
78
|
+
break;
|
|
79
|
+
case "C":
|
|
80
|
+
// CurveTo: C|c x1 y1 x2 y2 x y
|
|
81
|
+
_handleCubicBezierTo(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
82
|
+
break;
|
|
83
|
+
case "c":
|
|
84
|
+
// CurveTo: C|c x1 y1 x2 y2 x y
|
|
85
|
+
_handleCubicBezierTo(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
86
|
+
break;
|
|
87
|
+
case "S":
|
|
88
|
+
_handleShorthandCubicCurveTo(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
89
|
+
break;
|
|
90
|
+
case "s":
|
|
91
|
+
_handleShorthandCubicCurveTo(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
92
|
+
break;
|
|
93
|
+
case "Q":
|
|
94
|
+
// QuadraticCurveTo: Q|q x1 y1 x y
|
|
95
|
+
_handleQuadraticCurveTo(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
96
|
+
break;
|
|
97
|
+
case "q":
|
|
98
|
+
// QuadraticCurveTo: Q|q x1 y1 x y
|
|
99
|
+
_handleQuadraticCurveTo(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
100
|
+
break;
|
|
101
|
+
case "A":
|
|
102
|
+
// EllipticalArcTo: A|a rx ry x-axis-rotation large-arc-flag sweep-flag x y
|
|
103
|
+
_handleArcTo(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
104
|
+
break;
|
|
105
|
+
case "a":
|
|
106
|
+
// EllipticalArcTo: A|a rx ry x-axis-rotation large-arc-flag sweep-flag x y
|
|
107
|
+
_handleArcTo(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
108
|
+
break;
|
|
109
|
+
case "z":
|
|
110
|
+
_handleClosePath(data, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
111
|
+
break;
|
|
112
|
+
case "Z":
|
|
113
|
+
// ClosePath: Z|z (no arguments)
|
|
114
|
+
_handleClosePath(data, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
115
|
+
// i++;
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
if (cmd === "T") {
|
|
119
|
+
throw "T command only allowed after q command.";
|
|
120
|
+
}
|
|
121
|
+
if (cmd === "t") {
|
|
122
|
+
throw "t command only allowed after q command.";
|
|
123
|
+
}
|
|
124
|
+
throw "Unknown SVG path command found: " + cmd + ".";
|
|
125
|
+
}
|
|
126
|
+
// Safepoint: continue reading token by token until something is recognized again
|
|
127
|
+
i++;
|
|
128
|
+
} // END while
|
|
129
|
+
return result;
|
|
130
|
+
}; // END parseSVGPathData
|
|
131
|
+
// Just update the current position
|
|
132
|
+
const _handleMove = (data, isRelative, firstPoint, lastPoint, lastControlPoint, _result) => {
|
|
133
|
+
if (data.length < 3) {
|
|
134
|
+
throw "Unsufficient params for MOVE";
|
|
135
|
+
}
|
|
136
|
+
// result.push( new)
|
|
137
|
+
if (isRelative && !isNaN(lastPoint.x) && !isNaN(lastPoint.y)) {
|
|
138
|
+
lastPoint.x += Number(data[1]);
|
|
139
|
+
lastPoint.y += Number(data[2]);
|
|
140
|
+
lastControlPoint.x = lastPoint.x;
|
|
141
|
+
lastControlPoint.y = lastPoint.y;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
lastPoint.x = Number(data[1]);
|
|
145
|
+
lastPoint.y = Number(data[2]);
|
|
146
|
+
lastControlPoint.x = lastPoint.x;
|
|
147
|
+
lastControlPoint.y = lastPoint.y;
|
|
148
|
+
}
|
|
149
|
+
// console.log("AFTER MOVE", lastPoint);
|
|
150
|
+
if (isNaN(firstPoint.y)) {
|
|
151
|
+
firstPoint.x = lastPoint.x;
|
|
152
|
+
firstPoint.y = lastPoint.y;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
// Draw a line segment from the current position
|
|
156
|
+
const _handleLineTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
157
|
+
// console.log("Handle LINETO", data);
|
|
158
|
+
if (data.length < 3) {
|
|
159
|
+
throw "Unsufficient params for LINETO";
|
|
160
|
+
}
|
|
161
|
+
// console.log("Y: ", Number(data[2]), "lastPoint", lastPoint);
|
|
162
|
+
// result.push( new)
|
|
163
|
+
const line = new Line(new Vertex(lastPoint), new Vertex(lastPoint));
|
|
164
|
+
if (isRelative) {
|
|
165
|
+
line.b.x += Number(data[1]);
|
|
166
|
+
line.b.y += Number(data[2]);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
line.b.x = Number(data[1]);
|
|
170
|
+
line.b.y = Number(data[2]);
|
|
171
|
+
}
|
|
172
|
+
result.push(line);
|
|
173
|
+
lastPoint.x = line.b.x;
|
|
174
|
+
lastPoint.y = line.b.y;
|
|
175
|
+
lastControlPoint.x = line.b.x;
|
|
176
|
+
lastControlPoint.y = line.b.y;
|
|
177
|
+
if (isNaN(firstPoint.y)) {
|
|
178
|
+
firstPoint.x = line.a.x;
|
|
179
|
+
firstPoint.y = line.a.y;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const _handleHorizontalLineTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
183
|
+
// console.log("Handle HORIZONTALLINETO", data);
|
|
184
|
+
if (data.length < 2) {
|
|
185
|
+
throw "Unsufficient params for HORIZONTALLINETO";
|
|
186
|
+
}
|
|
187
|
+
// console.log("Y: ", Number(data[2]), "lastPoint", lastPoint);
|
|
188
|
+
// result.push( new)
|
|
189
|
+
const line = new Line(new Vertex(lastPoint), new Vertex(lastPoint));
|
|
190
|
+
if (isRelative) {
|
|
191
|
+
line.b.x += Number(data[1]);
|
|
192
|
+
// line.b.y += Number(data[2]);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
line.b.x = Number(data[1]);
|
|
196
|
+
// line.b.y = Number(data[2]);
|
|
197
|
+
}
|
|
198
|
+
result.push(line);
|
|
199
|
+
lastPoint.x = line.b.x;
|
|
200
|
+
// lastPoint.y = line.b.y;
|
|
201
|
+
lastControlPoint.x = line.b.x;
|
|
202
|
+
if (isNaN(firstPoint.y)) {
|
|
203
|
+
firstPoint.x = line.a.x;
|
|
204
|
+
firstPoint.y = line.a.y;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const _handleVerticalLineTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
208
|
+
// console.log("Handle VERTICALLINETO", data);
|
|
209
|
+
if (data.length < 2) {
|
|
210
|
+
throw "Unsufficient params for VERTICALLINETO";
|
|
211
|
+
}
|
|
212
|
+
// console.log("Y: ", Number(data[2]), "lastPoint", lastPoint);
|
|
213
|
+
// result.push( new)
|
|
214
|
+
const line = new Line(new Vertex(lastPoint), new Vertex(lastPoint));
|
|
215
|
+
if (isRelative) {
|
|
216
|
+
// line.b.x += Number(data[1]);
|
|
217
|
+
line.b.y += Number(data[1]);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
// line.b.x = Number(data[1]);
|
|
221
|
+
line.b.y = Number(data[1]);
|
|
222
|
+
}
|
|
223
|
+
result.push(line);
|
|
224
|
+
// lastPoint.x = line.b.x;
|
|
225
|
+
lastPoint.y = line.b.y;
|
|
226
|
+
lastControlPoint.y = line.b.y;
|
|
227
|
+
if (isNaN(firstPoint.y)) {
|
|
228
|
+
firstPoint.x = line.a.x;
|
|
229
|
+
firstPoint.y = line.a.y;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
// CurveTo: C|c x1 y1 x2 y2 x y
|
|
233
|
+
const _handleCubicBezierTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
234
|
+
// console.log("Handle CUBICBEZIERTO", data);
|
|
235
|
+
if (data.length < 7) {
|
|
236
|
+
throw "Unsufficient params for CUBICBEZIERTO";
|
|
237
|
+
}
|
|
238
|
+
// console.log("Y: ", Number(data[2]), "lastPoint", lastPoint);
|
|
239
|
+
// result.push( new)
|
|
240
|
+
const curve = new CubicBezierCurve(new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint));
|
|
241
|
+
if (isRelative) {
|
|
242
|
+
curve.startControlPoint.x += Number(data[1]);
|
|
243
|
+
curve.startControlPoint.y += Number(data[2]);
|
|
244
|
+
curve.endControlPoint.x += Number(data[3]);
|
|
245
|
+
curve.endControlPoint.y += Number(data[4]);
|
|
246
|
+
curve.endPoint.x += Number(data[5]);
|
|
247
|
+
curve.endPoint.y += Number(data[6]);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
curve.startControlPoint.x = Number(data[1]);
|
|
251
|
+
curve.startControlPoint.y = Number(data[2]);
|
|
252
|
+
curve.endControlPoint.x = Number(data[3]);
|
|
253
|
+
curve.endControlPoint.y = Number(data[4]);
|
|
254
|
+
curve.endPoint.x = Number(data[5]);
|
|
255
|
+
curve.endPoint.y = Number(data[6]);
|
|
256
|
+
}
|
|
257
|
+
result.push(curve);
|
|
258
|
+
lastPoint.x = curve.endPoint.x;
|
|
259
|
+
lastPoint.y = curve.endPoint.y;
|
|
260
|
+
lastControlPoint.x = curve.endControlPoint.x;
|
|
261
|
+
lastControlPoint.y = curve.endControlPoint.y;
|
|
262
|
+
if (isNaN(firstPoint.x)) {
|
|
263
|
+
firstPoint.x = curve.startPoint.x;
|
|
264
|
+
firstPoint.y = curve.startPoint.y;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
// QuadraticCurveTo: Q|q x1 y1 x y
|
|
268
|
+
const _handleQuadraticCurveTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
269
|
+
// console.log("Handle QUADRATICBEZIERTO", data);
|
|
270
|
+
if (data.length < 5) {
|
|
271
|
+
throw "Unsufficient params for QUADRATICBEZIERTO";
|
|
272
|
+
}
|
|
273
|
+
// console.log("Y: ", Number(data[2]), "lastPoint", lastPoint);
|
|
274
|
+
// result.push( new)
|
|
275
|
+
const curve = new CubicBezierCurve(new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint));
|
|
276
|
+
if (isRelative) {
|
|
277
|
+
curve.startControlPoint.x += curve.startPoint.x + (Number(data[1]) - curve.startControlPoint.x); // * 0.666;
|
|
278
|
+
curve.startControlPoint.y += curve.startPoint.y + (Number(data[2]) - curve.startControlPoint.y); // * 0.666;
|
|
279
|
+
curve.endPoint.x += Number(data[3]);
|
|
280
|
+
curve.endPoint.y += Number(data[4]);
|
|
281
|
+
curve.endControlPoint.x = curve.startControlPoint.x;
|
|
282
|
+
curve.endControlPoint.y = curve.startControlPoint.y;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
curve.startControlPoint.x = curve.startPoint.x + (Number(data[1]) - curve.startControlPoint.x); // * 0.666;
|
|
286
|
+
curve.startControlPoint.y = curve.startPoint.y + (Number(data[2]) - curve.startControlPoint.y); // * 0.666;
|
|
287
|
+
curve.endPoint.x = Number(data[3]);
|
|
288
|
+
curve.endPoint.y = Number(data[4]);
|
|
289
|
+
curve.endControlPoint.x = curve.startControlPoint.x;
|
|
290
|
+
curve.endControlPoint.y = curve.startControlPoint.y;
|
|
291
|
+
}
|
|
292
|
+
// var lastQuadraticControlPoint = { x: Number(data[1]), y: Number(data[2]) };
|
|
293
|
+
const lastQuadraticControlPoint = { x: curve.endControlPoint.x, y: curve.endControlPoint.y };
|
|
294
|
+
// Convert quadratic curve to cubic curve
|
|
295
|
+
curve.startControlPoint.x = curve.startPoint.x + (curve.startControlPoint.x - curve.startPoint.x) * 0.666;
|
|
296
|
+
curve.startControlPoint.y = curve.startPoint.y + (curve.startControlPoint.y - curve.startPoint.y) * 0.666;
|
|
297
|
+
curve.endControlPoint.x = curve.endPoint.x + (curve.endControlPoint.x - curve.endPoint.x) * 0.666;
|
|
298
|
+
curve.endControlPoint.y = curve.endPoint.y + (curve.endControlPoint.y - curve.endPoint.y) * 0.666;
|
|
299
|
+
result.push(curve);
|
|
300
|
+
lastPoint.x = curve.endPoint.x;
|
|
301
|
+
lastPoint.y = curve.endPoint.y;
|
|
302
|
+
lastControlPoint.x = curve.endControlPoint.x;
|
|
303
|
+
lastControlPoint.y = curve.endControlPoint.y;
|
|
304
|
+
if (isNaN(firstPoint.x)) {
|
|
305
|
+
firstPoint.x = curve.startPoint.x;
|
|
306
|
+
firstPoint.y = curve.startPoint.y;
|
|
307
|
+
}
|
|
308
|
+
// 'T' or 't' command may follow
|
|
309
|
+
if (data.length >= 8) {
|
|
310
|
+
// TODO: think about this type cast!
|
|
311
|
+
const subData = data.slice(5);
|
|
312
|
+
// var lastQuadraticControlPoint = { x: Number(data[1]), y: Number(data[2]) };
|
|
313
|
+
if (subData[0] === "T") {
|
|
314
|
+
// _handleShorthandQuadraticCurveTo(subData, false, firstPoint, lastPoint, lastControlPoint, result);
|
|
315
|
+
_handleShorthandQuadraticCurveTo(subData, false, firstPoint, lastPoint, lastQuadraticControlPoint, result);
|
|
316
|
+
}
|
|
317
|
+
else if (subData[0] === "t") {
|
|
318
|
+
// _handleShorthandQuadraticCurveTo(subData, true, firstPoint, lastPoint, lastControlPoint, result);
|
|
319
|
+
_handleShorthandQuadraticCurveTo(subData, true, firstPoint, lastPoint, lastQuadraticControlPoint, result);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
// This is a helper function and works only in combination with Quadratic Bézier Curves
|
|
324
|
+
// T|t x y
|
|
325
|
+
const _handleShorthandQuadraticCurveTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
326
|
+
// console.log("Handle SHORTHANDQUADRATICCURVETO", data);
|
|
327
|
+
if (data.length < 3) {
|
|
328
|
+
throw "Unsufficient params for SHORTHANDQUADRATICCURVETO";
|
|
329
|
+
}
|
|
330
|
+
const curve = new CubicBezierCurve(new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint));
|
|
331
|
+
if (isRelative) {
|
|
332
|
+
curve.endPoint.x += Number(data[1]);
|
|
333
|
+
curve.endPoint.y += Number(data[2]);
|
|
334
|
+
curve.startControlPoint.x += curve.startPoint.x - (lastControlPoint.x - lastPoint.x);
|
|
335
|
+
curve.startControlPoint.y += curve.startPoint.y - (lastControlPoint.y - lastPoint.y);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
curve.endPoint.x = Number(data[1]);
|
|
339
|
+
curve.endPoint.y = Number(data[2]);
|
|
340
|
+
curve.startControlPoint.x = curve.startPoint.x - (lastControlPoint.x - lastPoint.x);
|
|
341
|
+
curve.startControlPoint.y = curve.startPoint.y - (lastControlPoint.y - lastPoint.y);
|
|
342
|
+
}
|
|
343
|
+
// First handle as symmetrical cubic curve
|
|
344
|
+
curve.endControlPoint.x = curve.startControlPoint.x;
|
|
345
|
+
curve.endControlPoint.y = curve.startControlPoint.y;
|
|
346
|
+
// Convert quadratic curve to cubic curve
|
|
347
|
+
curve.startControlPoint.x = curve.startPoint.x + (curve.startControlPoint.x - curve.startPoint.x) * 0.666;
|
|
348
|
+
curve.startControlPoint.y = curve.startPoint.y + (curve.startControlPoint.y - curve.startPoint.y) * 0.666;
|
|
349
|
+
curve.endControlPoint.x = curve.endPoint.x + (curve.endControlPoint.x - curve.endPoint.x) * 0.666;
|
|
350
|
+
curve.endControlPoint.y = curve.endPoint.y + (curve.endControlPoint.y - curve.endPoint.y) * 0.666;
|
|
351
|
+
// console.log("ADDING T CURVE", curve);
|
|
352
|
+
result.push(curve);
|
|
353
|
+
lastPoint.x = curve.endPoint.x;
|
|
354
|
+
lastPoint.y = curve.endPoint.y;
|
|
355
|
+
lastControlPoint.x = curve.endControlPoint.x;
|
|
356
|
+
lastControlPoint.y = curve.endControlPoint.y;
|
|
357
|
+
if (isNaN(firstPoint.x)) {
|
|
358
|
+
firstPoint.x = curve.startPoint.x;
|
|
359
|
+
firstPoint.y = curve.startPoint.y;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
// The S|s x2 y2 x y
|
|
363
|
+
const _handleShorthandCubicCurveTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
364
|
+
// console.log("Handle SHORTHANDCUBICBEZIERTO", data);
|
|
365
|
+
if (data.length < 5) {
|
|
366
|
+
throw "Unsufficient params for SHORTHANDCUBICBEZIERTO";
|
|
367
|
+
}
|
|
368
|
+
const curve = new CubicBezierCurve(new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint), new Vertex(lastPoint));
|
|
369
|
+
if (isRelative) {
|
|
370
|
+
curve.startControlPoint.x = lastPoint.x - (lastControlPoint.x - lastPoint.x);
|
|
371
|
+
curve.startControlPoint.y = lastPoint.y - (lastControlPoint.y - lastPoint.y);
|
|
372
|
+
curve.endControlPoint.x += Number(data[1]);
|
|
373
|
+
curve.endControlPoint.y += Number(data[2]);
|
|
374
|
+
curve.endPoint.x += Number(data[3]);
|
|
375
|
+
curve.endPoint.y += Number(data[4]);
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
curve.startControlPoint.x = lastPoint.x - (lastControlPoint.x - lastPoint.x);
|
|
379
|
+
curve.startControlPoint.y = lastPoint.y - (lastControlPoint.y - lastPoint.y);
|
|
380
|
+
curve.endControlPoint.x = Number(data[1]);
|
|
381
|
+
curve.endControlPoint.y = Number(data[2]);
|
|
382
|
+
curve.endPoint.x = Number(data[3]);
|
|
383
|
+
curve.endPoint.y = Number(data[4]);
|
|
384
|
+
}
|
|
385
|
+
result.push(curve);
|
|
386
|
+
lastPoint.x = curve.endPoint.x;
|
|
387
|
+
lastPoint.y = curve.endPoint.y;
|
|
388
|
+
lastControlPoint.x = curve.endControlPoint.x;
|
|
389
|
+
lastControlPoint.y = curve.endControlPoint.y;
|
|
390
|
+
if (isNaN(firstPoint.x)) {
|
|
391
|
+
firstPoint.x = curve.startPoint.x;
|
|
392
|
+
firstPoint.y = curve.startPoint.y;
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
// EllipticalArcTo: A|a rx ry x-axis-rotation large-arc-flag sweep-flag x y
|
|
396
|
+
const _handleArcTo = (data, isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
397
|
+
// console.log("Handle ARCTO", data);
|
|
398
|
+
if (data.length < 8) {
|
|
399
|
+
throw "Unsufficient params for ARCTO";
|
|
400
|
+
}
|
|
401
|
+
const arcEndPoint = { x: Number(data[6]), y: Number(data[7]) };
|
|
402
|
+
if (isRelative) {
|
|
403
|
+
arcEndPoint.x += lastPoint.x;
|
|
404
|
+
arcEndPoint.y += lastPoint.y;
|
|
405
|
+
}
|
|
406
|
+
// console.log(
|
|
407
|
+
// "lastPoint.x",
|
|
408
|
+
// lastPoint.x, // x1
|
|
409
|
+
// "lastPoint.y",
|
|
410
|
+
// lastPoint.y, // y1
|
|
411
|
+
// "data[1]",
|
|
412
|
+
// Number(data[1]), // rx
|
|
413
|
+
// "data[2]",
|
|
414
|
+
// Number(data[2]), // ry
|
|
415
|
+
// "data[3]",
|
|
416
|
+
// Number(data[3]), // phi: number,
|
|
417
|
+
// "data[4]",
|
|
418
|
+
// Boolean(data[4]), // fa: boolean,
|
|
419
|
+
// "data[5]",
|
|
420
|
+
// Boolean(data[5]), // fs: boolean,
|
|
421
|
+
// "data[6]",
|
|
422
|
+
// arcEndPoint.x, // Number(data[6]), // x2: number,
|
|
423
|
+
// "data[7]",
|
|
424
|
+
// arcEndPoint.y // Number(data[7]) // y2: number
|
|
425
|
+
// );
|
|
426
|
+
// A 5 4 0 1 1 -10 -5
|
|
427
|
+
// TODO: respect relative/absolute here
|
|
428
|
+
const ellipseSector = VEllipseSector.ellipseSectorUtils.endpointToCenterParameters(lastPoint.x, lastPoint.y, Number(data[1]), Number(data[2]), Number(data[3]) * DEG_TO_RAD, Boolean(data[4]), Boolean(data[5]), arcEndPoint.x, arcEndPoint.y // Number(data[7]) // y2: number
|
|
429
|
+
);
|
|
430
|
+
// console.log("ellipseSector", ellipseSector);
|
|
431
|
+
const curves = ellipseSector.toCubicBezier(4); // 4 segments already seems to be a good approximation
|
|
432
|
+
for (var i = 0; i < curves.length; i++) {
|
|
433
|
+
result.push(curves[i]); // Destruct!
|
|
434
|
+
}
|
|
435
|
+
// result.push(ellipseSector.ellipse);
|
|
436
|
+
if (curves.length > 0) {
|
|
437
|
+
// console.log("curves", curves);
|
|
438
|
+
const lastCurve = curves[curves.length - 1];
|
|
439
|
+
lastPoint.x = lastCurve.endPoint.x;
|
|
440
|
+
lastPoint.y = lastCurve.endPoint.y;
|
|
441
|
+
lastControlPoint.x = lastCurve.endControlPoint.x;
|
|
442
|
+
lastControlPoint.y = lastCurve.endControlPoint.y;
|
|
443
|
+
if (isNaN(firstPoint.x)) {
|
|
444
|
+
firstPoint.x = curves[0].startPoint.x;
|
|
445
|
+
firstPoint.y = curves[0].startPoint.y;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
// TODO: track first/last/control point
|
|
449
|
+
};
|
|
450
|
+
const _handleClosePath = (_data, _isRelative, firstPoint, lastPoint, lastControlPoint, result) => {
|
|
451
|
+
// console.log("Handle CLOSEPATH", "lastPoint", lastPoint, "firstPoint", firstPoint);
|
|
452
|
+
const line = new Line(new Vertex(lastPoint), new Vertex(firstPoint));
|
|
453
|
+
result.push(line);
|
|
454
|
+
lastPoint.x = line.b.x;
|
|
455
|
+
lastPoint.y = line.b.y;
|
|
456
|
+
lastControlPoint.x = line.b.x;
|
|
457
|
+
lastControlPoint.y = line.b.y;
|
|
458
|
+
};
|
|
459
|
+
//# sourceMappingURL=parseSVGPathData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseSVGPathData.js","sourceRoot":"","sources":["../../../../ts/utils/parsers/svg/parseSVGPathData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;IAYI;AAEJ,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAetD,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAyC,EAAE;IAC5F,MAAM,YAAY,GAAiC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAEhF,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,IAAI,CAAC;KACb;IAED,sBAAsB;IACtB,MAAM,MAAM,GAAmC,EAAE,CAAC;IAElD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,UAAU,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IACrC,MAAM,gBAAgB,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IAE5C,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE;QAC9B,8DAA8D;QAC9D,MAAM,IAAI,GAA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0B,EAC1B,WAAoB,EACpB,UAAoB,EACpB,SAAmB,EACnB,gBAA0B,EAC1B,MAAsC,EACtC,EAAE;IACF,uFAAuF;IACvF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACrE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElB,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split SVG path data `d` strings.
|
|
3
|
+
*
|
|
4
|
+
* As this helper function does not detect all possible path data strings it should cover the most daily use-cases.
|
|
5
|
+
*
|
|
6
|
+
* For more insight see
|
|
7
|
+
* https://www.w3.org/TR/SVG/paths.html
|
|
8
|
+
*
|
|
9
|
+
* @author Ikaros Kappler
|
|
10
|
+
* @date 2022-11-22
|
|
11
|
+
* @modified 2022-12-21 Ported to Typescript
|
|
12
|
+
* @version 0.0.1-alpha
|
|
13
|
+
*/
|
|
14
|
+
import { SVGPathCommand } from "./types";
|
|
15
|
+
/**
|
|
16
|
+
* @name splitSVGPathData
|
|
17
|
+
* @static
|
|
18
|
+
* @param {string} dataString - The SVG path data to split. This should be some string
|
|
19
|
+
**/
|
|
20
|
+
export declare const splitSVGPathData: (dataString: string) => Array<SVGPathCommand> | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split SVG path data `d` strings.
|
|
3
|
+
*
|
|
4
|
+
* As this helper function does not detect all possible path data strings it should cover the most daily use-cases.
|
|
5
|
+
*
|
|
6
|
+
* For more insight see
|
|
7
|
+
* https://www.w3.org/TR/SVG/paths.html
|
|
8
|
+
*
|
|
9
|
+
* @author Ikaros Kappler
|
|
10
|
+
* @date 2022-11-22
|
|
11
|
+
* @modified 2022-12-21 Ported to Typescript
|
|
12
|
+
* @version 0.0.1-alpha
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @name splitSVGPathData
|
|
16
|
+
* @static
|
|
17
|
+
* @param {string} dataString - The SVG path data to split. This should be some string
|
|
18
|
+
**/
|
|
19
|
+
export const splitSVGPathData = (dataString) => {
|
|
20
|
+
// Source
|
|
21
|
+
// https://javascript.plainenglish.io/june-3-parsing-and-validating-svg-paths-with-regex-7bd0e245115
|
|
22
|
+
const validCommand = /([ml](\s?-?((\d+(\.\d+)?)|(\.\d+)))[,\s]?(-?((\d+(\.\d+)?)|(\.\d+))))|([hv](\s?-?((\d+(\.\d+)?)|(\.\d+))))|(c(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){5})|(q(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){3}(\s?t?(\s?-?((\d+(\.\d+)?)|(\.\d+)))[,\s]?(-?((\d+(\.\d+)?)|(\.\d+))))*)|(a(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){2}[,\s]?[01][,\s]+[01][,\s]+([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){2})|(s(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){3})|z/gi;
|
|
23
|
+
const dataElements = dataString.match(validCommand);
|
|
24
|
+
// console.log("Splitted: ", dataElements);
|
|
25
|
+
if (!dataElements) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const result = [];
|
|
29
|
+
var i = 0;
|
|
30
|
+
while (i < dataElements.length) {
|
|
31
|
+
const token = dataElements[i];
|
|
32
|
+
// Ctwheels comment was really useful here
|
|
33
|
+
// https://stackoverflow.com/questions/47801455/what-is-the-regex-that-properly-splits-svg-d-attributes-into-tokens
|
|
34
|
+
const dataRaw = token.match(/-?(?:\d*\.)?\d+|[a-z]/gi);
|
|
35
|
+
if (dataRaw) {
|
|
36
|
+
result.push(dataRaw);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// throw Error?
|
|
40
|
+
}
|
|
41
|
+
i++;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}; // END splitSVGPathData
|
|
45
|
+
//# sourceMappingURL=splitSVGPathData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitSVGPathData.js","sourceRoot":"","sources":["../../../../ts/utils/parsers/svg/splitSVGPathData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;IAII;AACJ,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAgC,EAAE;IACnF,SAAS;IACT,uGAAuG;IACvG,MAAM,YAAY,GAChB,uhBAAuhB,CAAC;IAE1hB,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACpD,2CAA2C;IAC3C,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE;QAC9B,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9B,0CAA0C;QAC1C,sHAAsH;QACtH,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACvD,IAAI,OAAO,EAAE;YACX,MAAM,CAAC,IAAI,CAAC,OAAyB,CAAC,CAAC;SACxC;aAAM;YACL,eAAe;SAChB;QACD,CAAC,EAAE,CAAC;KACL;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC,uBAAuB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defining some basic SVG command types.
|
|
3
|
+
*
|
|
4
|
+
* As these types do not define all very possible path data strings they should cover the most daily use-cases.
|
|
5
|
+
*
|
|
6
|
+
* For more insight see
|
|
7
|
+
* https://www.w3.org/TR/SVG/paths.html
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* @author Ikaros Kappler
|
|
11
|
+
* @date 2022-12-21 (winter solstice night – yes the days & nights are dark and I have nothing else to do)
|
|
12
|
+
* @version 0.0.1-alpha
|
|
13
|
+
*/
|
|
14
|
+
export declare type NumericString = `${number}`;
|
|
15
|
+
export declare type BooleanString = "0" | "1" | `${boolean}`;
|
|
16
|
+
export declare type SVGPathMoveToCommand = ["M" | "m", NumericString, NumericString];
|
|
17
|
+
export declare type SVGPathLineToCommand = ["L" | "l", NumericString, NumericString];
|
|
18
|
+
export declare type SVGPathVerticalLineToCommand = ["V" | "v", NumericString];
|
|
19
|
+
export declare type SVGPathHorizontalLineToCommand = ["H" | "h", NumericString];
|
|
20
|
+
export declare type SVGPathQuadraticCurveToCommand = ["Q" | "q", NumericString, NumericString, NumericString, NumericString] | ["Q" | "q", NumericString, NumericString, NumericString, NumericString, "T" | "t", NumericString, NumericString];
|
|
21
|
+
export declare type SVGPathCubicCurveToCommand = [
|
|
22
|
+
"C" | "c",
|
|
23
|
+
NumericString,
|
|
24
|
+
NumericString,
|
|
25
|
+
NumericString,
|
|
26
|
+
NumericString,
|
|
27
|
+
NumericString,
|
|
28
|
+
NumericString
|
|
29
|
+
];
|
|
30
|
+
export declare type SVGPathShorthandCubicCurveToCommand = ["S" | "s", NumericString, NumericString, NumericString, NumericString];
|
|
31
|
+
export declare type SVGPathArcToCommand = [
|
|
32
|
+
"A" | "a",
|
|
33
|
+
NumericString,
|
|
34
|
+
NumericString,
|
|
35
|
+
NumericString,
|
|
36
|
+
BooleanString,
|
|
37
|
+
BooleanString,
|
|
38
|
+
NumericString,
|
|
39
|
+
NumericString
|
|
40
|
+
];
|
|
41
|
+
export declare type SVGPathCloseCommand = ["Z" | "z"];
|
|
42
|
+
export declare type SVGPathShorthandQuadraticCurveToCommand = ["T" | "t", NumericString, NumericString];
|
|
43
|
+
export declare type SVGPathCommand = SVGPathMoveToCommand | SVGPathLineToCommand | SVGPathVerticalLineToCommand | SVGPathHorizontalLineToCommand | SVGPathQuadraticCurveToCommand | SVGPathCubicCurveToCommand | SVGPathShorthandCubicCurveToCommand | SVGPathArcToCommand | SVGPathCloseCommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defining some basic SVG command types.
|
|
3
|
+
*
|
|
4
|
+
* As these types do not define all very possible path data strings they should cover the most daily use-cases.
|
|
5
|
+
*
|
|
6
|
+
* For more insight see
|
|
7
|
+
* https://www.w3.org/TR/SVG/paths.html
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* @author Ikaros Kappler
|
|
11
|
+
* @date 2022-12-21 (winter solstice night – yes the days & nights are dark and I have nothing else to do)
|
|
12
|
+
* @version 0.0.1-alpha
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../ts/utils/parsers/svg/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
package/src/ts/Bounds.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* @modified 2021-06-21 (mid-summer) Added `getCenter` method.
|
|
8
8
|
* @modified 2022-02-01 Added the `toString` function.
|
|
9
9
|
* @modified 2022-10-09 Added the `fromDimension` function.
|
|
10
|
-
* @
|
|
10
|
+
* @modified 2022-11-28 Added the `clone` method.
|
|
11
|
+
* @version 1.6.0
|
|
11
12
|
**/
|
|
12
13
|
|
|
13
14
|
import { Polygon } from "./Polygon";
|
|
@@ -114,17 +115,14 @@ export class Bounds implements IBounds, XYDimension {
|
|
|
114
115
|
/**
|
|
115
116
|
* Clone this bounds object (create a deep clone).
|
|
116
117
|
*
|
|
117
|
-
* Note: the returned format might change in the future, so please do not
|
|
118
|
-
* rely on the returned string format.
|
|
119
|
-
*
|
|
120
118
|
* @method clone
|
|
121
119
|
* @instance
|
|
122
120
|
* @memberof Bounds
|
|
123
|
-
* @returns {
|
|
121
|
+
* @returns {Bounds} Creates a deep clone of this bounds object.
|
|
124
122
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
clone() {
|
|
124
|
+
return new Bounds({ x: this.min.x, y: this.min.y }, { x: this.max.x, y: this.max.y });
|
|
125
|
+
}
|
|
128
126
|
|
|
129
127
|
/**
|
|
130
128
|
* Compute the minimal bounding box for a given set of vertices.
|