@sarmal/core 0.26.0 → 0.27.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/dist/auto-init.cjs +145 -106
- package/dist/auto-init.js +144 -105
- package/dist/cli.js +1048 -0
- package/dist/cli.js.map +1 -0
- package/dist/curves/artemis2.cjs +16 -10
- package/dist/curves/artemis2.d.cts +1 -1
- package/dist/curves/artemis2.d.ts +1 -1
- package/dist/curves/artemis2.js +15 -9
- package/dist/curves/astroid.cjs +4 -4
- package/dist/curves/astroid.d.cts +1 -1
- package/dist/curves/astroid.d.ts +1 -1
- package/dist/curves/astroid.js +3 -3
- package/dist/curves/deltoid.cjs +4 -4
- package/dist/curves/deltoid.d.cts +1 -1
- package/dist/curves/deltoid.d.ts +1 -1
- package/dist/curves/deltoid.js +3 -3
- package/dist/curves/epicycloid3.cjs +4 -4
- package/dist/curves/epicycloid3.d.cts +1 -1
- package/dist/curves/epicycloid3.d.ts +1 -1
- package/dist/curves/epicycloid3.js +3 -3
- package/dist/curves/epitrochoid7.cjs +5 -5
- package/dist/curves/epitrochoid7.d.cts +1 -1
- package/dist/curves/epitrochoid7.d.ts +1 -1
- package/dist/curves/epitrochoid7.js +4 -4
- package/dist/curves/index.cjs +59 -43
- package/dist/curves/index.d.cts +29 -29
- package/dist/curves/index.d.ts +29 -29
- package/dist/curves/index.js +75 -43
- package/dist/curves/lame.cjs +6 -5
- package/dist/curves/lame.d.cts +1 -1
- package/dist/curves/lame.d.ts +1 -1
- package/dist/curves/lame.js +5 -4
- package/dist/curves/lissajous32.cjs +4 -4
- package/dist/curves/lissajous32.d.cts +1 -1
- package/dist/curves/lissajous32.d.ts +1 -1
- package/dist/curves/lissajous32.js +3 -3
- package/dist/curves/lissajous43.cjs +4 -4
- package/dist/curves/lissajous43.d.cts +1 -1
- package/dist/curves/lissajous43.d.ts +1 -1
- package/dist/curves/lissajous43.js +3 -3
- package/dist/curves/rose3.cjs +4 -4
- package/dist/curves/rose3.d.cts +1 -1
- package/dist/curves/rose3.d.ts +1 -1
- package/dist/curves/rose3.js +3 -3
- package/dist/curves/rose5.cjs +4 -4
- package/dist/curves/rose5.d.cts +1 -1
- package/dist/curves/rose5.d.ts +1 -1
- package/dist/curves/rose5.js +3 -3
- package/dist/curves/rose52.cjs +5 -5
- package/dist/curves/rose52.d.cts +1 -1
- package/dist/curves/rose52.d.ts +1 -1
- package/dist/curves/rose52.js +4 -4
- package/dist/curves/star.cjs +8 -5
- package/dist/curves/star.d.cts +1 -1
- package/dist/curves/star.d.ts +1 -1
- package/dist/curves/star.js +7 -4
- package/dist/curves/star4.cjs +8 -5
- package/dist/curves/star4.d.cts +1 -1
- package/dist/curves/star4.d.ts +1 -1
- package/dist/curves/star4.js +7 -4
- package/dist/curves/star7.cjs +8 -5
- package/dist/curves/star7.d.cts +1 -1
- package/dist/curves/star7.d.ts +1 -1
- package/dist/curves/star7.js +7 -4
- package/dist/index.cjs +131 -94
- package/dist/index.d.cts +78 -58
- package/dist/index.d.ts +78 -58
- package/dist/index.js +152 -94
- package/dist/renderer-shared-OR--cv-t.d.ts +49 -0
- package/dist/renderer-shared-jqw_Q1WO.d.cts +49 -0
- package/dist/terminal.cjs +593 -0
- package/dist/terminal.cjs.map +1 -0
- package/dist/terminal.d.cts +44 -0
- package/dist/terminal.d.ts +44 -0
- package/dist/terminal.js +585 -0
- package/dist/terminal.js.map +1 -0
- package/dist/types-zbxUgcmZ.d.cts +280 -266
- package/dist/types-zbxUgcmZ.d.ts +280 -266
- package/package.json +11 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
// src/engine.ts
|
|
4
4
|
var TWO_PI = Math.PI * 2;
|
|
@@ -63,13 +63,13 @@ function resolveCurve(curveDef) {
|
|
|
63
63
|
period,
|
|
64
64
|
speed,
|
|
65
65
|
skeleton: curveDef.skeleton,
|
|
66
|
-
skeletonFn: curveDef.skeletonFn
|
|
66
|
+
skeletonFn: curveDef.skeletonFn,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
function createEngine(curveDef, trailLength = 120) {
|
|
70
70
|
if (!Number.isFinite(trailLength) || trailLength <= 0) {
|
|
71
71
|
throw new RangeError(
|
|
72
|
-
`[sarmal] trailLength must be a positive finite number, got ${trailLength}
|
|
72
|
+
`[sarmal] trailLength must be a positive finite number, got ${trailLength}`,
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
let curve = resolveCurve(curveDef);
|
|
@@ -110,7 +110,8 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
110
110
|
actualTime += deltaTime;
|
|
111
111
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
112
112
|
const a = curve.fn(phase, actualTime, EMPTY_PARAMS);
|
|
113
|
-
const phaseB =
|
|
113
|
+
const phaseB =
|
|
114
|
+
_morphStrategy === "normalized" ? (phase / curve.period) * morphCurveB.period : phase;
|
|
114
115
|
const b = morphCurveB.fn(phaseB, actualTime, EMPTY_PARAMS);
|
|
115
116
|
trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
|
|
116
117
|
} else {
|
|
@@ -137,14 +138,14 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
137
138
|
trail.clear();
|
|
138
139
|
},
|
|
139
140
|
jump(newPhase, { clearTrail = false } = {}) {
|
|
140
|
-
phase = (newPhase % curve.period + curve.period) % curve.period;
|
|
141
|
+
phase = ((newPhase % curve.period) + curve.period) % curve.period;
|
|
141
142
|
if (clearTrail) {
|
|
142
143
|
trail.clear();
|
|
143
144
|
}
|
|
144
145
|
},
|
|
145
146
|
seek(targetPhase, { wrap = false, step = curve.period / trailLength } = {}) {
|
|
146
147
|
const advance = curve.speed * step;
|
|
147
|
-
const target = (targetPhase % curve.period + curve.period) % curve.period;
|
|
148
|
+
const target = ((targetPhase % curve.period) + curve.period) % curve.period;
|
|
148
149
|
const targetTime = target / curve.speed;
|
|
149
150
|
phase = target;
|
|
150
151
|
actualTime = targetTime;
|
|
@@ -153,7 +154,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
153
154
|
const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
|
|
154
155
|
for (let i = count - 1; i >= 0; i--) {
|
|
155
156
|
const samplePhase = target - i * advance;
|
|
156
|
-
const wrappedPhase = (samplePhase % curve.period + curve.period) % curve.period;
|
|
157
|
+
const wrappedPhase = ((samplePhase % curve.period) + curve.period) % curve.period;
|
|
157
158
|
const elapsed = targetTime - i * step;
|
|
158
159
|
const point = curve.fn(wrappedPhase, elapsed, EMPTY_PARAMS);
|
|
159
160
|
trail.push(point.x, point.y);
|
|
@@ -170,13 +171,16 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
170
171
|
...frozenB,
|
|
171
172
|
fn: (samplePhase, elapsed, params) => {
|
|
172
173
|
const a = frozenA.fn(samplePhase, elapsed, params);
|
|
173
|
-
const phaseB =
|
|
174
|
+
const phaseB =
|
|
175
|
+
frozenStrategy === "normalized"
|
|
176
|
+
? (samplePhase / frozenA.period) * frozenB.period
|
|
177
|
+
: samplePhase;
|
|
174
178
|
const b = frozenB.fn(phaseB, elapsed, params);
|
|
175
179
|
return {
|
|
176
180
|
x: a.x + (b.x - a.x) * frozenAlpha,
|
|
177
|
-
y: a.y + (b.y - a.y) * frozenAlpha
|
|
181
|
+
y: a.y + (b.y - a.y) * frozenAlpha,
|
|
178
182
|
};
|
|
179
|
-
}
|
|
183
|
+
},
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
186
|
_morphStrategy = strategy;
|
|
@@ -189,7 +193,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
189
193
|
completeMorph() {
|
|
190
194
|
if (morphCurveB !== null) {
|
|
191
195
|
if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
|
|
192
|
-
phase = phase / curve.period * morphCurveB.period;
|
|
196
|
+
phase = (phase / curve.period) * morphCurveB.period;
|
|
193
197
|
}
|
|
194
198
|
curve = morphCurveB;
|
|
195
199
|
}
|
|
@@ -201,19 +205,22 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
201
205
|
const points2 = new Array(steps);
|
|
202
206
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
203
207
|
for (let i = 0; i < steps; i++) {
|
|
204
|
-
const samplePhase = i / (steps - 1) * curve.period;
|
|
208
|
+
const samplePhase = (i / (steps - 1)) * curve.period;
|
|
205
209
|
const a = sampleSkeleton(curve, samplePhase);
|
|
206
|
-
const phaseB =
|
|
210
|
+
const phaseB =
|
|
211
|
+
_morphStrategy === "normalized"
|
|
212
|
+
? (samplePhase / curve.period) * morphCurveB.period
|
|
213
|
+
: samplePhase;
|
|
207
214
|
const b = sampleSkeleton(morphCurveB, phaseB);
|
|
208
215
|
points2[i] = {
|
|
209
216
|
x: a.x + (b.x - a.x) * _morphAlpha,
|
|
210
|
-
y: a.y + (b.y - a.y) * _morphAlpha
|
|
217
|
+
y: a.y + (b.y - a.y) * _morphAlpha,
|
|
211
218
|
};
|
|
212
219
|
}
|
|
213
220
|
return points2;
|
|
214
221
|
}
|
|
215
222
|
for (let i = 0; i < steps; i++) {
|
|
216
|
-
const samplePhase = i / (steps - 1) * curve.period;
|
|
223
|
+
const samplePhase = (i / (steps - 1)) * curve.period;
|
|
217
224
|
points2[i] = sampleSkeleton(curve, samplePhase);
|
|
218
225
|
}
|
|
219
226
|
return points2;
|
|
@@ -255,7 +262,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
255
262
|
_speedTransition.reject(new Error("Speed transition cancelled"));
|
|
256
263
|
_speedTransition = null;
|
|
257
264
|
}
|
|
258
|
-
}
|
|
265
|
+
},
|
|
259
266
|
};
|
|
260
267
|
}
|
|
261
268
|
|
|
@@ -294,7 +301,15 @@ function computeNormal(trail, i) {
|
|
|
294
301
|
const tangent = computeTangent(trail, i);
|
|
295
302
|
return { x: -tangent.y, y: tangent.x };
|
|
296
303
|
}
|
|
297
|
-
function computeTrailQuad(
|
|
304
|
+
function computeTrailQuad(
|
|
305
|
+
trail,
|
|
306
|
+
i,
|
|
307
|
+
trailCount,
|
|
308
|
+
toX,
|
|
309
|
+
toY,
|
|
310
|
+
minWidth = TRAIL_MIN_WIDTH,
|
|
311
|
+
maxWidth = TRAIL_MAX_WIDTH,
|
|
312
|
+
) {
|
|
298
313
|
const progress = i / (trailCount - 1);
|
|
299
314
|
const nextProgress = (i + 1) / (trailCount - 1);
|
|
300
315
|
const opacity = Math.pow(progress, TRAIL_FADE_CURVE) * TRAIL_MAX_OPACITY;
|
|
@@ -318,13 +333,16 @@ function computeTrailQuad(trail, i, trailCount, toX, toY, minWidth = TRAIL_MIN_W
|
|
|
318
333
|
r1x: nx - n1.x * w1,
|
|
319
334
|
r1y: ny - n1.y * w1,
|
|
320
335
|
opacity,
|
|
321
|
-
progress
|
|
336
|
+
progress,
|
|
322
337
|
};
|
|
323
338
|
}
|
|
324
339
|
function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_PADDING_MIN) {
|
|
325
340
|
if (pts.length === 0) return null;
|
|
326
341
|
const first = pts[0];
|
|
327
|
-
let minX = first.x,
|
|
342
|
+
let minX = first.x,
|
|
343
|
+
maxX = first.x,
|
|
344
|
+
minY = first.y,
|
|
345
|
+
maxY = first.y;
|
|
328
346
|
for (const p of pts) {
|
|
329
347
|
if (p.x < minX) {
|
|
330
348
|
minX = p.x;
|
|
@@ -343,7 +361,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
343
361
|
const h = maxY - minY;
|
|
344
362
|
if (w === 0 && h === 0) {
|
|
345
363
|
throw new Error(
|
|
346
|
-
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
364
|
+
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t.",
|
|
347
365
|
);
|
|
348
366
|
}
|
|
349
367
|
const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
|
|
@@ -354,12 +372,12 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
354
372
|
scaleXProportional,
|
|
355
373
|
scaleYProportional,
|
|
356
374
|
scaleXMinPadding,
|
|
357
|
-
scaleYMinPadding
|
|
375
|
+
scaleYMinPadding,
|
|
358
376
|
);
|
|
359
377
|
return {
|
|
360
378
|
scale,
|
|
361
379
|
offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
|
|
362
|
-
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
380
|
+
offsetY: (logicalHeight - h * scale) / 2 - minY * scale,
|
|
363
381
|
};
|
|
364
382
|
}
|
|
365
383
|
function enginePassthroughs(engine) {
|
|
@@ -370,7 +388,7 @@ function enginePassthroughs(engine) {
|
|
|
370
388
|
getSpeed: engine.getSpeed,
|
|
371
389
|
resetSpeed: engine.resetSpeed,
|
|
372
390
|
setSpeedOver: engine.setSpeedOver,
|
|
373
|
-
getSarmalSkeleton: engine.getSarmalSkeleton
|
|
391
|
+
getSarmalSkeleton: engine.getSarmalSkeleton,
|
|
374
392
|
};
|
|
375
393
|
}
|
|
376
394
|
var palettes = {
|
|
@@ -379,16 +397,16 @@ var palettes = {
|
|
|
379
397
|
ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"],
|
|
380
398
|
ice: ["#1e3a8a", "#67e8f9"],
|
|
381
399
|
fire: ["#7f1d1d", "#fbbf24"],
|
|
382
|
-
forest: ["#14532d", "#86efac"]
|
|
400
|
+
forest: ["#14532d", "#86efac"],
|
|
383
401
|
};
|
|
384
402
|
function hexToRgb(hex) {
|
|
385
403
|
const n = parseInt(hex.slice(1), 16);
|
|
386
|
-
return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
|
|
404
|
+
return { r: n >> 16, g: (n >> 8) & 255, b: n & 255 };
|
|
387
405
|
}
|
|
388
406
|
var lerpRgb = (a, b, t) => ({
|
|
389
407
|
r: Math.round(a.r + (b.r - a.r) * t),
|
|
390
408
|
g: Math.round(a.g + (b.g - a.g) * t),
|
|
391
|
-
b: Math.round(a.b + (b.b - a.b) * t)
|
|
409
|
+
b: Math.round(a.b + (b.b - a.b) * t),
|
|
392
410
|
});
|
|
393
411
|
function getPaletteColor(palette, position, timeOffset = 0) {
|
|
394
412
|
if (palette.length === 0) {
|
|
@@ -397,7 +415,7 @@ function getPaletteColor(palette, position, timeOffset = 0) {
|
|
|
397
415
|
if (palette.length === 1) {
|
|
398
416
|
return hexToRgb(palette[0]);
|
|
399
417
|
}
|
|
400
|
-
const cyclePos = ((position + timeOffset) % 1 + 1) % 1;
|
|
418
|
+
const cyclePos = (((position + timeOffset) % 1) + 1) % 1;
|
|
401
419
|
const scaled = cyclePos * palette.length;
|
|
402
420
|
const idx = Math.floor(scaled);
|
|
403
421
|
const t = scaled - idx;
|
|
@@ -412,7 +430,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
|
412
430
|
"headColor",
|
|
413
431
|
"skeletonColor",
|
|
414
432
|
"trailStyle",
|
|
415
|
-
"headRadius"
|
|
433
|
+
"headRadius",
|
|
416
434
|
]);
|
|
417
435
|
function validateRenderOptions(partial) {
|
|
418
436
|
for (const key of Object.keys(partial)) {
|
|
@@ -440,7 +458,7 @@ function assertTrailColor(value) {
|
|
|
440
458
|
if (typeof value === "string") {
|
|
441
459
|
if (!HEX_COLOR_RE.test(value)) {
|
|
442
460
|
throw new TypeError(
|
|
443
|
-
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"
|
|
461
|
+
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`,
|
|
444
462
|
);
|
|
445
463
|
}
|
|
446
464
|
return;
|
|
@@ -448,21 +466,21 @@ function assertTrailColor(value) {
|
|
|
448
466
|
if (Array.isArray(value)) {
|
|
449
467
|
if (value.length < 2) {
|
|
450
468
|
throw new RangeError(
|
|
451
|
-
`[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}
|
|
469
|
+
`[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`,
|
|
452
470
|
);
|
|
453
471
|
}
|
|
454
472
|
for (let i = 0; i < value.length; i++) {
|
|
455
473
|
const entry = value[i];
|
|
456
474
|
if (typeof entry !== "string" || !HEX_COLOR_RE.test(entry)) {
|
|
457
475
|
throw new TypeError(
|
|
458
|
-
`[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}
|
|
476
|
+
`[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`,
|
|
459
477
|
);
|
|
460
478
|
}
|
|
461
479
|
}
|
|
462
480
|
return;
|
|
463
481
|
}
|
|
464
482
|
throw new TypeError(
|
|
465
|
-
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}
|
|
483
|
+
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`,
|
|
466
484
|
);
|
|
467
485
|
}
|
|
468
486
|
function assertHeadColor(value) {
|
|
@@ -471,7 +489,7 @@ function assertHeadColor(value) {
|
|
|
471
489
|
}
|
|
472
490
|
if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
|
|
473
491
|
throw new TypeError(
|
|
474
|
-
`[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}
|
|
492
|
+
`[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`,
|
|
475
493
|
);
|
|
476
494
|
}
|
|
477
495
|
}
|
|
@@ -481,26 +499,26 @@ function assertSkeletonColor(value) {
|
|
|
481
499
|
}
|
|
482
500
|
if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
|
|
483
501
|
throw new TypeError(
|
|
484
|
-
`[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}
|
|
502
|
+
`[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`,
|
|
485
503
|
);
|
|
486
504
|
}
|
|
487
505
|
}
|
|
488
506
|
function assertTrailStyle(value) {
|
|
489
507
|
if (!TRAIL_STYLES.includes(value)) {
|
|
490
508
|
throw new RangeError(
|
|
491
|
-
`[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}
|
|
509
|
+
`[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`,
|
|
492
510
|
);
|
|
493
511
|
}
|
|
494
512
|
}
|
|
495
513
|
function assertHeadRadius(value) {
|
|
496
514
|
if (typeof value !== "number") {
|
|
497
515
|
throw new TypeError(
|
|
498
|
-
`[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}
|
|
516
|
+
`[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`,
|
|
499
517
|
);
|
|
500
518
|
}
|
|
501
519
|
if (!Number.isFinite(value) || value <= 0) {
|
|
502
520
|
throw new TypeError(
|
|
503
|
-
`[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}
|
|
521
|
+
`[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`,
|
|
504
522
|
);
|
|
505
523
|
}
|
|
506
524
|
}
|
|
@@ -522,13 +540,13 @@ function resolveHeadColor(trailColor, trailStyle) {
|
|
|
522
540
|
function warnIfTrailColorMismatch(trailColor, trailStyle) {
|
|
523
541
|
if (trailStyle === "default" && Array.isArray(trailColor)) {
|
|
524
542
|
console.warn(
|
|
525
|
-
'[sarmal] trailColor is an array but trailStyle is "default"; only the first color will be used. Pass a gradient trailStyle to use the whole palette.'
|
|
543
|
+
'[sarmal] trailColor is an array but trailStyle is "default"; only the first color will be used. Pass a gradient trailStyle to use the whole palette.',
|
|
526
544
|
);
|
|
527
545
|
return;
|
|
528
546
|
}
|
|
529
547
|
if (trailStyle !== "default" && typeof trailColor === "string") {
|
|
530
548
|
console.warn(
|
|
531
|
-
`[sarmal] trailColor is a single color but trailStyle is "${trailStyle}"; the trail will render as a solid color. Pass an array of hex colors to use a real gradient
|
|
549
|
+
`[sarmal] trailColor is a single color but trailStyle is "${trailStyle}"; the trail will render as a solid color. Pass an array of hex colors to use a real gradient.`,
|
|
532
550
|
);
|
|
533
551
|
}
|
|
534
552
|
}
|
|
@@ -538,7 +556,7 @@ var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160)
|
|
|
538
556
|
var WHITE_HEX = "#ffffff";
|
|
539
557
|
function hexToRgbComponents(hex) {
|
|
540
558
|
const n = parseInt(hex.slice(1), 16);
|
|
541
|
-
return `${n >> 16},${n >> 8 & 255},${n & 255}`;
|
|
559
|
+
return `${n >> 16},${(n >> 8) & 255},${n & 255}`;
|
|
542
560
|
}
|
|
543
561
|
function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
|
|
544
562
|
target.style.width = `${logicalWidth}px`;
|
|
@@ -665,7 +683,7 @@ function createRenderer(options) {
|
|
|
665
683
|
i,
|
|
666
684
|
trailCount,
|
|
667
685
|
toX,
|
|
668
|
-
toY
|
|
686
|
+
toY,
|
|
669
687
|
);
|
|
670
688
|
if (trailStyle === "default") {
|
|
671
689
|
ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
|
|
@@ -830,7 +848,7 @@ function createRenderer(options) {
|
|
|
830
848
|
if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
|
|
831
849
|
warnIfTrailColorMismatch(trailColor, trailStyle);
|
|
832
850
|
}
|
|
833
|
-
}
|
|
851
|
+
},
|
|
834
852
|
};
|
|
835
853
|
const pauseOnHidden = options.pauseOnHidden !== false;
|
|
836
854
|
function handleVisibilityChange() {
|
|
@@ -880,8 +898,10 @@ function sampleCurveSkeleton(curveDef) {
|
|
|
880
898
|
const samples = Math.ceil(period * 50);
|
|
881
899
|
const pts = Array.from({ length: samples });
|
|
882
900
|
for (let i = 0; i < samples; i++) {
|
|
883
|
-
const phase = i / (samples - 1) * period;
|
|
884
|
-
pts[i] = curveDef.skeletonFn
|
|
901
|
+
const phase = (i / (samples - 1)) * period;
|
|
902
|
+
pts[i] = curveDef.skeletonFn
|
|
903
|
+
? curveDef.skeletonFn(phase)
|
|
904
|
+
: curveDef.fn(phase, 0, EMPTY_PARAMS2);
|
|
885
905
|
}
|
|
886
906
|
return pts;
|
|
887
907
|
}
|
|
@@ -893,7 +913,7 @@ function createSVGRenderer(options) {
|
|
|
893
913
|
const poolSize = engine.trailLength;
|
|
894
914
|
if (poolSize > HIGH_TRAIL_LENGTH_THRESHOLD) {
|
|
895
915
|
console.warn(
|
|
896
|
-
`[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails
|
|
916
|
+
`[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails.`,
|
|
897
917
|
);
|
|
898
918
|
}
|
|
899
919
|
let trailStyle = options.trailStyle ?? "default";
|
|
@@ -912,9 +932,9 @@ function createSVGRenderer(options) {
|
|
|
912
932
|
return rect.width && rect.height ? Math.min(rect.width, rect.height) : 200;
|
|
913
933
|
}
|
|
914
934
|
const containerPx = getContainerPixelSize();
|
|
915
|
-
const svgTrailMinWidth = TRAIL_MIN_WIDTH * viewSize / containerPx;
|
|
916
|
-
const svgTrailMaxWidth = TRAIL_MAX_WIDTH * viewSize / containerPx;
|
|
917
|
-
const svgSkeletonStrokeWidth = String(SKELETON_STROKE_WIDTH_PX * viewSize / containerPx);
|
|
935
|
+
const svgTrailMinWidth = (TRAIL_MIN_WIDTH * viewSize) / containerPx;
|
|
936
|
+
const svgTrailMaxWidth = (TRAIL_MAX_WIDTH * viewSize) / containerPx;
|
|
937
|
+
const svgSkeletonStrokeWidth = String((SKELETON_STROKE_WIDTH_PX * viewSize) / containerPx);
|
|
918
938
|
headRadius = options.headRadius ?? SVG_DEFAULT_HEAD_RADIUS;
|
|
919
939
|
container.setAttribute("viewBox", `0 0 ${viewSize} ${viewSize}`);
|
|
920
940
|
container.setAttribute("role", "img");
|
|
@@ -1002,7 +1022,7 @@ function createSVGRenderer(options) {
|
|
|
1002
1022
|
px,
|
|
1003
1023
|
py,
|
|
1004
1024
|
svgTrailMinWidth,
|
|
1005
|
-
svgTrailMaxWidth
|
|
1025
|
+
svgTrailMaxWidth,
|
|
1006
1026
|
);
|
|
1007
1027
|
const d = `M${l0x.toFixed(2)} ${l0y.toFixed(2)} L${l1x.toFixed(2)} ${l1y.toFixed(2)} L${r1x.toFixed(2)} ${r1y.toFixed(2)} L${r0x.toFixed(2)} ${r0y.toFixed(2)} Z`;
|
|
1008
1028
|
trailPaths[i].setAttribute("d", d);
|
|
@@ -1030,7 +1050,8 @@ function createSVGRenderer(options) {
|
|
|
1030
1050
|
let animationId = null;
|
|
1031
1051
|
let lastTime = 0;
|
|
1032
1052
|
let pausedByVisibility = false;
|
|
1033
|
-
const prefersReducedMotion =
|
|
1053
|
+
const prefersReducedMotion =
|
|
1054
|
+
typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1034
1055
|
let morphResolve = null;
|
|
1035
1056
|
let morphReject = null;
|
|
1036
1057
|
let morphDurationMs = DEFAULT_MORPH_DURATION_MS;
|
|
@@ -1048,7 +1069,7 @@ function createSVGRenderer(options) {
|
|
|
1048
1069
|
skeletonPathA.setAttribute("visibility", "visible");
|
|
1049
1070
|
skeletonPathA.setAttribute(
|
|
1050
1071
|
"stroke-opacity",
|
|
1051
|
-
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY)
|
|
1072
|
+
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY),
|
|
1052
1073
|
);
|
|
1053
1074
|
}
|
|
1054
1075
|
if (morphPathBBuilt) {
|
|
@@ -1202,7 +1223,7 @@ function createSVGRenderer(options) {
|
|
|
1202
1223
|
if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
|
|
1203
1224
|
warnIfTrailColorMismatch(trailColor, trailStyle);
|
|
1204
1225
|
}
|
|
1205
|
-
}
|
|
1226
|
+
},
|
|
1206
1227
|
};
|
|
1207
1228
|
const pauseOnHidden = options.pauseOnHidden !== false;
|
|
1208
1229
|
function handleVisibilityChange() {
|
|
@@ -1240,7 +1261,13 @@ var PERIOD = 2 * Math.PI;
|
|
|
1240
1261
|
function catmullRom1D(p0, p1, p2, p3, u) {
|
|
1241
1262
|
const u2 = u * u;
|
|
1242
1263
|
const u3 = u2 * u;
|
|
1243
|
-
return
|
|
1264
|
+
return (
|
|
1265
|
+
0.5 *
|
|
1266
|
+
(2 * p1 +
|
|
1267
|
+
(-p0 + p2) * u +
|
|
1268
|
+
(2 * p0 - 5 * p1 + 4 * p2 - p3) * u2 +
|
|
1269
|
+
(-p0 + 3 * p1 - 3 * p2 + p3) * u3)
|
|
1270
|
+
);
|
|
1244
1271
|
}
|
|
1245
1272
|
function evaluateCatmullRom(points2, phase) {
|
|
1246
1273
|
const N = points2.length;
|
|
@@ -1250,7 +1277,7 @@ function evaluateCatmullRom(points2, phase) {
|
|
|
1250
1277
|
if (N === 1) {
|
|
1251
1278
|
return { x: points2[0][0], y: points2[0][1] };
|
|
1252
1279
|
}
|
|
1253
|
-
phase = (phase % PERIOD + PERIOD) % PERIOD;
|
|
1280
|
+
phase = ((phase % PERIOD) + PERIOD) % PERIOD;
|
|
1254
1281
|
const segmentSize = PERIOD / N;
|
|
1255
1282
|
let i = Math.floor(phase / segmentSize);
|
|
1256
1283
|
if (i >= N) {
|
|
@@ -1264,7 +1291,7 @@ function evaluateCatmullRom(points2, phase) {
|
|
|
1264
1291
|
const p3 = points2[(i + 2) % N];
|
|
1265
1292
|
return {
|
|
1266
1293
|
x: catmullRom1D(p0[0], p1[0], p2[0], p3[0], u),
|
|
1267
|
-
y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u)
|
|
1294
|
+
y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u),
|
|
1268
1295
|
};
|
|
1269
1296
|
}
|
|
1270
1297
|
function drawCurve(points2, opts) {
|
|
@@ -1274,20 +1301,20 @@ function drawCurve(points2, opts) {
|
|
|
1274
1301
|
const first = points2[0];
|
|
1275
1302
|
if (points2.every((p) => p[0] === first[0] && p[1] === first[1])) {
|
|
1276
1303
|
console.warn(
|
|
1277
|
-
"[sarmal].drawCurve: all control points are identical. The curve will be a single point."
|
|
1304
|
+
"[sarmal].drawCurve: all control points are identical. The curve will be a single point.",
|
|
1278
1305
|
);
|
|
1279
1306
|
}
|
|
1280
1307
|
const maxAbs = points2.reduce((m, p) => Math.max(m, Math.abs(p[0]), Math.abs(p[1])), 0);
|
|
1281
1308
|
if (maxAbs > 2) {
|
|
1282
1309
|
console.warn(
|
|
1283
|
-
`[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1]
|
|
1310
|
+
`[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1].`,
|
|
1284
1311
|
);
|
|
1285
1312
|
}
|
|
1286
1313
|
const pts = points2.map(([x, y]) => [x, y]);
|
|
1287
1314
|
return {
|
|
1288
1315
|
name: opts?.name ?? "drawn",
|
|
1289
1316
|
fn: (phase) => evaluateCatmullRom(pts, phase),
|
|
1290
|
-
period: PERIOD
|
|
1317
|
+
period: PERIOD,
|
|
1291
1318
|
};
|
|
1292
1319
|
}
|
|
1293
1320
|
|
|
@@ -1313,11 +1340,11 @@ var points = [
|
|
|
1313
1340
|
[-0.69, -0.84],
|
|
1314
1341
|
[-0.87, -0.66],
|
|
1315
1342
|
[-0.9, -0.47],
|
|
1316
|
-
[-0.76, -0.35]
|
|
1343
|
+
[-0.76, -0.35],
|
|
1317
1344
|
];
|
|
1318
1345
|
var artemis2 = {
|
|
1319
1346
|
...drawCurve(points, { name: "Artemis II" }),
|
|
1320
|
-
speed: 0.7
|
|
1347
|
+
speed: 0.7,
|
|
1321
1348
|
};
|
|
1322
1349
|
|
|
1323
1350
|
// src/curves/astroid.ts
|
|
@@ -1327,14 +1354,14 @@ function astroidFn(phase, _elapsed, _params) {
|
|
|
1327
1354
|
const s = Math.sin(phase);
|
|
1328
1355
|
return {
|
|
1329
1356
|
x: c * c * c,
|
|
1330
|
-
y: s * s * s
|
|
1357
|
+
y: s * s * s,
|
|
1331
1358
|
};
|
|
1332
1359
|
}
|
|
1333
1360
|
var astroid = {
|
|
1334
1361
|
name: "Astroid",
|
|
1335
1362
|
fn: astroidFn,
|
|
1336
1363
|
period: TWO_PI2,
|
|
1337
|
-
speed: 1.1
|
|
1364
|
+
speed: 1.1,
|
|
1338
1365
|
};
|
|
1339
1366
|
|
|
1340
1367
|
// src/curves/deltoid.ts
|
|
@@ -1342,14 +1369,14 @@ var TWO_PI3 = Math.PI * 2;
|
|
|
1342
1369
|
function deltoidFn(phase, _elapsed, _params) {
|
|
1343
1370
|
return {
|
|
1344
1371
|
x: 2 * Math.cos(phase) + Math.cos(2 * phase),
|
|
1345
|
-
y: 2 * Math.sin(phase) - Math.sin(2 * phase)
|
|
1372
|
+
y: 2 * Math.sin(phase) - Math.sin(2 * phase),
|
|
1346
1373
|
};
|
|
1347
1374
|
}
|
|
1348
1375
|
var deltoid = {
|
|
1349
1376
|
name: "Deltoid",
|
|
1350
1377
|
fn: deltoidFn,
|
|
1351
1378
|
period: TWO_PI3,
|
|
1352
|
-
speed: 0.9
|
|
1379
|
+
speed: 0.9,
|
|
1353
1380
|
};
|
|
1354
1381
|
|
|
1355
1382
|
// src/curves/epicycloid3.ts
|
|
@@ -1357,14 +1384,14 @@ var TWO_PI4 = Math.PI * 2;
|
|
|
1357
1384
|
function epicycloid3Fn(phase, _elapsed, _params) {
|
|
1358
1385
|
return {
|
|
1359
1386
|
x: 4 * Math.cos(phase) - Math.cos(4 * phase),
|
|
1360
|
-
y: 4 * Math.sin(phase) - Math.sin(4 * phase)
|
|
1387
|
+
y: 4 * Math.sin(phase) - Math.sin(4 * phase),
|
|
1361
1388
|
};
|
|
1362
1389
|
}
|
|
1363
1390
|
var epicycloid3 = {
|
|
1364
1391
|
name: "Epicycloid (n=3)",
|
|
1365
1392
|
fn: epicycloid3Fn,
|
|
1366
1393
|
period: TWO_PI4,
|
|
1367
|
-
speed: 0.75
|
|
1394
|
+
speed: 0.75,
|
|
1368
1395
|
};
|
|
1369
1396
|
|
|
1370
1397
|
// src/curves/epitrochoid7.ts
|
|
@@ -1373,14 +1400,14 @@ function epitrochoid7Fn(phase, _elapsed, _params) {
|
|
|
1373
1400
|
const d = 1 + 0.55 * Math.sin(phase * 0.5);
|
|
1374
1401
|
return {
|
|
1375
1402
|
x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
|
|
1376
|
-
y: 7 * Math.sin(phase) - d * Math.sin(7 * phase)
|
|
1403
|
+
y: 7 * Math.sin(phase) - d * Math.sin(7 * phase),
|
|
1377
1404
|
};
|
|
1378
1405
|
}
|
|
1379
1406
|
function epitrochoid7SkeletonFn(phase) {
|
|
1380
1407
|
const d = 1.275;
|
|
1381
1408
|
return {
|
|
1382
1409
|
x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
|
|
1383
|
-
y: 7 * Math.sin(phase) - d * Math.sin(7 * phase)
|
|
1410
|
+
y: 7 * Math.sin(phase) - d * Math.sin(7 * phase),
|
|
1384
1411
|
};
|
|
1385
1412
|
}
|
|
1386
1413
|
var epitrochoid7 = {
|
|
@@ -1388,7 +1415,7 @@ var epitrochoid7 = {
|
|
|
1388
1415
|
fn: epitrochoid7Fn,
|
|
1389
1416
|
period: TWO_PI5,
|
|
1390
1417
|
speed: 1.4,
|
|
1391
|
-
skeletonFn: epitrochoid7SkeletonFn
|
|
1418
|
+
skeletonFn: epitrochoid7SkeletonFn,
|
|
1392
1419
|
};
|
|
1393
1420
|
|
|
1394
1421
|
// src/curves/lissajous32.ts
|
|
@@ -1397,7 +1424,7 @@ function lissajous32Fn(phase, elapsed, _params) {
|
|
|
1397
1424
|
const phi = elapsed * 0.45;
|
|
1398
1425
|
return {
|
|
1399
1426
|
x: Math.sin(3 * phase + phi),
|
|
1400
|
-
y: Math.sin(2 * phase)
|
|
1427
|
+
y: Math.sin(2 * phase),
|
|
1401
1428
|
};
|
|
1402
1429
|
}
|
|
1403
1430
|
var lissajous32 = {
|
|
@@ -1405,7 +1432,7 @@ var lissajous32 = {
|
|
|
1405
1432
|
fn: lissajous32Fn,
|
|
1406
1433
|
period: TWO_PI6,
|
|
1407
1434
|
speed: 2,
|
|
1408
|
-
skeleton: "live"
|
|
1435
|
+
skeleton: "live",
|
|
1409
1436
|
};
|
|
1410
1437
|
|
|
1411
1438
|
// src/curves/lissajous43.ts
|
|
@@ -1414,7 +1441,7 @@ function lissajous43Fn(phase, elapsed, _params) {
|
|
|
1414
1441
|
const phi = elapsed * 0.38;
|
|
1415
1442
|
return {
|
|
1416
1443
|
x: Math.sin(4 * phase + phi),
|
|
1417
|
-
y: Math.sin(3 * phase)
|
|
1444
|
+
y: Math.sin(3 * phase),
|
|
1418
1445
|
};
|
|
1419
1446
|
}
|
|
1420
1447
|
var lissajous43 = {
|
|
@@ -1422,17 +1449,18 @@ var lissajous43 = {
|
|
|
1422
1449
|
fn: lissajous43Fn,
|
|
1423
1450
|
period: TWO_PI7,
|
|
1424
1451
|
speed: 1.8,
|
|
1425
|
-
skeleton: "live"
|
|
1452
|
+
skeleton: "live",
|
|
1426
1453
|
};
|
|
1427
1454
|
|
|
1428
1455
|
// src/curves/lame.ts
|
|
1429
1456
|
var TWO_PI8 = Math.PI * 2;
|
|
1430
1457
|
function lameFn(phase, elapsed, _params) {
|
|
1431
1458
|
const p = 1.75 + 1.25 * Math.sin(elapsed * 0.48);
|
|
1432
|
-
const c = Math.cos(phase),
|
|
1459
|
+
const c = Math.cos(phase),
|
|
1460
|
+
s = Math.sin(phase);
|
|
1433
1461
|
return {
|
|
1434
1462
|
x: Math.sign(c) * Math.pow(Math.abs(c), p),
|
|
1435
|
-
y: Math.sign(s) * Math.pow(Math.abs(s), p)
|
|
1463
|
+
y: Math.sign(s) * Math.pow(Math.abs(s), p),
|
|
1436
1464
|
};
|
|
1437
1465
|
}
|
|
1438
1466
|
var lame = {
|
|
@@ -1440,7 +1468,7 @@ var lame = {
|
|
|
1440
1468
|
fn: lameFn,
|
|
1441
1469
|
period: TWO_PI8,
|
|
1442
1470
|
speed: 1,
|
|
1443
|
-
skeleton: "live"
|
|
1471
|
+
skeleton: "live",
|
|
1444
1472
|
};
|
|
1445
1473
|
|
|
1446
1474
|
// src/curves/rose3.ts
|
|
@@ -1449,14 +1477,14 @@ function rose3Fn(phase, _elapsed, _params) {
|
|
|
1449
1477
|
const r = Math.cos(3 * phase);
|
|
1450
1478
|
return {
|
|
1451
1479
|
x: r * Math.cos(phase),
|
|
1452
|
-
y: r * Math.sin(phase)
|
|
1480
|
+
y: r * Math.sin(phase),
|
|
1453
1481
|
};
|
|
1454
1482
|
}
|
|
1455
1483
|
var rose3 = {
|
|
1456
1484
|
name: "Rose (n=3)",
|
|
1457
1485
|
fn: rose3Fn,
|
|
1458
1486
|
period: TWO_PI9,
|
|
1459
|
-
speed: 1.15
|
|
1487
|
+
speed: 1.15,
|
|
1460
1488
|
};
|
|
1461
1489
|
|
|
1462
1490
|
// src/curves/rose5.ts
|
|
@@ -1465,78 +1493,87 @@ function rose5Fn(phase, _elapsed, _params) {
|
|
|
1465
1493
|
const r = Math.cos(5 * phase);
|
|
1466
1494
|
return {
|
|
1467
1495
|
x: r * Math.cos(phase),
|
|
1468
|
-
y: r * Math.sin(phase)
|
|
1496
|
+
y: r * Math.sin(phase),
|
|
1469
1497
|
};
|
|
1470
1498
|
}
|
|
1471
1499
|
var rose5 = {
|
|
1472
1500
|
name: "Rose (n=5)",
|
|
1473
1501
|
fn: rose5Fn,
|
|
1474
1502
|
period: TWO_PI10,
|
|
1475
|
-
speed: 1
|
|
1503
|
+
speed: 1,
|
|
1476
1504
|
};
|
|
1477
1505
|
|
|
1478
1506
|
// src/curves/rose52.ts
|
|
1479
1507
|
var FOUR_PI = Math.PI * 4;
|
|
1480
1508
|
function rose52Fn(phase, _elapsed, _params) {
|
|
1481
|
-
const r = Math.cos(5 / 2 * phase);
|
|
1509
|
+
const r = Math.cos((5 / 2) * phase);
|
|
1482
1510
|
return {
|
|
1483
1511
|
x: r * Math.cos(phase),
|
|
1484
|
-
y: r * Math.sin(phase)
|
|
1512
|
+
y: r * Math.sin(phase),
|
|
1485
1513
|
};
|
|
1486
1514
|
}
|
|
1487
1515
|
var rose52 = {
|
|
1488
1516
|
name: "Rose (n=5/2)",
|
|
1489
1517
|
fn: rose52Fn,
|
|
1490
1518
|
period: FOUR_PI,
|
|
1491
|
-
speed: 0.8
|
|
1519
|
+
speed: 0.8,
|
|
1492
1520
|
};
|
|
1493
1521
|
|
|
1494
1522
|
// src/curves/star.ts
|
|
1495
1523
|
var TWO_PI11 = Math.PI * 2;
|
|
1496
1524
|
function starFn(phase, _elapsed, _params) {
|
|
1497
|
-
const r =
|
|
1525
|
+
const r =
|
|
1526
|
+
Math.abs(Math.cos((5 / 2) * phase)) +
|
|
1527
|
+
0.35 * Math.abs(Math.cos((15 / 2) * phase)) +
|
|
1528
|
+
0.15 * Math.abs(Math.cos((25 / 2) * phase));
|
|
1498
1529
|
return {
|
|
1499
1530
|
x: r * Math.cos(phase),
|
|
1500
|
-
y: r * Math.sin(phase)
|
|
1531
|
+
y: r * Math.sin(phase),
|
|
1501
1532
|
};
|
|
1502
1533
|
}
|
|
1503
1534
|
var star = {
|
|
1504
1535
|
name: "Star",
|
|
1505
1536
|
fn: starFn,
|
|
1506
1537
|
period: TWO_PI11,
|
|
1507
|
-
speed: 1
|
|
1538
|
+
speed: 1,
|
|
1508
1539
|
};
|
|
1509
1540
|
|
|
1510
1541
|
// src/curves/star4.ts
|
|
1511
1542
|
var TWO_PI12 = Math.PI * 2;
|
|
1512
1543
|
function star4Fn(phase, _elapsed, _params) {
|
|
1513
|
-
const r =
|
|
1544
|
+
const r =
|
|
1545
|
+
Math.abs(Math.cos(2 * phase)) +
|
|
1546
|
+
0.35 * Math.abs(Math.cos(6 * phase)) +
|
|
1547
|
+
0.15 * Math.abs(Math.cos(10 * phase));
|
|
1514
1548
|
return {
|
|
1515
1549
|
x: r * Math.cos(phase),
|
|
1516
|
-
y: r * Math.sin(phase)
|
|
1550
|
+
y: r * Math.sin(phase),
|
|
1517
1551
|
};
|
|
1518
1552
|
}
|
|
1519
1553
|
var star4 = {
|
|
1520
1554
|
name: "Star (4-arm)",
|
|
1521
1555
|
fn: star4Fn,
|
|
1522
1556
|
period: TWO_PI12,
|
|
1523
|
-
speed: 1
|
|
1557
|
+
speed: 1,
|
|
1524
1558
|
};
|
|
1525
1559
|
|
|
1526
1560
|
// src/curves/star7.ts
|
|
1527
1561
|
var TWO_PI13 = Math.PI * 2;
|
|
1528
1562
|
function star7Fn(phase, _elapsed, _params) {
|
|
1529
|
-
const r =
|
|
1563
|
+
const r =
|
|
1564
|
+
Math.abs(Math.cos((7 / 2) * phase)) +
|
|
1565
|
+
0.35 * Math.abs(Math.cos((21 / 2) * phase)) +
|
|
1566
|
+
0.15 * Math.abs(Math.cos((35 / 2) * phase));
|
|
1530
1567
|
return {
|
|
1531
1568
|
x: r * Math.cos(phase),
|
|
1532
|
-
y: r * Math.sin(phase)
|
|
1569
|
+
y: r * Math.sin(phase),
|
|
1533
1570
|
};
|
|
1534
1571
|
}
|
|
1535
1572
|
var star7 = {
|
|
1536
1573
|
name: "Star (7-arm)",
|
|
1537
1574
|
fn: star7Fn,
|
|
1538
1575
|
period: TWO_PI13,
|
|
1539
|
-
speed: 1
|
|
1576
|
+
speed: 1,
|
|
1540
1577
|
};
|
|
1541
1578
|
|
|
1542
1579
|
// src/curves/index.ts
|
|
@@ -1554,7 +1591,7 @@ var curves = {
|
|
|
1554
1591
|
lissajous32,
|
|
1555
1592
|
lissajous43,
|
|
1556
1593
|
epicycloid3,
|
|
1557
|
-
lame
|
|
1594
|
+
lame,
|
|
1558
1595
|
};
|
|
1559
1596
|
|
|
1560
1597
|
// src/index.ts
|
|
@@ -1585,4 +1622,4 @@ exports.palettes = palettes;
|
|
|
1585
1622
|
exports.rose3 = rose3;
|
|
1586
1623
|
exports.rose5 = rose5;
|
|
1587
1624
|
//# sourceMappingURL=index.cjs.map
|
|
1588
|
-
//# sourceMappingURL=index.cjs.map
|
|
1625
|
+
//# sourceMappingURL=index.cjs.map
|