@remotion/svg-3d-engine 4.0.249

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.
@@ -0,0 +1,2694 @@
1
+ // src/matrix.ts
2
+ var stride = function({
3
+ v,
4
+ m,
5
+ width,
6
+ offset,
7
+ colStride
8
+ }) {
9
+ for (let i = 0;i < v.length; i++) {
10
+ m[i * width + (i * colStride + offset + width) % width] = v[i];
11
+ }
12
+ return m;
13
+ };
14
+ var identity4 = function() {
15
+ const n = 4;
16
+ let size = n * n;
17
+ const m = new Array(size);
18
+ while (size--) {
19
+ m[size] = size % (n + 1) === 0 ? 1 : 0;
20
+ }
21
+ return m;
22
+ };
23
+ var rotated = function(axisVec, radians) {
24
+ return rotatedUnitSinCos(normalize(axisVec), Math.sin(radians), Math.cos(radians));
25
+ };
26
+ var rotateX = (radians) => {
27
+ return rotated([1, 0, 0], radians);
28
+ };
29
+ var rotateY = (radians) => {
30
+ return rotated([0, 1, 0], radians);
31
+ };
32
+ var rotateZ = (radians) => {
33
+ return rotated([0, 0, 1], radians);
34
+ };
35
+ var multiplyMatrices = (matrix1, matrix2) => {
36
+ const result = new Array(16).fill(0);
37
+ for (let i = 0;i < 4; i++) {
38
+ for (let j = 0;j < 4; j++) {
39
+ for (let k = 0;k < 4; k++) {
40
+ result[i * 4 + j] += matrix1[i * 4 + k] * matrix2[k * 4 + j];
41
+ }
42
+ }
43
+ }
44
+ return result;
45
+ };
46
+ var reduceMatrices = (matrices) => {
47
+ return matrices.slice().reverse().reduce((acc, cur) => {
48
+ return multiplyMatrices(acc, cur);
49
+ }, identity4());
50
+ };
51
+ var makeMatrix3dTransform = function(matrix) {
52
+ return `matrix3d(${[
53
+ matrix[0],
54
+ matrix[4],
55
+ matrix[8],
56
+ matrix[12],
57
+ matrix[1],
58
+ matrix[5],
59
+ matrix[9],
60
+ matrix[13],
61
+ matrix[2],
62
+ matrix[6],
63
+ matrix[10],
64
+ matrix[14],
65
+ matrix[3],
66
+ matrix[7],
67
+ matrix[11],
68
+ matrix[15]
69
+ ].join(", ")}`;
70
+ };
71
+ var interpolate = (a, b, t) => {
72
+ return a + (b - a) * t;
73
+ };
74
+ var interpolateMatrix4d = (input, matrix1, matrix2) => {
75
+ return [
76
+ interpolate(matrix1[0], matrix2[0], input),
77
+ interpolate(matrix1[1], matrix2[1], input),
78
+ interpolate(matrix1[2], matrix2[2], input),
79
+ interpolate(matrix1[3], matrix2[3], input),
80
+ interpolate(matrix1[4], matrix2[4], input),
81
+ interpolate(matrix1[5], matrix2[5], input),
82
+ interpolate(matrix1[6], matrix2[6], input),
83
+ interpolate(matrix1[7], matrix2[7], input),
84
+ interpolate(matrix1[8], matrix2[8], input),
85
+ interpolate(matrix1[9], matrix2[9], input),
86
+ interpolate(matrix1[10], matrix2[10], input),
87
+ interpolate(matrix1[11], matrix2[11], input),
88
+ interpolate(matrix1[12], matrix2[12], input),
89
+ interpolate(matrix1[13], matrix2[13], input),
90
+ interpolate(matrix1[14], matrix2[14], input),
91
+ interpolate(matrix1[15], matrix2[15], input)
92
+ ];
93
+ };
94
+ var scaled = function(value) {
95
+ const vec = typeof value === "number" ? [value, value, value] : value;
96
+ return stride({ v: vec, m: identity4(), width: 4, offset: 0, colStride: 1 });
97
+ };
98
+ var rotatedUnitSinCos = function(axisVec, sinAngle, cosAngle) {
99
+ const x = axisVec[0];
100
+ const y = axisVec[1];
101
+ const z = axisVec[2];
102
+ const c = cosAngle;
103
+ const s = sinAngle;
104
+ const t = 1 - c;
105
+ return [
106
+ t * x * x + c,
107
+ t * x * y - s * z,
108
+ t * x * z + s * y,
109
+ 0,
110
+ t * x * y + s * z,
111
+ t * y * y + c,
112
+ t * y * z - s * x,
113
+ 0,
114
+ t * x * z - s * y,
115
+ t * y * z + s * x,
116
+ t * z * z + c,
117
+ 0,
118
+ 0,
119
+ 0,
120
+ 0,
121
+ 1
122
+ ];
123
+ };
124
+ var normalize = function(v) {
125
+ return mulScalar(v, 1 / vectorLength(v));
126
+ };
127
+ var vectorLength = function(v) {
128
+ return Math.sqrt(lengthSquared(v));
129
+ };
130
+ var lengthSquared = function(v) {
131
+ return dot(v, v);
132
+ };
133
+ var dot = function(a, b) {
134
+ if (a.length !== b.length) {
135
+ throw new Error(`Cannot perform dot product on arrays of different length (${a.length} vs ${b.length})`);
136
+ }
137
+ return a.map((v, i) => {
138
+ return v * b[i];
139
+ }).reduce((acc, cur) => {
140
+ return acc + cur;
141
+ });
142
+ };
143
+ var translated = function(vec) {
144
+ return stride({
145
+ v: vec,
146
+ m: identity4(),
147
+ width: 4,
148
+ offset: 3,
149
+ colStride: 0
150
+ });
151
+ };
152
+ var translateX = (x) => {
153
+ return translated([x, 0, 0]);
154
+ };
155
+ var translateY = (y) => {
156
+ return translated([0, y, 0]);
157
+ };
158
+ var translateZ = (z) => {
159
+ return translated([0, 0, z]);
160
+ };
161
+ var mulScalar = function(v, s) {
162
+ return v.map((i) => {
163
+ return i * s;
164
+ });
165
+ };
166
+ function multiplyMatrixAndSvgInstruction(matrix, point) {
167
+ if (point.type === "C") {
168
+ return {
169
+ type: "C",
170
+ cp1: multiplyMatrix(matrix, point.cp1),
171
+ cp2: multiplyMatrix(matrix, point.cp2),
172
+ point: multiplyMatrix(matrix, point.point)
173
+ };
174
+ }
175
+ if (point.type === "Q") {
176
+ return {
177
+ type: "Q",
178
+ cp: multiplyMatrix(matrix, point.cp),
179
+ point: multiplyMatrix(matrix, point.point)
180
+ };
181
+ }
182
+ if (point.type === "M") {
183
+ return {
184
+ type: "M",
185
+ point: multiplyMatrix(matrix, point.point)
186
+ };
187
+ }
188
+ if (point.type === "L") {
189
+ return {
190
+ type: "L",
191
+ point: multiplyMatrix(matrix, point.point)
192
+ };
193
+ }
194
+ if (point.type === "Z") {
195
+ return {
196
+ type: "Z",
197
+ point: multiplyMatrix(matrix, point.point)
198
+ };
199
+ }
200
+ throw new Error("Unknown instruction type: " + JSON.stringify(point));
201
+ }
202
+ var multiplyMatrix = (matrix, point) => {
203
+ if (matrix.length !== 16 || point.length !== 4) {
204
+ throw new Error("Invalid matrix or vector dimension");
205
+ }
206
+ const result = [0, 0, 0, 0];
207
+ for (let i = 0;i < 4; i++) {
208
+ for (let j = 0;j < 4; j++) {
209
+ result[i] += matrix[i * 4 + j] * point[j];
210
+ }
211
+ }
212
+ return result;
213
+ };
214
+ // src/3d-svg.ts
215
+ var serializeThreeDReducedInstruction = (instruction) => {
216
+ if (instruction.type === "M") {
217
+ return `M ${instruction.point[0]} ${instruction.point[1]}`;
218
+ }
219
+ if (instruction.type === "L") {
220
+ return `L ${instruction.point[0]} ${instruction.point[1]}`;
221
+ }
222
+ if (instruction.type === "C") {
223
+ return `C ${instruction.cp1[0]} ${instruction.cp1[1]} ${instruction.cp2[0]} ${instruction.cp2[1]} ${instruction.point[0]} ${instruction.point[1]}`;
224
+ }
225
+ if (instruction.type === "Q") {
226
+ return `Q ${instruction.cp[0]} ${instruction.cp[1]} ${instruction.point[0]} ${instruction.point[1]}`;
227
+ }
228
+ if (instruction.type === "Z") {
229
+ return "Z";
230
+ }
231
+ throw new Error("Unknown instruction type");
232
+ };
233
+ var threeDIntoSvgPath = (instructions) => instructions.map((instruction) => serializeThreeDReducedInstruction(instruction)).join(" ");
234
+ // src/make-id.ts
235
+ var makeId = () => {
236
+ return Math.random().toString().replace(".", "");
237
+ };
238
+
239
+ // ../paths/dist/esm/index.mjs
240
+ var cutLInstruction = ({
241
+ instruction,
242
+ lastPoint,
243
+ progress
244
+ }) => {
245
+ const x = lastPoint.x + (instruction.x - lastPoint.x) * progress;
246
+ const y = lastPoint.y + (instruction.y - lastPoint.y) * progress;
247
+ return {
248
+ type: "L",
249
+ x,
250
+ y
251
+ };
252
+ };
253
+ function interpolatePoint(pA, pB, factor) {
254
+ return {
255
+ x: pA.x + (pB.x - pA.x) * factor,
256
+ y: pA.y + (pB.y - pA.y) * factor
257
+ };
258
+ }
259
+ function cutCInstruction({
260
+ progress,
261
+ lastPoint,
262
+ instruction
263
+ }) {
264
+ const u = progress;
265
+ const p0 = { x: lastPoint.x, y: lastPoint.y };
266
+ const p1 = { x: instruction.cp1x, y: instruction.cp1y };
267
+ const p2 = { x: instruction.cp2x, y: instruction.cp2y };
268
+ const p3 = { x: instruction.x, y: instruction.y };
269
+ const p01 = interpolatePoint(p0, p1, u);
270
+ const p12 = interpolatePoint(p1, p2, u);
271
+ const p23 = interpolatePoint(p2, p3, u);
272
+ const p012 = interpolatePoint(p01, p12, u);
273
+ const p123 = interpolatePoint(p12, p23, u);
274
+ const p0123 = interpolatePoint(p012, p123, u);
275
+ return {
276
+ type: "C",
277
+ cp1x: p01.x,
278
+ cp1y: p01.y,
279
+ cp2x: p012.x,
280
+ cp2y: p012.y,
281
+ x: p0123.x,
282
+ y: p0123.y
283
+ };
284
+ }
285
+ var cutInstruction = ({
286
+ instruction,
287
+ lastPoint,
288
+ progress
289
+ }) => {
290
+ if (instruction.type === "M") {
291
+ return instruction;
292
+ }
293
+ if (instruction.type === "L") {
294
+ return cutLInstruction({ instruction, lastPoint, progress });
295
+ }
296
+ if (instruction.type === "C") {
297
+ return cutCInstruction({ instruction, lastPoint, progress });
298
+ }
299
+ if (instruction.type === "Z") {
300
+ return instruction;
301
+ }
302
+ throw new TypeError(`${instruction.type} is not supported.`);
303
+ };
304
+ var tValues = [
305
+ [],
306
+ [],
307
+ [
308
+ -0.5773502691896257,
309
+ 0.5773502691896257
310
+ ],
311
+ [
312
+ 0,
313
+ -0.7745966692414834,
314
+ 0.7745966692414834
315
+ ],
316
+ [
317
+ -0.33998104358485626,
318
+ 0.33998104358485626,
319
+ -0.8611363115940526,
320
+ 0.8611363115940526
321
+ ],
322
+ [
323
+ 0,
324
+ -0.5384693101056831,
325
+ 0.5384693101056831,
326
+ -0.906179845938664,
327
+ 0.906179845938664
328
+ ],
329
+ [
330
+ 0.6612093864662645,
331
+ -0.6612093864662645,
332
+ -0.2386191860831969,
333
+ 0.2386191860831969,
334
+ -0.932469514203152,
335
+ 0.932469514203152
336
+ ],
337
+ [
338
+ 0,
339
+ 0.4058451513773972,
340
+ -0.4058451513773972,
341
+ -0.7415311855993945,
342
+ 0.7415311855993945,
343
+ -0.9491079123427585,
344
+ 0.9491079123427585
345
+ ],
346
+ [
347
+ -0.1834346424956498,
348
+ 0.1834346424956498,
349
+ -0.525532409916329,
350
+ 0.525532409916329,
351
+ -0.7966664774136267,
352
+ 0.7966664774136267,
353
+ -0.9602898564975363,
354
+ 0.9602898564975363
355
+ ],
356
+ [
357
+ 0,
358
+ -0.8360311073266358,
359
+ 0.8360311073266358,
360
+ -0.9681602395076261,
361
+ 0.9681602395076261,
362
+ -0.3242534234038089,
363
+ 0.3242534234038089,
364
+ -0.6133714327005904,
365
+ 0.6133714327005904
366
+ ],
367
+ [
368
+ -0.14887433898163122,
369
+ 0.14887433898163122,
370
+ -0.4333953941292472,
371
+ 0.4333953941292472,
372
+ -0.6794095682990244,
373
+ 0.6794095682990244,
374
+ -0.8650633666889845,
375
+ 0.8650633666889845,
376
+ -0.9739065285171717,
377
+ 0.9739065285171717
378
+ ],
379
+ [
380
+ 0,
381
+ -0.26954315595234496,
382
+ 0.26954315595234496,
383
+ -0.5190961292068118,
384
+ 0.5190961292068118,
385
+ -0.7301520055740494,
386
+ 0.7301520055740494,
387
+ -0.8870625997680953,
388
+ 0.8870625997680953,
389
+ -0.978228658146057,
390
+ 0.978228658146057
391
+ ],
392
+ [
393
+ -0.1252334085114689,
394
+ 0.1252334085114689,
395
+ -0.3678314989981802,
396
+ 0.3678314989981802,
397
+ -0.5873179542866175,
398
+ 0.5873179542866175,
399
+ -0.7699026741943047,
400
+ 0.7699026741943047,
401
+ -0.9041172563704749,
402
+ 0.9041172563704749,
403
+ -0.9815606342467192,
404
+ 0.9815606342467192
405
+ ],
406
+ [
407
+ 0,
408
+ -0.2304583159551348,
409
+ 0.2304583159551348,
410
+ -0.44849275103644687,
411
+ 0.44849275103644687,
412
+ -0.6423493394403402,
413
+ 0.6423493394403402,
414
+ -0.8015780907333099,
415
+ 0.8015780907333099,
416
+ -0.9175983992229779,
417
+ 0.9175983992229779,
418
+ -0.9841830547185881,
419
+ 0.9841830547185881
420
+ ],
421
+ [
422
+ -0.10805494870734367,
423
+ 0.10805494870734367,
424
+ -0.31911236892788974,
425
+ 0.31911236892788974,
426
+ -0.5152486363581541,
427
+ 0.5152486363581541,
428
+ -0.6872929048116855,
429
+ 0.6872929048116855,
430
+ -0.827201315069765,
431
+ 0.827201315069765,
432
+ -0.9284348836635735,
433
+ 0.9284348836635735,
434
+ -0.9862838086968123,
435
+ 0.9862838086968123
436
+ ],
437
+ [
438
+ 0,
439
+ -0.20119409399743451,
440
+ 0.20119409399743451,
441
+ -0.3941513470775634,
442
+ 0.3941513470775634,
443
+ -0.5709721726085388,
444
+ 0.5709721726085388,
445
+ -0.7244177313601701,
446
+ 0.7244177313601701,
447
+ -0.8482065834104272,
448
+ 0.8482065834104272,
449
+ -0.937273392400706,
450
+ 0.937273392400706,
451
+ -0.9879925180204854,
452
+ 0.9879925180204854
453
+ ],
454
+ [
455
+ -0.09501250983763744,
456
+ 0.09501250983763744,
457
+ -0.2816035507792589,
458
+ 0.2816035507792589,
459
+ -0.45801677765722737,
460
+ 0.45801677765722737,
461
+ -0.6178762444026438,
462
+ 0.6178762444026438,
463
+ -0.755404408355003,
464
+ 0.755404408355003,
465
+ -0.8656312023878318,
466
+ 0.8656312023878318,
467
+ -0.9445750230732326,
468
+ 0.9445750230732326,
469
+ -0.9894009349916499,
470
+ 0.9894009349916499
471
+ ],
472
+ [
473
+ 0,
474
+ -0.17848418149584785,
475
+ 0.17848418149584785,
476
+ -0.3512317634538763,
477
+ 0.3512317634538763,
478
+ -0.5126905370864769,
479
+ 0.5126905370864769,
480
+ -0.6576711592166907,
481
+ 0.6576711592166907,
482
+ -0.7815140038968014,
483
+ 0.7815140038968014,
484
+ -0.8802391537269859,
485
+ 0.8802391537269859,
486
+ -0.9506755217687678,
487
+ 0.9506755217687678,
488
+ -0.9905754753144174,
489
+ 0.9905754753144174
490
+ ],
491
+ [
492
+ -0.0847750130417353,
493
+ 0.0847750130417353,
494
+ -0.2518862256915055,
495
+ 0.2518862256915055,
496
+ -0.41175116146284263,
497
+ 0.41175116146284263,
498
+ -0.5597708310739475,
499
+ 0.5597708310739475,
500
+ -0.6916870430603532,
501
+ 0.6916870430603532,
502
+ -0.8037049589725231,
503
+ 0.8037049589725231,
504
+ -0.8926024664975557,
505
+ 0.8926024664975557,
506
+ -0.9558239495713977,
507
+ 0.9558239495713977,
508
+ -0.9915651684209309,
509
+ 0.9915651684209309
510
+ ],
511
+ [
512
+ 0,
513
+ -0.16035864564022537,
514
+ 0.16035864564022537,
515
+ -0.31656409996362983,
516
+ 0.31656409996362983,
517
+ -0.46457074137596094,
518
+ 0.46457074137596094,
519
+ -0.600545304661681,
520
+ 0.600545304661681,
521
+ -0.7209661773352294,
522
+ 0.7209661773352294,
523
+ -0.8227146565371428,
524
+ 0.8227146565371428,
525
+ -0.9031559036148179,
526
+ 0.9031559036148179,
527
+ -0.96020815213483,
528
+ 0.96020815213483,
529
+ -0.9924068438435844,
530
+ 0.9924068438435844
531
+ ],
532
+ [
533
+ -0.07652652113349734,
534
+ 0.07652652113349734,
535
+ -0.22778585114164507,
536
+ 0.22778585114164507,
537
+ -0.37370608871541955,
538
+ 0.37370608871541955,
539
+ -0.5108670019508271,
540
+ 0.5108670019508271,
541
+ -0.636053680726515,
542
+ 0.636053680726515,
543
+ -0.7463319064601508,
544
+ 0.7463319064601508,
545
+ -0.8391169718222188,
546
+ 0.8391169718222188,
547
+ -0.912234428251326,
548
+ 0.912234428251326,
549
+ -0.9639719272779138,
550
+ 0.9639719272779138,
551
+ -0.9931285991850949,
552
+ 0.9931285991850949
553
+ ],
554
+ [
555
+ 0,
556
+ -0.1455618541608951,
557
+ 0.1455618541608951,
558
+ -0.2880213168024011,
559
+ 0.2880213168024011,
560
+ -0.4243421202074388,
561
+ 0.4243421202074388,
562
+ -0.5516188358872198,
563
+ 0.5516188358872198,
564
+ -0.6671388041974123,
565
+ 0.6671388041974123,
566
+ -0.7684399634756779,
567
+ 0.7684399634756779,
568
+ -0.8533633645833173,
569
+ 0.8533633645833173,
570
+ -0.9200993341504008,
571
+ 0.9200993341504008,
572
+ -0.9672268385663063,
573
+ 0.9672268385663063,
574
+ -0.9937521706203895,
575
+ 0.9937521706203895
576
+ ],
577
+ [
578
+ -0.06973927331972223,
579
+ 0.06973927331972223,
580
+ -0.20786042668822127,
581
+ 0.20786042668822127,
582
+ -0.34193582089208424,
583
+ 0.34193582089208424,
584
+ -0.469355837986757,
585
+ 0.469355837986757,
586
+ -0.5876404035069116,
587
+ 0.5876404035069116,
588
+ -0.6944872631866827,
589
+ 0.6944872631866827,
590
+ -0.7878168059792081,
591
+ 0.7878168059792081,
592
+ -0.8658125777203002,
593
+ 0.8658125777203002,
594
+ -0.926956772187174,
595
+ 0.926956772187174,
596
+ -0.9700604978354287,
597
+ 0.9700604978354287,
598
+ -0.9942945854823992,
599
+ 0.9942945854823992
600
+ ],
601
+ [
602
+ 0,
603
+ -0.1332568242984661,
604
+ 0.1332568242984661,
605
+ -0.26413568097034495,
606
+ 0.26413568097034495,
607
+ -0.3903010380302908,
608
+ 0.3903010380302908,
609
+ -0.5095014778460075,
610
+ 0.5095014778460075,
611
+ -0.6196098757636461,
612
+ 0.6196098757636461,
613
+ -0.7186613631319502,
614
+ 0.7186613631319502,
615
+ -0.8048884016188399,
616
+ 0.8048884016188399,
617
+ -0.8767523582704416,
618
+ 0.8767523582704416,
619
+ -0.9329710868260161,
620
+ 0.9329710868260161,
621
+ -0.9725424712181152,
622
+ 0.9725424712181152,
623
+ -0.9947693349975522,
624
+ 0.9947693349975522
625
+ ],
626
+ [
627
+ -0.06405689286260563,
628
+ 0.06405689286260563,
629
+ -0.1911188674736163,
630
+ 0.1911188674736163,
631
+ -0.3150426796961634,
632
+ 0.3150426796961634,
633
+ -0.4337935076260451,
634
+ 0.4337935076260451,
635
+ -0.5454214713888396,
636
+ 0.5454214713888396,
637
+ -0.6480936519369755,
638
+ 0.6480936519369755,
639
+ -0.7401241915785544,
640
+ 0.7401241915785544,
641
+ -0.820001985973903,
642
+ 0.820001985973903,
643
+ -0.8864155270044011,
644
+ 0.8864155270044011,
645
+ -0.9382745520027328,
646
+ 0.9382745520027328,
647
+ -0.9747285559713095,
648
+ 0.9747285559713095,
649
+ -0.9951872199970213,
650
+ 0.9951872199970213
651
+ ]
652
+ ];
653
+ var cValues = [
654
+ [],
655
+ [],
656
+ [1, 1],
657
+ [
658
+ 0.8888888888888888,
659
+ 0.5555555555555556,
660
+ 0.5555555555555556
661
+ ],
662
+ [
663
+ 0.6521451548625461,
664
+ 0.6521451548625461,
665
+ 0.34785484513745385,
666
+ 0.34785484513745385
667
+ ],
668
+ [
669
+ 0.5688888888888889,
670
+ 0.47862867049936647,
671
+ 0.47862867049936647,
672
+ 0.23692688505618908,
673
+ 0.23692688505618908
674
+ ],
675
+ [
676
+ 0.3607615730481386,
677
+ 0.3607615730481386,
678
+ 0.46791393457269104,
679
+ 0.46791393457269104,
680
+ 0.17132449237917036,
681
+ 0.17132449237917036
682
+ ],
683
+ [
684
+ 0.4179591836734694,
685
+ 0.3818300505051189,
686
+ 0.3818300505051189,
687
+ 0.27970539148927664,
688
+ 0.27970539148927664,
689
+ 0.1294849661688697,
690
+ 0.1294849661688697
691
+ ],
692
+ [
693
+ 0.362683783378362,
694
+ 0.362683783378362,
695
+ 0.31370664587788727,
696
+ 0.31370664587788727,
697
+ 0.22238103445337448,
698
+ 0.22238103445337448,
699
+ 0.10122853629037626,
700
+ 0.10122853629037626
701
+ ],
702
+ [
703
+ 0.3302393550012598,
704
+ 0.1806481606948574,
705
+ 0.1806481606948574,
706
+ 0.08127438836157441,
707
+ 0.08127438836157441,
708
+ 0.31234707704000286,
709
+ 0.31234707704000286,
710
+ 0.26061069640293544,
711
+ 0.26061069640293544
712
+ ],
713
+ [
714
+ 0.29552422471475287,
715
+ 0.29552422471475287,
716
+ 0.26926671930999635,
717
+ 0.26926671930999635,
718
+ 0.21908636251598204,
719
+ 0.21908636251598204,
720
+ 0.1494513491505806,
721
+ 0.1494513491505806,
722
+ 0.06667134430868814,
723
+ 0.06667134430868814
724
+ ],
725
+ [
726
+ 0.2729250867779006,
727
+ 0.26280454451024665,
728
+ 0.26280454451024665,
729
+ 0.23319376459199048,
730
+ 0.23319376459199048,
731
+ 0.18629021092773426,
732
+ 0.18629021092773426,
733
+ 0.1255803694649046,
734
+ 0.1255803694649046,
735
+ 0.05566856711617366,
736
+ 0.05566856711617366
737
+ ],
738
+ [
739
+ 0.24914704581340277,
740
+ 0.24914704581340277,
741
+ 0.2334925365383548,
742
+ 0.2334925365383548,
743
+ 0.20316742672306592,
744
+ 0.20316742672306592,
745
+ 0.16007832854334622,
746
+ 0.16007832854334622,
747
+ 0.10693932599531843,
748
+ 0.10693932599531843,
749
+ 0.04717533638651183,
750
+ 0.04717533638651183
751
+ ],
752
+ [
753
+ 0.2325515532308739,
754
+ 0.22628318026289723,
755
+ 0.22628318026289723,
756
+ 0.2078160475368885,
757
+ 0.2078160475368885,
758
+ 0.17814598076194574,
759
+ 0.17814598076194574,
760
+ 0.13887351021978725,
761
+ 0.13887351021978725,
762
+ 0.09212149983772845,
763
+ 0.09212149983772845,
764
+ 0.04048400476531588,
765
+ 0.04048400476531588
766
+ ],
767
+ [
768
+ 0.2152638534631578,
769
+ 0.2152638534631578,
770
+ 0.2051984637212956,
771
+ 0.2051984637212956,
772
+ 0.18553839747793782,
773
+ 0.18553839747793782,
774
+ 0.15720316715819355,
775
+ 0.15720316715819355,
776
+ 0.12151857068790319,
777
+ 0.12151857068790319,
778
+ 0.08015808715976021,
779
+ 0.08015808715976021,
780
+ 0.03511946033175186,
781
+ 0.03511946033175186
782
+ ],
783
+ [
784
+ 0.2025782419255613,
785
+ 0.19843148532711158,
786
+ 0.19843148532711158,
787
+ 0.1861610000155622,
788
+ 0.1861610000155622,
789
+ 0.16626920581699392,
790
+ 0.16626920581699392,
791
+ 0.13957067792615432,
792
+ 0.13957067792615432,
793
+ 0.10715922046717194,
794
+ 0.10715922046717194,
795
+ 0.07036604748810812,
796
+ 0.07036604748810812,
797
+ 0.03075324199611727,
798
+ 0.03075324199611727
799
+ ],
800
+ [
801
+ 0.1894506104550685,
802
+ 0.1894506104550685,
803
+ 0.18260341504492358,
804
+ 0.18260341504492358,
805
+ 0.16915651939500254,
806
+ 0.16915651939500254,
807
+ 0.14959598881657674,
808
+ 0.14959598881657674,
809
+ 0.12462897125553388,
810
+ 0.12462897125553388,
811
+ 0.09515851168249279,
812
+ 0.09515851168249279,
813
+ 0.062253523938647894,
814
+ 0.062253523938647894,
815
+ 0.027152459411754096,
816
+ 0.027152459411754096
817
+ ],
818
+ [
819
+ 0.17944647035620653,
820
+ 0.17656270536699264,
821
+ 0.17656270536699264,
822
+ 0.16800410215645004,
823
+ 0.16800410215645004,
824
+ 0.15404576107681028,
825
+ 0.15404576107681028,
826
+ 0.13513636846852548,
827
+ 0.13513636846852548,
828
+ 0.11188384719340397,
829
+ 0.11188384719340397,
830
+ 0.08503614831717918,
831
+ 0.08503614831717918,
832
+ 0.0554595293739872,
833
+ 0.0554595293739872,
834
+ 0.02414830286854793,
835
+ 0.02414830286854793
836
+ ],
837
+ [
838
+ 0.1691423829631436,
839
+ 0.1691423829631436,
840
+ 0.16427648374583273,
841
+ 0.16427648374583273,
842
+ 0.15468467512626524,
843
+ 0.15468467512626524,
844
+ 0.14064291467065065,
845
+ 0.14064291467065065,
846
+ 0.12255520671147846,
847
+ 0.12255520671147846,
848
+ 0.10094204410628717,
849
+ 0.10094204410628717,
850
+ 0.07642573025488905,
851
+ 0.07642573025488905,
852
+ 0.0497145488949698,
853
+ 0.0497145488949698,
854
+ 0.02161601352648331,
855
+ 0.02161601352648331
856
+ ],
857
+ [
858
+ 0.1610544498487837,
859
+ 0.15896884339395434,
860
+ 0.15896884339395434,
861
+ 0.15276604206585967,
862
+ 0.15276604206585967,
863
+ 0.1426067021736066,
864
+ 0.1426067021736066,
865
+ 0.12875396253933621,
866
+ 0.12875396253933621,
867
+ 0.11156664554733399,
868
+ 0.11156664554733399,
869
+ 0.09149002162245,
870
+ 0.09149002162245,
871
+ 0.06904454273764123,
872
+ 0.06904454273764123,
873
+ 0.0448142267656996,
874
+ 0.0448142267656996,
875
+ 0.019461788229726478,
876
+ 0.019461788229726478
877
+ ],
878
+ [
879
+ 0.15275338713072584,
880
+ 0.15275338713072584,
881
+ 0.14917298647260374,
882
+ 0.14917298647260374,
883
+ 0.14209610931838204,
884
+ 0.14209610931838204,
885
+ 0.13168863844917664,
886
+ 0.13168863844917664,
887
+ 0.11819453196151841,
888
+ 0.11819453196151841,
889
+ 0.10193011981724044,
890
+ 0.10193011981724044,
891
+ 0.08327674157670475,
892
+ 0.08327674157670475,
893
+ 0.06267204833410907,
894
+ 0.06267204833410907,
895
+ 0.04060142980038694,
896
+ 0.04060142980038694,
897
+ 0.017614007139152118,
898
+ 0.017614007139152118
899
+ ],
900
+ [
901
+ 0.14608113364969041,
902
+ 0.14452440398997005,
903
+ 0.14452440398997005,
904
+ 0.13988739479107315,
905
+ 0.13988739479107315,
906
+ 0.13226893863333747,
907
+ 0.13226893863333747,
908
+ 0.12183141605372853,
909
+ 0.12183141605372853,
910
+ 0.10879729916714838,
911
+ 0.10879729916714838,
912
+ 0.09344442345603386,
913
+ 0.09344442345603386,
914
+ 0.0761001136283793,
915
+ 0.0761001136283793,
916
+ 0.057134425426857205,
917
+ 0.057134425426857205,
918
+ 0.036953789770852494,
919
+ 0.036953789770852494,
920
+ 0.016017228257774335,
921
+ 0.016017228257774335
922
+ ],
923
+ [
924
+ 0.13925187285563198,
925
+ 0.13925187285563198,
926
+ 0.13654149834601517,
927
+ 0.13654149834601517,
928
+ 0.13117350478706238,
929
+ 0.13117350478706238,
930
+ 0.12325237681051242,
931
+ 0.12325237681051242,
932
+ 0.11293229608053922,
933
+ 0.11293229608053922,
934
+ 0.10041414444288096,
935
+ 0.10041414444288096,
936
+ 0.08594160621706773,
937
+ 0.08594160621706773,
938
+ 0.06979646842452049,
939
+ 0.06979646842452049,
940
+ 0.052293335152683286,
941
+ 0.052293335152683286,
942
+ 0.03377490158481415,
943
+ 0.03377490158481415,
944
+ 0.0146279952982722,
945
+ 0.0146279952982722
946
+ ],
947
+ [
948
+ 0.13365457218610619,
949
+ 0.1324620394046966,
950
+ 0.1324620394046966,
951
+ 0.12890572218808216,
952
+ 0.12890572218808216,
953
+ 0.12304908430672953,
954
+ 0.12304908430672953,
955
+ 0.11499664022241136,
956
+ 0.11499664022241136,
957
+ 0.10489209146454141,
958
+ 0.10489209146454141,
959
+ 0.09291576606003515,
960
+ 0.09291576606003515,
961
+ 0.07928141177671895,
962
+ 0.07928141177671895,
963
+ 0.06423242140852585,
964
+ 0.06423242140852585,
965
+ 0.04803767173108467,
966
+ 0.04803767173108467,
967
+ 0.030988005856979445,
968
+ 0.030988005856979445,
969
+ 0.013411859487141771,
970
+ 0.013411859487141771
971
+ ],
972
+ [
973
+ 0.12793819534675216,
974
+ 0.12793819534675216,
975
+ 0.1258374563468283,
976
+ 0.1258374563468283,
977
+ 0.12167047292780339,
978
+ 0.12167047292780339,
979
+ 0.1155056680537256,
980
+ 0.1155056680537256,
981
+ 0.10744427011596563,
982
+ 0.10744427011596563,
983
+ 0.09761865210411388,
984
+ 0.09761865210411388,
985
+ 0.08619016153195327,
986
+ 0.08619016153195327,
987
+ 0.0733464814110803,
988
+ 0.0733464814110803,
989
+ 0.05929858491543678,
990
+ 0.05929858491543678,
991
+ 0.04427743881741981,
992
+ 0.04427743881741981,
993
+ 0.028531388628933663,
994
+ 0.028531388628933663,
995
+ 0.0123412297999872,
996
+ 0.0123412297999872
997
+ ]
998
+ ];
999
+ var binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
1000
+ var cubicPoint = (xs, ys, t) => {
1001
+ const x = (1 - t) * (1 - t) * (1 - t) * xs[0] + 3 * (1 - t) * (1 - t) * t * xs[1] + 3 * (1 - t) * t * t * xs[2] + t * t * t * xs[3];
1002
+ const y = (1 - t) * (1 - t) * (1 - t) * ys[0] + 3 * (1 - t) * (1 - t) * t * ys[1] + 3 * (1 - t) * t * t * ys[2] + t * t * t * ys[3];
1003
+ return { x, y };
1004
+ };
1005
+ var getDerivative = (derivative, t, vs) => {
1006
+ const n = vs.length - 1;
1007
+ let value;
1008
+ if (n === 0) {
1009
+ return 0;
1010
+ }
1011
+ if (derivative === 0) {
1012
+ value = 0;
1013
+ for (let k = 0;k <= n; k++) {
1014
+ value += binomialCoefficients[n][k] * (1 - t) ** (n - k) * t ** k * vs[k];
1015
+ }
1016
+ return value;
1017
+ }
1018
+ const _vs = new Array(n);
1019
+ for (let k = 0;k < n; k++) {
1020
+ _vs[k] = n * (vs[k + 1] - vs[k]);
1021
+ }
1022
+ return getDerivative(derivative - 1, t, _vs);
1023
+ };
1024
+ function bFunc(xs, ys, t) {
1025
+ const xbase = getDerivative(1, t, xs);
1026
+ const ybase = getDerivative(1, t, ys);
1027
+ const combined = xbase * xbase + ybase * ybase;
1028
+ return Math.sqrt(combined);
1029
+ }
1030
+ var getCubicArcLength = ({
1031
+ sx,
1032
+ sy,
1033
+ t
1034
+ }) => {
1035
+ let correctedT;
1036
+ const n = 20;
1037
+ const z = t / 2;
1038
+ let sum = 0;
1039
+ for (let i = 0;i < n; i++) {
1040
+ correctedT = z * tValues[n][i] + z;
1041
+ sum += cValues[n][i] * bFunc(sx, sy, correctedT);
1042
+ }
1043
+ return z * sum;
1044
+ };
1045
+ var quadraticPoint = (xs, ys, t) => {
1046
+ const x = (1 - t) * (1 - t) * xs[0] + 2 * (1 - t) * t * xs[1] + t * t * xs[2];
1047
+ const y = (1 - t) * (1 - t) * ys[0] + 2 * (1 - t) * t * ys[1] + t * t * ys[2];
1048
+ return { x, y };
1049
+ };
1050
+ var cubicDerivative = (xs, ys, t) => {
1051
+ const derivative = quadraticPoint([3 * (xs[1] - xs[0]), 3 * (xs[2] - xs[1]), 3 * (xs[3] - xs[2])], [3 * (ys[1] - ys[0]), 3 * (ys[2] - ys[1]), 3 * (ys[3] - ys[2])], t);
1052
+ return derivative;
1053
+ };
1054
+ var t2length = ({
1055
+ length,
1056
+ totalLength,
1057
+ func
1058
+ }) => {
1059
+ let error = 1;
1060
+ let t = length / totalLength;
1061
+ let step = (length - func(t)) / totalLength;
1062
+ let numIterations = 0;
1063
+ while (error > 0.001) {
1064
+ const increasedTLength = func(t + step);
1065
+ const increasedTError = Math.abs(length - increasedTLength) / totalLength;
1066
+ if (increasedTError < error) {
1067
+ error = increasedTError;
1068
+ t += step;
1069
+ } else {
1070
+ const decreasedTLength = func(t - step);
1071
+ const decreasedTError = Math.abs(length - decreasedTLength) / totalLength;
1072
+ if (decreasedTError < error) {
1073
+ error = decreasedTError;
1074
+ t -= step;
1075
+ } else {
1076
+ step /= 2;
1077
+ }
1078
+ }
1079
+ numIterations++;
1080
+ if (numIterations > 500) {
1081
+ break;
1082
+ }
1083
+ }
1084
+ return t;
1085
+ };
1086
+ var makeCubic = ({
1087
+ startX,
1088
+ startY,
1089
+ cp1x,
1090
+ cp1y,
1091
+ cp2x,
1092
+ cp2y,
1093
+ x,
1094
+ y
1095
+ }) => {
1096
+ const a = { x: startX, y: startY };
1097
+ const b = { x: cp1x, y: cp1y };
1098
+ const c = { x: cp2x, y: cp2y };
1099
+ const d = { x, y };
1100
+ const length = getCubicArcLength({
1101
+ sx: [a.x, b.x, c.x, d.x],
1102
+ sy: [a.y, b.y, c.y, d.y],
1103
+ t: 1
1104
+ });
1105
+ const getTotalLength = () => {
1106
+ return length;
1107
+ };
1108
+ const getPointAtLength = (len) => {
1109
+ const sx = [a.x, b.x, c.x, d.x];
1110
+ const sy = [a.y, b.y, c.y, d.y];
1111
+ const t = t2length({
1112
+ length: len,
1113
+ totalLength: length,
1114
+ func: (i) => {
1115
+ return getCubicArcLength({ sx, sy, t: i });
1116
+ }
1117
+ });
1118
+ return cubicPoint(sx, sy, t);
1119
+ };
1120
+ const getTangentAtLength = (len) => {
1121
+ const xs = [a.x, b.x, c.x, d.x];
1122
+ const xy = [a.y, b.y, c.y, d.y];
1123
+ const t = t2length({
1124
+ length: len,
1125
+ totalLength: length,
1126
+ func: (i) => getCubicArcLength({ sx: xs, sy: xy, t: i })
1127
+ });
1128
+ const derivative = cubicDerivative(xs, xy, t);
1129
+ const mdl = Math.sqrt(derivative.x * derivative.x + derivative.y * derivative.y);
1130
+ let tangent;
1131
+ if (mdl > 0) {
1132
+ tangent = { x: derivative.x / mdl, y: derivative.y / mdl };
1133
+ } else {
1134
+ tangent = { x: 0, y: 0 };
1135
+ }
1136
+ return tangent;
1137
+ };
1138
+ const getC = () => {
1139
+ return c;
1140
+ };
1141
+ const getD = () => {
1142
+ return d;
1143
+ };
1144
+ return {
1145
+ getPointAtLength,
1146
+ getTangentAtLength,
1147
+ getTotalLength,
1148
+ getC,
1149
+ getD,
1150
+ type: "cubic-bezier"
1151
+ };
1152
+ };
1153
+ var makeLinearPosition = ({
1154
+ x0,
1155
+ x1,
1156
+ y0,
1157
+ y1
1158
+ }) => {
1159
+ return {
1160
+ getTotalLength: () => {
1161
+ return Math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2);
1162
+ },
1163
+ getPointAtLength: (pos) => {
1164
+ let fraction = pos / Math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2);
1165
+ fraction = Number.isNaN(fraction) ? 1 : fraction;
1166
+ const newDeltaX = (x1 - x0) * fraction;
1167
+ const newDeltaY = (y1 - y0) * fraction;
1168
+ return { x: x0 + newDeltaX, y: y0 + newDeltaY };
1169
+ },
1170
+ getTangentAtLength: () => {
1171
+ const module = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
1172
+ return { x: (x1 - x0) / module, y: (y1 - y0) / module };
1173
+ },
1174
+ type: "linear"
1175
+ };
1176
+ };
1177
+ var conductAnalysis = (instructions) => {
1178
+ let currentPoint = { x: 0, y: 0 };
1179
+ let moveStart = { x: 0, y: 0 };
1180
+ const segments = [];
1181
+ for (let i = 0;i < instructions.length; i++) {
1182
+ const instruction = instructions[i];
1183
+ if (instruction.type === "M") {
1184
+ currentPoint = { x: instruction.x, y: instruction.y };
1185
+ moveStart = { x: currentPoint.x, y: currentPoint.y };
1186
+ segments.push({
1187
+ startPoint: { x: instruction.x, y: instruction.y },
1188
+ instructionsAndInfo: [
1189
+ {
1190
+ instruction,
1191
+ function: null,
1192
+ length: 0,
1193
+ startPoint: currentPoint
1194
+ }
1195
+ ]
1196
+ });
1197
+ }
1198
+ if (instruction.type === "L") {
1199
+ if (segments.length > 0) {
1200
+ const length = Math.sqrt((currentPoint.x - instruction.x) ** 2 + (currentPoint.y - instruction.y) ** 2);
1201
+ segments[segments.length - 1].instructionsAndInfo.push({
1202
+ instruction,
1203
+ length,
1204
+ function: makeLinearPosition({
1205
+ x0: currentPoint.x,
1206
+ x1: instruction.x,
1207
+ y0: currentPoint.y,
1208
+ y1: instruction.y
1209
+ }),
1210
+ startPoint: currentPoint
1211
+ });
1212
+ }
1213
+ currentPoint = { x: instruction.x, y: instruction.y };
1214
+ }
1215
+ if (instruction.type === "Z") {
1216
+ if (segments.length > 0) {
1217
+ const length = Math.sqrt((segments[segments.length - 1].startPoint.x - currentPoint.x) ** 2 + (segments[segments.length - 1].startPoint.y - currentPoint.y) ** 2);
1218
+ segments[segments.length - 1].instructionsAndInfo.push({
1219
+ instruction,
1220
+ function: makeLinearPosition({
1221
+ x0: currentPoint.x,
1222
+ x1: moveStart.x,
1223
+ y0: currentPoint.y,
1224
+ y1: moveStart.y
1225
+ }),
1226
+ length,
1227
+ startPoint: { ...currentPoint }
1228
+ });
1229
+ }
1230
+ currentPoint = { x: moveStart.x, y: moveStart.y };
1231
+ }
1232
+ if (instruction.type === "C") {
1233
+ const curve = makeCubic({
1234
+ startX: currentPoint.x,
1235
+ startY: currentPoint.y,
1236
+ cp1x: instruction.cp1x,
1237
+ cp1y: instruction.cp1y,
1238
+ cp2x: instruction.cp2x,
1239
+ cp2y: instruction.cp2y,
1240
+ x: instruction.x,
1241
+ y: instruction.y
1242
+ });
1243
+ const length = curve.getTotalLength();
1244
+ if (segments.length > 0) {
1245
+ segments[segments.length - 1].instructionsAndInfo.push({
1246
+ instruction,
1247
+ length,
1248
+ function: curve,
1249
+ startPoint: { ...currentPoint }
1250
+ });
1251
+ }
1252
+ currentPoint = { x: instruction.x, y: instruction.y };
1253
+ }
1254
+ }
1255
+ return segments;
1256
+ };
1257
+ var length = {
1258
+ a: 7,
1259
+ A: 7,
1260
+ C: 6,
1261
+ c: 6,
1262
+ H: 1,
1263
+ h: 1,
1264
+ L: 2,
1265
+ l: 2,
1266
+ M: 2,
1267
+ m: 2,
1268
+ Q: 4,
1269
+ q: 4,
1270
+ S: 4,
1271
+ s: 4,
1272
+ T: 2,
1273
+ t: 2,
1274
+ V: 1,
1275
+ v: 1,
1276
+ Z: 0,
1277
+ z: 0
1278
+ };
1279
+ var chunkExact = (array, instruction) => {
1280
+ const chunks = [];
1281
+ const expectedSize = length[instruction];
1282
+ if (array.length % expectedSize !== 0) {
1283
+ throw new Error(`Expected number of arguments of SVG instruction "${instruction} ${array.join(" ")}" to be a multiple of ${expectedSize}`);
1284
+ }
1285
+ for (let i = 0;i < array.length; i += expectedSize) {
1286
+ chunks.push(array.slice(i, i + expectedSize));
1287
+ }
1288
+ return chunks;
1289
+ };
1290
+ var makeInstructions = (arr, instruction, cb) => {
1291
+ return chunkExact(arr, instruction).map((args) => {
1292
+ return cb(args);
1293
+ });
1294
+ };
1295
+ var segmentRegExp = /([astvzqmhlc])([^astvzqmhlc]*)/gi;
1296
+ var numberRegExp = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
1297
+ var parseValues = (args, instructionType) => {
1298
+ const numbers = args.match(numberRegExp);
1299
+ if (!numbers) {
1300
+ if (instructionType === "Z" || instructionType === "z") {
1301
+ return [];
1302
+ }
1303
+ throw new Error(`Malformed path data: ${instructionType} was expected to have numbers afterwards`);
1304
+ }
1305
+ const expectedArguments = length[instructionType];
1306
+ if (numbers.length % expectedArguments !== 0) {
1307
+ throw new Error(`Malformed path data: ${instructionType} was expected to have a multiple of ${expectedArguments} numbers, but got "${instructionType} ${numbers.join(" ")} instead"`);
1308
+ }
1309
+ return numbers.map(Number);
1310
+ };
1311
+ var parsePath = (path) => {
1312
+ if (!path) {
1313
+ throw new Error("No path provided");
1314
+ }
1315
+ const segments = path.match(segmentRegExp);
1316
+ if (!segments) {
1317
+ throw new Error(`No path elements found in string ${path}`);
1318
+ }
1319
+ return segments.map((segmentString) => {
1320
+ const command = segmentString.charAt(0);
1321
+ const args = parseValues(segmentString.substring(1), command);
1322
+ if (command === "M" && args.length > 2) {
1323
+ const segmentsArray = [];
1324
+ segmentsArray.push({
1325
+ type: command,
1326
+ x: args[0],
1327
+ y: args[1]
1328
+ });
1329
+ segmentsArray.push(...makeInstructions(args.slice(2), "L", (numbers) => ({
1330
+ type: "L",
1331
+ x: numbers[0],
1332
+ y: numbers[1]
1333
+ })));
1334
+ return segmentsArray;
1335
+ }
1336
+ if (command === "m" && args.length > 2) {
1337
+ const segmentsArray = [];
1338
+ segmentsArray.push({
1339
+ type: command,
1340
+ dx: args[0],
1341
+ dy: args[1]
1342
+ });
1343
+ segmentsArray.push(...makeInstructions(args.slice(2), "l", (numbers) => ({
1344
+ type: "l",
1345
+ dx: numbers[0],
1346
+ dy: numbers[1]
1347
+ })));
1348
+ return segmentsArray;
1349
+ }
1350
+ if (command === "Z" || command === "z") {
1351
+ return [
1352
+ {
1353
+ type: "Z"
1354
+ }
1355
+ ];
1356
+ }
1357
+ if (command === "A") {
1358
+ return makeInstructions(args, command, (numbers) => ({
1359
+ type: command,
1360
+ rx: numbers[0],
1361
+ ry: numbers[1],
1362
+ xAxisRotation: numbers[2],
1363
+ largeArcFlag: numbers[3] === 1,
1364
+ sweepFlag: numbers[4] === 1,
1365
+ x: numbers[5],
1366
+ y: numbers[6]
1367
+ }));
1368
+ }
1369
+ if (command === "a") {
1370
+ return makeInstructions(args, command, (numbers) => ({
1371
+ type: command,
1372
+ rx: numbers[0],
1373
+ ry: numbers[1],
1374
+ xAxisRotation: numbers[2],
1375
+ largeArcFlag: numbers[3] === 1,
1376
+ sweepFlag: numbers[4] === 1,
1377
+ dx: numbers[5],
1378
+ dy: numbers[6]
1379
+ }));
1380
+ }
1381
+ if (command === "C") {
1382
+ return makeInstructions(args, command, (numbers) => ({
1383
+ type: command,
1384
+ cp1x: numbers[0],
1385
+ cp1y: numbers[1],
1386
+ cp2x: numbers[2],
1387
+ cp2y: numbers[3],
1388
+ x: numbers[4],
1389
+ y: numbers[5]
1390
+ }));
1391
+ }
1392
+ if (command === "c") {
1393
+ return makeInstructions(args, command, (numbers) => ({
1394
+ type: command,
1395
+ cp1dx: numbers[0],
1396
+ cp1dy: numbers[1],
1397
+ cp2dx: numbers[2],
1398
+ cp2dy: numbers[3],
1399
+ dx: numbers[4],
1400
+ dy: numbers[5]
1401
+ }));
1402
+ }
1403
+ if (command === "S") {
1404
+ return makeInstructions(args, command, (numbers) => ({
1405
+ type: command,
1406
+ cpx: numbers[0],
1407
+ cpy: numbers[1],
1408
+ x: numbers[2],
1409
+ y: numbers[3]
1410
+ }));
1411
+ }
1412
+ if (command === "s") {
1413
+ return makeInstructions(args, command, (numbers) => ({
1414
+ type: command,
1415
+ cpdx: numbers[0],
1416
+ cpdy: numbers[1],
1417
+ dx: numbers[2],
1418
+ dy: numbers[3]
1419
+ }));
1420
+ }
1421
+ if (command === "H") {
1422
+ return makeInstructions(args, command, (numbers) => ({
1423
+ type: command,
1424
+ x: numbers[0]
1425
+ }));
1426
+ }
1427
+ if (command === "h") {
1428
+ return makeInstructions(args, command, (numbers) => ({
1429
+ type: command,
1430
+ dx: numbers[0]
1431
+ }));
1432
+ }
1433
+ if (command === "V") {
1434
+ return makeInstructions(args, command, (numbers) => ({
1435
+ type: command,
1436
+ y: numbers[0]
1437
+ }));
1438
+ }
1439
+ if (command === "v") {
1440
+ return makeInstructions(args, command, (numbers) => ({
1441
+ type: command,
1442
+ dy: numbers[0]
1443
+ }));
1444
+ }
1445
+ if (command === "L") {
1446
+ return makeInstructions(args, command, (numbers) => ({
1447
+ type: command,
1448
+ x: numbers[0],
1449
+ y: numbers[1]
1450
+ }));
1451
+ }
1452
+ if (command === "M") {
1453
+ return makeInstructions(args, command, (numbers) => ({
1454
+ type: command,
1455
+ x: numbers[0],
1456
+ y: numbers[1]
1457
+ }));
1458
+ }
1459
+ if (command === "m") {
1460
+ return makeInstructions(args, command, (numbers) => ({
1461
+ type: command,
1462
+ dx: numbers[0],
1463
+ dy: numbers[1]
1464
+ }));
1465
+ }
1466
+ if (command === "l") {
1467
+ return makeInstructions(args, command, (numbers) => ({
1468
+ type: command,
1469
+ dx: numbers[0],
1470
+ dy: numbers[1]
1471
+ }));
1472
+ }
1473
+ if (command === "Q") {
1474
+ return makeInstructions(args, command, (numbers) => ({
1475
+ type: command,
1476
+ cpx: numbers[0],
1477
+ cpy: numbers[1],
1478
+ x: numbers[2],
1479
+ y: numbers[3]
1480
+ }));
1481
+ }
1482
+ if (command === "q") {
1483
+ return makeInstructions(args, command, (numbers) => ({
1484
+ type: command,
1485
+ cpdx: numbers[0],
1486
+ cpdy: numbers[1],
1487
+ dx: numbers[2],
1488
+ dy: numbers[3]
1489
+ }));
1490
+ }
1491
+ if (command === "T") {
1492
+ return makeInstructions(args, command, (numbers) => ({
1493
+ type: command,
1494
+ x: numbers[0],
1495
+ y: numbers[1]
1496
+ }));
1497
+ }
1498
+ if (command === "t") {
1499
+ return makeInstructions(args, command, (numbers) => ({
1500
+ type: command,
1501
+ dx: numbers[0],
1502
+ dy: numbers[1]
1503
+ }));
1504
+ }
1505
+ throw new Error(`Invalid path element ${segmentString}`);
1506
+ }, []).flat(1);
1507
+ };
1508
+ var convertQToCInstruction = (instruction, startPoint) => {
1509
+ const cp1x = startPoint.x + 2 / 3 * (instruction.cpx - startPoint.x);
1510
+ const cp1y = startPoint.y + 2 / 3 * (instruction.cpy - startPoint.y);
1511
+ const cp2x = instruction.x + 2 / 3 * (instruction.cpx - instruction.x);
1512
+ const cp2y = instruction.y + 2 / 3 * (instruction.cpy - instruction.y);
1513
+ return {
1514
+ type: "C",
1515
+ cp1x,
1516
+ cp1y,
1517
+ cp2x,
1518
+ cp2y,
1519
+ x: instruction.x,
1520
+ y: instruction.y
1521
+ };
1522
+ };
1523
+ var iterateOverSegments = ({
1524
+ segments,
1525
+ iterate
1526
+ }) => {
1527
+ let x = 0;
1528
+ let y = 0;
1529
+ let initialX = 0;
1530
+ let initialY = 0;
1531
+ let cpX = null;
1532
+ let cpY = null;
1533
+ const newSegments = segments.map((s, i) => {
1534
+ const newSeg = iterate({
1535
+ segment: s,
1536
+ x,
1537
+ y,
1538
+ prevSegment: segments[i - 1] ?? null,
1539
+ initialX,
1540
+ initialY,
1541
+ cpX,
1542
+ cpY
1543
+ });
1544
+ switch (s.type) {
1545
+ case "M":
1546
+ initialX = s.x;
1547
+ initialY = s.y;
1548
+ x = s.x;
1549
+ y = s.y;
1550
+ cpX = null;
1551
+ cpY = null;
1552
+ break;
1553
+ case "Q":
1554
+ x = s.x;
1555
+ y = s.y;
1556
+ cpX = s.cpx;
1557
+ cpY = s.cpy;
1558
+ break;
1559
+ case "A":
1560
+ x = s.x;
1561
+ y = s.y;
1562
+ cpX = null;
1563
+ cpY = null;
1564
+ break;
1565
+ case "C":
1566
+ x = s.x;
1567
+ y = s.y;
1568
+ cpX = s.cp2x;
1569
+ cpY = s.cp2y;
1570
+ break;
1571
+ case "S":
1572
+ x = s.x;
1573
+ y = s.y;
1574
+ cpX = s.cpx;
1575
+ cpY = s.cpy;
1576
+ break;
1577
+ case "T":
1578
+ if (cpX !== null && cpY !== null) {
1579
+ cpX = x - (cpX - x);
1580
+ cpY = y - (cpY - y);
1581
+ }
1582
+ x = s.x;
1583
+ y = s.y;
1584
+ break;
1585
+ case "L":
1586
+ x = s.x;
1587
+ y = s.y;
1588
+ cpX = null;
1589
+ cpY = null;
1590
+ break;
1591
+ case "V":
1592
+ y = s.y;
1593
+ cpX = null;
1594
+ cpY = null;
1595
+ break;
1596
+ case "H":
1597
+ x = s.x;
1598
+ cpX = null;
1599
+ cpY = null;
1600
+ break;
1601
+ case "Z":
1602
+ x = initialX;
1603
+ y = initialY;
1604
+ cpX = null;
1605
+ cpY = null;
1606
+ break;
1607
+ default:
1608
+ throw new Error(`Unexpected instruction ${s.type}`);
1609
+ }
1610
+ return newSeg;
1611
+ });
1612
+ return newSegments.flat(1);
1613
+ };
1614
+ var TAU = Math.PI * 2;
1615
+ function approximate_unit_arc(theta1, delta_theta) {
1616
+ const alpha = 4 / 3 * Math.tan(delta_theta / 4);
1617
+ const x1 = Math.cos(theta1);
1618
+ const y1 = Math.sin(theta1);
1619
+ const x2 = Math.cos(theta1 + delta_theta);
1620
+ const y2 = Math.sin(theta1 + delta_theta);
1621
+ return [
1622
+ x1,
1623
+ y1,
1624
+ x1 - y1 * alpha,
1625
+ y1 + x1 * alpha,
1626
+ x2 + y2 * alpha,
1627
+ y2 - x2 * alpha,
1628
+ x2,
1629
+ y2
1630
+ ];
1631
+ }
1632
+ function unit_vector_angle(ux, uy, vx, vy) {
1633
+ const sign = ux * vy - uy * vx < 0 ? -1 : 1;
1634
+ let dot2 = ux * vx + uy * vy;
1635
+ if (dot2 > 1) {
1636
+ dot2 = 1;
1637
+ }
1638
+ if (dot2 < -1) {
1639
+ dot2 = -1;
1640
+ }
1641
+ return sign * Math.acos(dot2);
1642
+ }
1643
+ function get_arc_center({
1644
+ x1,
1645
+ y1,
1646
+ x2,
1647
+ y2,
1648
+ largeArcFlag,
1649
+ sweepFlag,
1650
+ rx,
1651
+ ry,
1652
+ sin_phi,
1653
+ cos_phi
1654
+ }) {
1655
+ const x1p = cos_phi * (x1 - x2) / 2 + sin_phi * (y1 - y2) / 2;
1656
+ const y1p = -sin_phi * (x1 - x2) / 2 + cos_phi * (y1 - y2) / 2;
1657
+ const rx_sq = rx * rx;
1658
+ const ry_sq = ry * ry;
1659
+ const x1p_sq = x1p * x1p;
1660
+ const y1p_sq = y1p * y1p;
1661
+ let radicant = rx_sq * ry_sq - rx_sq * y1p_sq - ry_sq * x1p_sq;
1662
+ if (radicant < 0) {
1663
+ radicant = 0;
1664
+ }
1665
+ radicant /= rx_sq * y1p_sq + ry_sq * x1p_sq;
1666
+ radicant = Math.sqrt(radicant) * (largeArcFlag === sweepFlag ? -1 : 1);
1667
+ const cxp = radicant * rx / ry * y1p;
1668
+ const cyp = radicant * -ry / rx * x1p;
1669
+ const cx = cos_phi * cxp - sin_phi * cyp + (x1 + x2) / 2;
1670
+ const cy = sin_phi * cxp + cos_phi * cyp + (y1 + y2) / 2;
1671
+ const v1x = (x1p - cxp) / rx;
1672
+ const v1y = (y1p - cyp) / ry;
1673
+ const v2x = (-x1p - cxp) / rx;
1674
+ const v2y = (-y1p - cyp) / ry;
1675
+ const theta1 = unit_vector_angle(1, 0, v1x, v1y);
1676
+ let delta_theta = unit_vector_angle(v1x, v1y, v2x, v2y);
1677
+ if (sweepFlag === false && delta_theta > 0) {
1678
+ delta_theta -= TAU;
1679
+ }
1680
+ if (sweepFlag === true && delta_theta < 0) {
1681
+ delta_theta += TAU;
1682
+ }
1683
+ return [cx, cy, theta1, delta_theta];
1684
+ }
1685
+ function arcToCircle({
1686
+ x1,
1687
+ y1,
1688
+ x2,
1689
+ y2,
1690
+ largeArcFlag,
1691
+ sweepFlag,
1692
+ rx,
1693
+ ry,
1694
+ phi
1695
+ }) {
1696
+ const sin_phi = Math.sin(phi * TAU / 360);
1697
+ const cos_phi = Math.cos(phi * TAU / 360);
1698
+ const x1p = cos_phi * (x1 - x2) / 2 + sin_phi * (y1 - y2) / 2;
1699
+ const y1p = -sin_phi * (x1 - x2) / 2 + cos_phi * (y1 - y2) / 2;
1700
+ if (x1p === 0 && y1p === 0) {
1701
+ return [];
1702
+ }
1703
+ if (rx === 0 || ry === 0) {
1704
+ return [];
1705
+ }
1706
+ rx = Math.abs(rx);
1707
+ ry = Math.abs(ry);
1708
+ const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
1709
+ if (lambda > 1) {
1710
+ rx *= Math.sqrt(lambda);
1711
+ ry *= Math.sqrt(lambda);
1712
+ }
1713
+ const cc = get_arc_center({
1714
+ x1,
1715
+ y1,
1716
+ x2,
1717
+ y2,
1718
+ largeArcFlag,
1719
+ sweepFlag,
1720
+ rx,
1721
+ ry,
1722
+ sin_phi,
1723
+ cos_phi
1724
+ });
1725
+ const result = [];
1726
+ let theta1 = cc[2];
1727
+ let delta_theta = cc[3];
1728
+ const segments = Math.max(Math.ceil(Math.abs(delta_theta) / (TAU / 4)), 1);
1729
+ delta_theta /= segments;
1730
+ for (let i = 0;i < segments; i++) {
1731
+ result.push(approximate_unit_arc(theta1, delta_theta));
1732
+ theta1 += delta_theta;
1733
+ }
1734
+ return result.map((curve) => {
1735
+ for (let i = 0;i < curve.length; i += 2) {
1736
+ let x = curve[i + 0];
1737
+ let y = curve[i + 1];
1738
+ x *= rx;
1739
+ y *= ry;
1740
+ const xp = cos_phi * x - sin_phi * y;
1741
+ const yp = sin_phi * x + cos_phi * y;
1742
+ curve[i + 0] = xp + cc[0];
1743
+ curve[i + 1] = yp + cc[1];
1744
+ }
1745
+ return curve;
1746
+ });
1747
+ }
1748
+ var removeATSHVQInstructions = (segments) => {
1749
+ return iterateOverSegments({
1750
+ segments,
1751
+ iterate: ({ segment, prevSegment, x, y, cpX, cpY }) => {
1752
+ if (segment.type === "H") {
1753
+ return [{ type: "L", x: segment.x, y }];
1754
+ }
1755
+ if (segment.type === "V") {
1756
+ return [{ type: "L", x, y: segment.y }];
1757
+ }
1758
+ if (segment.type === "A") {
1759
+ const nextX = segment.x;
1760
+ const nextY = segment.y;
1761
+ const new_segments = arcToCircle({
1762
+ x1: x,
1763
+ y1: y,
1764
+ x2: nextX,
1765
+ y2: nextY,
1766
+ largeArcFlag: segment.largeArcFlag,
1767
+ sweepFlag: segment.sweepFlag,
1768
+ rx: segment.rx,
1769
+ ry: segment.ry,
1770
+ phi: segment.xAxisRotation
1771
+ });
1772
+ if (new_segments.length === 0) {
1773
+ return [
1774
+ {
1775
+ type: "L",
1776
+ x: segment.x,
1777
+ y: segment.y
1778
+ }
1779
+ ];
1780
+ }
1781
+ const result = new_segments.map((_s) => {
1782
+ return {
1783
+ type: "C",
1784
+ cp1x: _s[2],
1785
+ cp1y: _s[3],
1786
+ cp2x: _s[4],
1787
+ cp2y: _s[5],
1788
+ x: _s[6],
1789
+ y: _s[7]
1790
+ };
1791
+ });
1792
+ return result;
1793
+ }
1794
+ if (segment.type === "T") {
1795
+ let prevControlX = 0;
1796
+ let prevControlY = 0;
1797
+ if (prevSegment && (prevSegment.type === "Q" || prevSegment.type === "T")) {
1798
+ prevControlX = cpX;
1799
+ prevControlY = cpY;
1800
+ } else {
1801
+ prevControlX = x;
1802
+ prevControlY = y;
1803
+ }
1804
+ const vectorX = prevControlX - x;
1805
+ const vectorY = prevControlY - y;
1806
+ const newControlX = x - vectorX;
1807
+ const newControlY = y - vectorY;
1808
+ return [
1809
+ convertQToCInstruction({
1810
+ type: "Q",
1811
+ cpx: newControlX,
1812
+ cpy: newControlY,
1813
+ x: segment.x,
1814
+ y: segment.y
1815
+ }, { x, y })
1816
+ ];
1817
+ }
1818
+ if (segment.type === "S") {
1819
+ let prevControlX = 0;
1820
+ let prevControlY = 0;
1821
+ if (prevSegment && prevSegment.type === "C") {
1822
+ prevControlX = prevSegment.cp2x;
1823
+ prevControlY = prevSegment.cp2y;
1824
+ } else if (prevSegment && prevSegment.type === "S") {
1825
+ prevControlX = prevSegment.cpx;
1826
+ prevControlY = prevSegment.cpy;
1827
+ } else {
1828
+ prevControlX = x;
1829
+ prevControlY = y;
1830
+ }
1831
+ const vectorX = prevControlX - x;
1832
+ const vectorY = prevControlY - y;
1833
+ const newControlX = x - vectorX;
1834
+ const newControlY = y - vectorY;
1835
+ return [
1836
+ {
1837
+ type: "C",
1838
+ cp1x: newControlX,
1839
+ cp1y: newControlY,
1840
+ cp2x: segment.cpx,
1841
+ cp2y: segment.cpy,
1842
+ x: segment.x,
1843
+ y: segment.y
1844
+ }
1845
+ ];
1846
+ }
1847
+ if (segment.type === "Q") {
1848
+ return [convertQToCInstruction(segment, { x, y })];
1849
+ }
1850
+ return [segment];
1851
+ }
1852
+ });
1853
+ };
1854
+ var serializeInstruction = (instruction) => {
1855
+ if (instruction.type === "A") {
1856
+ return `A ${instruction.rx} ${instruction.ry} ${instruction.xAxisRotation} ${Number(instruction.largeArcFlag)} ${Number(instruction.sweepFlag)} ${instruction.x} ${instruction.y}`;
1857
+ }
1858
+ if (instruction.type === "a") {
1859
+ return `a ${instruction.rx} ${instruction.ry} ${instruction.xAxisRotation} ${Number(instruction.largeArcFlag)} ${Number(instruction.sweepFlag)} ${instruction.dx} ${instruction.dy}`;
1860
+ }
1861
+ if (instruction.type === "C") {
1862
+ return `C ${instruction.cp1x} ${instruction.cp1y} ${instruction.cp2x} ${instruction.cp2y} ${instruction.x} ${instruction.y}`;
1863
+ }
1864
+ if (instruction.type === "c") {
1865
+ return `c ${instruction.cp1dx} ${instruction.cp1dy} ${instruction.cp2dx} ${instruction.cp2dy} ${instruction.dx} ${instruction.dy}`;
1866
+ }
1867
+ if (instruction.type === "S") {
1868
+ return `S ${instruction.cpx} ${instruction.cpy} ${instruction.x} ${instruction.y}`;
1869
+ }
1870
+ if (instruction.type === "s") {
1871
+ return `s ${instruction.cpdx} ${instruction.cpdy} ${instruction.dx} ${instruction.dy}`;
1872
+ }
1873
+ if (instruction.type === "Q") {
1874
+ return `Q ${instruction.cpx} ${instruction.cpy} ${instruction.x} ${instruction.y}`;
1875
+ }
1876
+ if (instruction.type === "q") {
1877
+ return `q ${instruction.cpdx} ${instruction.cpdy} ${instruction.dx} ${instruction.dy}`;
1878
+ }
1879
+ if (instruction.type === "Z") {
1880
+ return "Z";
1881
+ }
1882
+ if (instruction.type === "H") {
1883
+ return `H ${instruction.x}`;
1884
+ }
1885
+ if (instruction.type === "h") {
1886
+ return `h ${instruction.dx}`;
1887
+ }
1888
+ if (instruction.type === "V") {
1889
+ return `V ${instruction.y}`;
1890
+ }
1891
+ if (instruction.type === "v") {
1892
+ return `v ${instruction.dy}`;
1893
+ }
1894
+ if (instruction.type === "L") {
1895
+ return `L ${instruction.x} ${instruction.y}`;
1896
+ }
1897
+ if (instruction.type === "l") {
1898
+ return `l ${instruction.dx} ${instruction.dy}`;
1899
+ }
1900
+ if (instruction.type === "M") {
1901
+ return `M ${instruction.x} ${instruction.y}`;
1902
+ }
1903
+ if (instruction.type === "m") {
1904
+ return `m ${instruction.dx} ${instruction.dy}`;
1905
+ }
1906
+ if (instruction.type === "T") {
1907
+ return `T ${instruction.x} ${instruction.y}`;
1908
+ }
1909
+ if (instruction.type === "t") {
1910
+ return `t ${instruction.dx} ${instruction.dy}`;
1911
+ }
1912
+ throw new Error(`Unknown instruction type: ${instruction.type}`);
1913
+ };
1914
+ var serializeInstructions = (path) => {
1915
+ return path.map((p) => {
1916
+ return serializeInstruction(p);
1917
+ }).join(" ");
1918
+ };
1919
+ var normalizeInstructions = (instructions) => {
1920
+ const normalized = [];
1921
+ let x = 0;
1922
+ let y = 0;
1923
+ let moveX = 0;
1924
+ let moveY = 0;
1925
+ for (let i = 0;i < instructions.length; i++) {
1926
+ const instruction = instructions[i];
1927
+ if (instruction.type === "M") {
1928
+ moveX = instruction.x;
1929
+ moveY = instruction.y;
1930
+ } else if (instruction.type === "m") {
1931
+ moveX += instruction.dx;
1932
+ moveY += instruction.dy;
1933
+ }
1934
+ if (instruction.type === "A" || instruction.type === "C" || instruction.type === "L" || instruction.type === "M" || instruction.type === "Q" || instruction.type === "S" || instruction.type === "T") {
1935
+ normalized.push(instruction);
1936
+ x = instruction.x;
1937
+ y = instruction.y;
1938
+ continue;
1939
+ }
1940
+ if (instruction.type === "a" || instruction.type === "c" || instruction.type === "l" || instruction.type === "m" || instruction.type === "q" || instruction.type === "s" || instruction.type === "t") {
1941
+ const currentX = x;
1942
+ const currentY = y;
1943
+ x += instruction.dx;
1944
+ y += instruction.dy;
1945
+ if (instruction.type === "a") {
1946
+ normalized.push({
1947
+ type: "A",
1948
+ largeArcFlag: instruction.largeArcFlag,
1949
+ rx: instruction.rx,
1950
+ ry: instruction.ry,
1951
+ sweepFlag: instruction.sweepFlag,
1952
+ xAxisRotation: instruction.xAxisRotation,
1953
+ x,
1954
+ y
1955
+ });
1956
+ continue;
1957
+ }
1958
+ if (instruction.type === "c") {
1959
+ normalized.push({
1960
+ type: "C",
1961
+ cp1x: instruction.cp1dx + currentX,
1962
+ cp1y: instruction.cp1dy + currentY,
1963
+ cp2x: instruction.cp2dx + currentX,
1964
+ cp2y: instruction.cp2dy + currentY,
1965
+ x,
1966
+ y
1967
+ });
1968
+ continue;
1969
+ }
1970
+ if (instruction.type === "l") {
1971
+ normalized.push({
1972
+ type: "L",
1973
+ x,
1974
+ y
1975
+ });
1976
+ continue;
1977
+ }
1978
+ if (instruction.type === "m") {
1979
+ normalized.push({
1980
+ type: "M",
1981
+ x,
1982
+ y
1983
+ });
1984
+ continue;
1985
+ }
1986
+ if (instruction.type === "q") {
1987
+ normalized.push({
1988
+ type: "Q",
1989
+ cpx: instruction.cpdx + currentX,
1990
+ cpy: instruction.cpdy + currentY,
1991
+ x,
1992
+ y
1993
+ });
1994
+ continue;
1995
+ }
1996
+ if (instruction.type === "s") {
1997
+ normalized.push({
1998
+ type: "S",
1999
+ cpx: instruction.cpdx + currentX,
2000
+ cpy: instruction.cpdy + currentY,
2001
+ x,
2002
+ y
2003
+ });
2004
+ continue;
2005
+ }
2006
+ if (instruction.type === "t") {
2007
+ normalized.push({
2008
+ type: "T",
2009
+ x,
2010
+ y
2011
+ });
2012
+ continue;
2013
+ }
2014
+ }
2015
+ if (instruction.type === "H") {
2016
+ normalized.push(instruction);
2017
+ x = instruction.x;
2018
+ continue;
2019
+ }
2020
+ if (instruction.type === "V") {
2021
+ normalized.push(instruction);
2022
+ y = instruction.y;
2023
+ continue;
2024
+ }
2025
+ if (instruction.type === "Z") {
2026
+ normalized.push(instruction);
2027
+ x = moveX;
2028
+ y = moveY;
2029
+ continue;
2030
+ }
2031
+ if (instruction.type === "h") {
2032
+ x += instruction.dx;
2033
+ normalized.push({
2034
+ type: "H",
2035
+ x
2036
+ });
2037
+ continue;
2038
+ }
2039
+ if (instruction.type === "v") {
2040
+ y += instruction.dy;
2041
+ normalized.push({
2042
+ type: "V",
2043
+ y
2044
+ });
2045
+ continue;
2046
+ }
2047
+ throw new Error("Unknown instruction type: " + instruction.type);
2048
+ }
2049
+ return normalized;
2050
+ };
2051
+ var reduceInstructions = (instruction) => {
2052
+ const simplified = normalizeInstructions(instruction);
2053
+ return removeATSHVQInstructions(simplified);
2054
+ };
2055
+ var cutPath = (d, length2) => {
2056
+ const parsed = parsePath(d);
2057
+ const reduced = reduceInstructions(parsed);
2058
+ const constructed = conductAnalysis(reduced);
2059
+ const newInstructions = [];
2060
+ let summedUpLength = 0;
2061
+ for (const segment of constructed) {
2062
+ for (const instructionAndInfo of segment.instructionsAndInfo) {
2063
+ if (summedUpLength + instructionAndInfo.length > length2) {
2064
+ const remainingLength = length2 - summedUpLength;
2065
+ const progress = remainingLength / instructionAndInfo.length;
2066
+ const cut = cutInstruction({
2067
+ instruction: instructionAndInfo.instruction,
2068
+ lastPoint: instructionAndInfo.startPoint,
2069
+ progress
2070
+ });
2071
+ newInstructions.push(cut);
2072
+ return serializeInstructions(newInstructions);
2073
+ }
2074
+ summedUpLength += instructionAndInfo.length;
2075
+ newInstructions.push(instructionAndInfo.instruction);
2076
+ if (summedUpLength === length2) {
2077
+ return serializeInstructions(newInstructions);
2078
+ }
2079
+ }
2080
+ }
2081
+ return serializeInstructions(newInstructions);
2082
+ };
2083
+ var debugPath = (d) => {
2084
+ const instructions = normalizeInstructions(parsePath(d));
2085
+ return instructions.map((inst, i) => {
2086
+ if (inst.type === "Z") {
2087
+ return null;
2088
+ }
2089
+ if (inst.type === "H" || inst.type === "V") {
2090
+ return null;
2091
+ }
2092
+ const topLeft = [inst.x - 5, inst.y - 5];
2093
+ const topRight = [inst.x + 5, inst.y - 5];
2094
+ const bottomLeft = [inst.x - 5, inst.y + 5];
2095
+ const bottomRight = [inst.x + 5, inst.y + 5];
2096
+ const triangle = [
2097
+ {
2098
+ type: "M",
2099
+ x: topLeft[0],
2100
+ y: topLeft[1]
2101
+ },
2102
+ {
2103
+ type: "L",
2104
+ x: topRight[0],
2105
+ y: topRight[1]
2106
+ },
2107
+ {
2108
+ type: "L",
2109
+ x: bottomRight[0],
2110
+ y: bottomRight[1]
2111
+ },
2112
+ {
2113
+ type: "L",
2114
+ x: bottomLeft[0],
2115
+ y: bottomLeft[1]
2116
+ },
2117
+ {
2118
+ type: "Z"
2119
+ }
2120
+ ];
2121
+ return {
2122
+ d: serializeInstructions(triangle),
2123
+ color: i === instructions.length - 1 ? "red" : inst.type === "M" ? "blue" : "green"
2124
+ };
2125
+ }).filter(Boolean);
2126
+ };
2127
+ var CBEZIER_MINMAX_EPSILON = 0.00000001;
2128
+ function minmaxQ(A) {
2129
+ const min = Math.min(A[0], A[2]);
2130
+ const max = Math.max(A[0], A[2]);
2131
+ if (A[1] > A[0] ? A[2] >= A[1] : A[2] <= A[1]) {
2132
+ return [min, max];
2133
+ }
2134
+ const E = (A[0] * A[2] - A[1] * A[1]) / (A[0] - 2 * A[1] + A[2]);
2135
+ return E < min ? [E, max] : [min, E];
2136
+ }
2137
+ function minmaxC(A) {
2138
+ const K = A[0] - 3 * A[1] + 3 * A[2] - A[3];
2139
+ if (Math.abs(K) < CBEZIER_MINMAX_EPSILON) {
2140
+ if (A[0] === A[3] && A[0] === A[1]) {
2141
+ return [A[0], A[3]];
2142
+ }
2143
+ return minmaxQ([
2144
+ A[0],
2145
+ -0.5 * A[0] + 1.5 * A[1],
2146
+ A[0] - 3 * A[1] + 3 * A[2]
2147
+ ]);
2148
+ }
2149
+ const T = -A[0] * A[2] + A[0] * A[3] - A[1] * A[2] - A[1] * A[3] + A[1] * A[1] + A[2] * A[2];
2150
+ if (T <= 0) {
2151
+ return [Math.min(A[0], A[3]), Math.max(A[0], A[3])];
2152
+ }
2153
+ const S = Math.sqrt(T);
2154
+ let min = Math.min(A[0], A[3]);
2155
+ let max = Math.max(A[0], A[3]);
2156
+ const L = A[0] - 2 * A[1] + A[2];
2157
+ for (let R = (L + S) / K, i = 1;i <= 2; R = (L - S) / K, i++) {
2158
+ if (R > 0 && R < 1) {
2159
+ const Q = A[0] * (1 - R) * (1 - R) * (1 - R) + A[1] * 3 * (1 - R) * (1 - R) * R + A[2] * 3 * (1 - R) * R * R + A[3] * R * R * R;
2160
+ if (Q < min) {
2161
+ min = Q;
2162
+ }
2163
+ if (Q > max) {
2164
+ max = Q;
2165
+ }
2166
+ }
2167
+ }
2168
+ return [min, max];
2169
+ }
2170
+ var getBoundingBoxFromInstructions = (instructions) => {
2171
+ let minX = Infinity;
2172
+ let minY = Infinity;
2173
+ let maxX = -Infinity;
2174
+ let maxY = -Infinity;
2175
+ let x = 0;
2176
+ let y = 0;
2177
+ let lastMoveX = 0;
2178
+ let lastMoveY = 0;
2179
+ for (const seg of instructions) {
2180
+ switch (seg.type) {
2181
+ case "M": {
2182
+ lastMoveX = seg.x;
2183
+ lastMoveY = seg.y;
2184
+ if (minX > seg.x) {
2185
+ minX = seg.x;
2186
+ }
2187
+ if (minY > seg.y) {
2188
+ minY = seg.y;
2189
+ }
2190
+ if (maxX < seg.x) {
2191
+ maxX = seg.x;
2192
+ }
2193
+ if (maxY < seg.y) {
2194
+ maxY = seg.y;
2195
+ }
2196
+ x = seg.x;
2197
+ y = seg.y;
2198
+ break;
2199
+ }
2200
+ case "L": {
2201
+ if (minX > seg.x) {
2202
+ minX = seg.x;
2203
+ }
2204
+ if (minY > seg.y) {
2205
+ minY = seg.y;
2206
+ }
2207
+ if (maxX < seg.x) {
2208
+ maxX = seg.x;
2209
+ }
2210
+ if (maxY < seg.y) {
2211
+ maxY = seg.y;
2212
+ }
2213
+ x = seg.x;
2214
+ y = seg.y;
2215
+ break;
2216
+ }
2217
+ case "C": {
2218
+ const cxMinMax = minmaxC([x, seg.cp1x, seg.cp2x, seg.x]);
2219
+ if (minX > cxMinMax[0]) {
2220
+ minX = cxMinMax[0];
2221
+ }
2222
+ if (maxX < cxMinMax[1]) {
2223
+ maxX = cxMinMax[1];
2224
+ }
2225
+ const cyMinMax = minmaxC([y, seg.cp1y, seg.cp2y, seg.y]);
2226
+ if (minY > cyMinMax[0]) {
2227
+ minY = cyMinMax[0];
2228
+ }
2229
+ if (maxY < cyMinMax[1]) {
2230
+ maxY = cyMinMax[1];
2231
+ }
2232
+ x = seg.x;
2233
+ y = seg.y;
2234
+ break;
2235
+ }
2236
+ case "Z":
2237
+ x = lastMoveX;
2238
+ y = lastMoveY;
2239
+ break;
2240
+ default:
2241
+ throw new Error(`Unknown instruction ${seg.type}`);
2242
+ }
2243
+ }
2244
+ return {
2245
+ x1: minX,
2246
+ y1: minY,
2247
+ x2: maxX,
2248
+ y2: maxY,
2249
+ viewBox: `${minX} ${minY} ${maxX - minX} ${maxY - minY}`,
2250
+ width: maxX - minX,
2251
+ height: maxY - minY
2252
+ };
2253
+ };
2254
+ var PathInternals = {
2255
+ getBoundingBoxFromInstructions,
2256
+ debugPath,
2257
+ cutPath
2258
+ };
2259
+
2260
+ // src/fix-z.ts
2261
+ var turnInto3D = (instructions) => {
2262
+ let lastMove = [0, 0, 0, 1];
2263
+ const newInstructions = [];
2264
+ const reduced = reduceInstructions(instructions);
2265
+ for (let i = 0;i < reduced.length; i++) {
2266
+ const instruction = reduced[i];
2267
+ if (instruction.type === "Z") {
2268
+ newInstructions.push({
2269
+ type: "Z",
2270
+ point: lastMove
2271
+ });
2272
+ } else if (instruction.type === "M") {
2273
+ lastMove = [instruction.x, instruction.y, 0, 1];
2274
+ newInstructions.push({
2275
+ point: [instruction.x, instruction.y, 0, 1],
2276
+ type: "M"
2277
+ });
2278
+ } else if (instruction.type === "L") {
2279
+ newInstructions.push({
2280
+ type: "L",
2281
+ point: [instruction.x, instruction.y, 0, 1]
2282
+ });
2283
+ } else if (instruction.type === "C") {
2284
+ newInstructions.push({
2285
+ type: "C",
2286
+ point: [instruction.x, instruction.y, 0, 1],
2287
+ cp1: [instruction.cp1x, instruction.cp1y, 0, 1],
2288
+ cp2: [instruction.cp2x, instruction.cp2y, 0, 1]
2289
+ });
2290
+ } else {
2291
+ throw new Error("unknown");
2292
+ }
2293
+ }
2294
+ return newInstructions;
2295
+ };
2296
+
2297
+ // src/map-face.ts
2298
+ var translateSvgInstruction = (instruction, x, y, z) => {
2299
+ if (instruction.type === "M") {
2300
+ return {
2301
+ type: "M",
2302
+ point: [
2303
+ instruction.point[0] + x,
2304
+ instruction.point[1] + y,
2305
+ instruction.point[2] + z,
2306
+ instruction.point[3]
2307
+ ]
2308
+ };
2309
+ }
2310
+ if (instruction.type === "L") {
2311
+ return {
2312
+ type: "L",
2313
+ point: [
2314
+ instruction.point[0] + x,
2315
+ instruction.point[1] + y,
2316
+ instruction.point[2] + z,
2317
+ instruction.point[3]
2318
+ ]
2319
+ };
2320
+ }
2321
+ if (instruction.type === "C") {
2322
+ return {
2323
+ type: "C",
2324
+ point: [
2325
+ instruction.point[0] + x,
2326
+ instruction.point[1] + y,
2327
+ instruction.point[2] + z,
2328
+ instruction.point[3]
2329
+ ],
2330
+ cp1: [
2331
+ instruction.cp1[0] + x,
2332
+ instruction.cp1[1] + y,
2333
+ instruction.cp1[2] + z,
2334
+ instruction.cp1[3]
2335
+ ],
2336
+ cp2: [
2337
+ instruction.cp2[0] + x,
2338
+ instruction.cp2[1] + y,
2339
+ instruction.cp2[2] + z,
2340
+ instruction.cp2[3]
2341
+ ]
2342
+ };
2343
+ }
2344
+ if (instruction.type === "Q") {
2345
+ return {
2346
+ type: "Q",
2347
+ point: [
2348
+ instruction.point[0] + x,
2349
+ instruction.point[1] + y,
2350
+ instruction.point[2] + z,
2351
+ instruction.point[3]
2352
+ ],
2353
+ cp: [
2354
+ instruction.cp[0] + x,
2355
+ instruction.cp[1] + y,
2356
+ instruction.cp[2] + z,
2357
+ instruction.cp[3]
2358
+ ]
2359
+ };
2360
+ }
2361
+ if (instruction.type === "Z") {
2362
+ return {
2363
+ type: "Z",
2364
+ point: [
2365
+ instruction.point[0] + x,
2366
+ instruction.point[1] + y,
2367
+ instruction.point[2] + z,
2368
+ instruction.point[3]
2369
+ ]
2370
+ };
2371
+ }
2372
+ throw new Error("Unknown instruction type: " + JSON.stringify(instruction));
2373
+ };
2374
+ var transformPath = ({
2375
+ path,
2376
+ transformation
2377
+ }) => {
2378
+ const parsed = parsePath(path);
2379
+ const reduced = reduceInstructions(parsed);
2380
+ const threeD = turnInto3D(reduced);
2381
+ return threeDIntoSvgPath(threeD.map((p) => {
2382
+ return multiplyMatrixAndSvgInstruction(transformation, p);
2383
+ }));
2384
+ };
2385
+ var transformFace = (face, transformations) => {
2386
+ return {
2387
+ ...face,
2388
+ points: face.points.map((p) => {
2389
+ return transformations.reduce((acc, t) => {
2390
+ return multiplyMatrixAndSvgInstruction(t, acc);
2391
+ }, p);
2392
+ }),
2393
+ centerPoint: transformations.reduce((acc, t) => {
2394
+ const result = multiplyMatrix(t, acc);
2395
+ return result;
2396
+ }, face.centerPoint)
2397
+ };
2398
+ };
2399
+
2400
+ // src/elements.ts
2401
+ var makeElement = ({
2402
+ face: faces,
2403
+ centerPoint,
2404
+ description
2405
+ }) => {
2406
+ return {
2407
+ faces,
2408
+ id: makeId(),
2409
+ centerPoint,
2410
+ description
2411
+ };
2412
+ };
2413
+ var transformElement = (element, transformations) => {
2414
+ return {
2415
+ ...element,
2416
+ faces: element.faces.map((face) => {
2417
+ return transformFace(face, transformations);
2418
+ }),
2419
+ id: makeId(),
2420
+ centerPoint: transformations.reduce((point, transformation) => multiplyMatrix(transformation, point), element.centerPoint)
2421
+ };
2422
+ };
2423
+ // src/subdivide-instructions.ts
2424
+ var subdivideLOrMInstruction = (from, instruction) => {
2425
+ if (instruction.type !== "L" && instruction.type !== "M") {
2426
+ throw new Error("Expected L or M instruction");
2427
+ }
2428
+ const t = 0.5;
2429
+ const q0 = [
2430
+ (1 - t) * from[0] + t * instruction.point[0],
2431
+ (1 - t) * from[1] + t * instruction.point[1],
2432
+ (1 - t) * from[2] + t * instruction.point[2],
2433
+ (1 - t) * from[3] + t * instruction.point[3]
2434
+ ];
2435
+ const curves = [
2436
+ { type: instruction.type, point: q0 },
2437
+ { type: instruction.type, point: instruction.point }
2438
+ ];
2439
+ return curves;
2440
+ };
2441
+ var subdivide3DCInstruction = (from, instruction) => {
2442
+ if (instruction.type !== "C") {
2443
+ throw new Error("Expected C instruction");
2444
+ }
2445
+ const t = 0.5;
2446
+ const q0 = [
2447
+ (1 - t) * from[0] + t * instruction.cp1[0],
2448
+ (1 - t) * from[1] + t * instruction.cp1[1],
2449
+ (1 - t) * from[2] + t * instruction.cp1[2],
2450
+ (1 - t) * from[3] + t * instruction.cp1[3]
2451
+ ];
2452
+ const q1 = [
2453
+ (1 - t) * instruction.cp1[0] + t * instruction.cp2[0],
2454
+ (1 - t) * instruction.cp1[1] + t * instruction.cp2[1],
2455
+ (1 - t) * instruction.cp1[2] + t * instruction.cp2[2],
2456
+ (1 - t) * instruction.cp1[3] + t * instruction.cp2[3]
2457
+ ];
2458
+ const q2 = [
2459
+ (1 - t) * instruction.cp2[0] + t * instruction.point[0],
2460
+ (1 - t) * instruction.cp2[1] + t * instruction.point[1],
2461
+ (1 - t) * instruction.cp2[2] + t * instruction.point[2],
2462
+ (1 - t) * instruction.cp2[3] + t * instruction.point[3]
2463
+ ];
2464
+ const r0 = [
2465
+ (1 - t) * q0[0] + t * q1[0],
2466
+ (1 - t) * q0[1] + t * q1[1],
2467
+ (1 - t) * q0[2] + t * q1[2],
2468
+ (1 - t) * q0[3] + t * q1[3]
2469
+ ];
2470
+ const r1 = [
2471
+ (1 - t) * q1[0] + t * q2[0],
2472
+ (1 - t) * q1[1] + t * q2[1],
2473
+ (1 - t) * q1[2] + t * q2[2],
2474
+ (1 - t) * q1[3] + t * q2[3]
2475
+ ];
2476
+ const s0 = [
2477
+ (1 - t) * r0[0] + t * r1[0],
2478
+ (1 - t) * r0[1] + t * r1[1],
2479
+ (1 - t) * r0[2] + t * r1[2],
2480
+ (1 - t) * r0[3] + t * r1[3]
2481
+ ];
2482
+ const curves = [
2483
+ { type: "C", point: s0, cp1: q0, cp2: r0 },
2484
+ { type: "C", point: instruction.point, cp1: r1, cp2: q2 }
2485
+ ];
2486
+ return curves;
2487
+ };
2488
+ var subdivideQInstruction = (from, instruction) => {
2489
+ if (instruction.type !== "Q") {
2490
+ throw new Error("Expected Q instruction");
2491
+ }
2492
+ const t = 0.5;
2493
+ const q0 = [
2494
+ (1 - t) * from[0] + t * instruction.cp[0],
2495
+ (1 - t) * from[1] + t * instruction.cp[1],
2496
+ (1 - t) * from[2] + t * instruction.cp[2],
2497
+ (1 - t) * from[3] + t * instruction.cp[3]
2498
+ ];
2499
+ const q1 = [
2500
+ (1 - t) * instruction.cp[0] + t * instruction.point[0],
2501
+ (1 - t) * instruction.cp[1] + t * instruction.point[1],
2502
+ (1 - t) * instruction.cp[2] + t * instruction.point[2],
2503
+ (1 - t) * instruction.cp[3] + t * instruction.point[3]
2504
+ ];
2505
+ const r0 = [
2506
+ (1 - t) * q0[0] + t * q1[0],
2507
+ (1 - t) * q0[1] + t * q1[1],
2508
+ (1 - t) * q0[2] + t * q1[2],
2509
+ (1 - t) * q0[3] + t * q1[3]
2510
+ ];
2511
+ const newInstructions = [
2512
+ { type: "Q", point: r0, cp: q0 },
2513
+ { type: "Q", point: instruction.point, cp: q1 }
2514
+ ];
2515
+ return newInstructions;
2516
+ };
2517
+ var subdivideInstruction = (from, instruction) => {
2518
+ if (instruction.type === "C") {
2519
+ return subdivide3DCInstruction(from, instruction);
2520
+ }
2521
+ if (instruction.type === "L" || instruction.type === "M") {
2522
+ return subdivideLOrMInstruction(from, instruction);
2523
+ }
2524
+ if (instruction.type === "Q") {
2525
+ return subdivideQInstruction(from, instruction);
2526
+ }
2527
+ if (instruction.type === "Z") {
2528
+ return [instruction];
2529
+ }
2530
+ throw new Error("Cannot subdivide instruction");
2531
+ };
2532
+ var subdivideInstructions = (instructions) => {
2533
+ const newInstructions = [];
2534
+ instructions.forEach((instruction, i) => {
2535
+ if (instruction.type === "M") {
2536
+ newInstructions.push(instruction);
2537
+ return;
2538
+ }
2539
+ if (instruction.type === "Z") {
2540
+ newInstructions.push(instruction);
2541
+ return;
2542
+ }
2543
+ const previousInstruction = instructions[i - 1];
2544
+ const subdivided = subdivideInstruction(previousInstruction.point, instruction);
2545
+ newInstructions.push(...subdivided);
2546
+ });
2547
+ return newInstructions;
2548
+ };
2549
+
2550
+ // src/truthy.ts
2551
+ function truthy(value) {
2552
+ return Boolean(value);
2553
+ }
2554
+
2555
+ // src/extrude-element.ts
2556
+ var inverseInstruction = (instruction, comingFrom) => {
2557
+ if (instruction.type === "M") {
2558
+ return {
2559
+ type: "M",
2560
+ point: comingFrom
2561
+ };
2562
+ }
2563
+ if (instruction.type === "L") {
2564
+ return {
2565
+ type: "L",
2566
+ point: comingFrom
2567
+ };
2568
+ }
2569
+ if (instruction.type === "C") {
2570
+ return {
2571
+ type: "C",
2572
+ point: comingFrom,
2573
+ cp1: instruction.cp2,
2574
+ cp2: instruction.cp1
2575
+ };
2576
+ }
2577
+ if (instruction.type === "Q") {
2578
+ return {
2579
+ type: "Q",
2580
+ point: comingFrom,
2581
+ cp: instruction.cp
2582
+ };
2583
+ }
2584
+ if (instruction.type === "Z") {
2585
+ return {
2586
+ type: "L",
2587
+ point: comingFrom
2588
+ };
2589
+ }
2590
+ throw new Error("Unknown instruction type");
2591
+ };
2592
+ var extrudeElement = ({
2593
+ depth,
2594
+ sideColor,
2595
+ frontFaceColor,
2596
+ backFaceColor,
2597
+ points,
2598
+ strokeWidth,
2599
+ description = "extruded",
2600
+ strokeColor,
2601
+ crispEdges
2602
+ }) => {
2603
+ const boundingBox = PathInternals.getBoundingBoxFromInstructions(reduceInstructions(points));
2604
+ const centerX = (boundingBox.x2 - boundingBox.x1) / 2 + boundingBox.x1;
2605
+ const centerY = (boundingBox.y2 - boundingBox.y1) / 2 + boundingBox.y1;
2606
+ const threeD = turnInto3D(points);
2607
+ const instructions = {
2608
+ centerPoint: [0, 0, 0, 1],
2609
+ points: subdivideInstructions(subdivideInstructions(subdivideInstructions(threeD))),
2610
+ strokeWidth,
2611
+ strokeColor,
2612
+ color: "black",
2613
+ description: description ?? "extruded",
2614
+ crispEdges
2615
+ };
2616
+ const unscaledBackFace = transformFace(instructions, []);
2617
+ const unscaledFrontFace = transformFace(instructions, [translateZ(-depth)]);
2618
+ const inbetween = unscaledBackFace.points.map((t, i) => {
2619
+ const nextInstruction = i === unscaledBackFace.points.length - 1 ? unscaledBackFace.points[0] : unscaledBackFace.points[i + 1];
2620
+ const currentPoint = t.point;
2621
+ const nextPoint = nextInstruction.point;
2622
+ const movingOver = [
2623
+ nextPoint[0],
2624
+ nextPoint[1],
2625
+ nextPoint[2] - depth,
2626
+ nextPoint[3]
2627
+ ];
2628
+ const translatedInstruction = translateSvgInstruction(inverseInstruction(nextInstruction, currentPoint), 0, 0, -depth);
2629
+ const newInstructions = [
2630
+ {
2631
+ type: "M",
2632
+ point: currentPoint
2633
+ },
2634
+ nextInstruction,
2635
+ nextInstruction.type === "Z" ? {
2636
+ type: "M",
2637
+ point: nextInstruction.point
2638
+ } : null,
2639
+ {
2640
+ type: "L",
2641
+ point: movingOver
2642
+ },
2643
+ translatedInstruction,
2644
+ {
2645
+ type: "L",
2646
+ point: currentPoint
2647
+ }
2648
+ ].filter(truthy);
2649
+ return {
2650
+ points: newInstructions,
2651
+ color: sideColor,
2652
+ centerPoint: [0, 0, 0, 1],
2653
+ strokeWidth: 0,
2654
+ strokeColor: "black",
2655
+ description: description + "inbetween",
2656
+ crispEdges: true
2657
+ };
2658
+ });
2659
+ const scaledFrontFace = {
2660
+ ...unscaledFrontFace,
2661
+ color: frontFaceColor,
2662
+ description: description + "(front)"
2663
+ };
2664
+ const scaledBackFace = {
2665
+ ...unscaledBackFace,
2666
+ color: backFaceColor,
2667
+ description: description + "(back)"
2668
+ };
2669
+ return makeElement({
2670
+ face: [...inbetween, scaledFrontFace, scaledBackFace],
2671
+ centerPoint: [centerX, centerY, 0, 1],
2672
+ description
2673
+ });
2674
+ };
2675
+ var extrudeAndTransformElement = (options) => {
2676
+ return transformElement(extrudeElement(options), [options.transformations]);
2677
+ };
2678
+ export {
2679
+ translateZ,
2680
+ translateY,
2681
+ translateX,
2682
+ transformPath,
2683
+ transformElement,
2684
+ threeDIntoSvgPath,
2685
+ scaled,
2686
+ rotateZ,
2687
+ rotateY,
2688
+ rotateX,
2689
+ reduceMatrices,
2690
+ makeMatrix3dTransform,
2691
+ interpolateMatrix4d,
2692
+ extrudeElement,
2693
+ extrudeAndTransformElement
2694
+ };