@sarmal/core 0.25.0 → 0.25.1
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 +140 -105
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.js +139 -104
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.cjs +15 -10
- package/dist/curves/artemis2.cjs.map +1 -1
- package/dist/curves/artemis2.d.cts +1 -1
- package/dist/curves/artemis2.d.ts +1 -1
- package/dist/curves/artemis2.js +14 -9
- package/dist/curves/artemis2.js.map +1 -1
- 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 +58 -43
- package/dist/curves/index.cjs.map +1 -1
- package/dist/curves/index.d.cts +29 -29
- package/dist/curves/index.d.ts +29 -29
- package/dist/curves/index.js +74 -43
- package/dist/curves/index.js.map +1 -1
- 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 +126 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -40
- package/dist/index.d.ts +92 -40
- package/dist/index.js +147 -93
- package/dist/index.js.map +1 -1
- package/dist/types-Z9i1_AQZ.d.cts +339 -0
- package/dist/types-Z9i1_AQZ.d.ts +339 -0
- package/package.json +1 -1
- package/dist/types-BZpzgNau.d.cts +0 -332
- package/dist/types-BZpzgNau.d.ts +0 -332
package/dist/index.js
CHANGED
|
@@ -61,13 +61,13 @@ function resolveCurve(curveDef) {
|
|
|
61
61
|
period,
|
|
62
62
|
speed,
|
|
63
63
|
skeleton: curveDef.skeleton,
|
|
64
|
-
skeletonFn: curveDef.skeletonFn
|
|
64
|
+
skeletonFn: curveDef.skeletonFn,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
function createEngine(curveDef, trailLength = 120) {
|
|
68
68
|
if (!Number.isFinite(trailLength) || trailLength <= 0) {
|
|
69
69
|
throw new RangeError(
|
|
70
|
-
`[sarmal] trailLength must be a positive finite number, got ${trailLength}
|
|
70
|
+
`[sarmal] trailLength must be a positive finite number, got ${trailLength}`,
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
let curve = resolveCurve(curveDef);
|
|
@@ -108,7 +108,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
108
108
|
actualTime += deltaTime;
|
|
109
109
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
110
110
|
const a = curve.fn(t, actualTime, EMPTY_PARAMS);
|
|
111
|
-
const tB = _morphStrategy === "normalized" ? t / curve.period * morphCurveB.period : t;
|
|
111
|
+
const tB = _morphStrategy === "normalized" ? (t / curve.period) * morphCurveB.period : t;
|
|
112
112
|
const b = morphCurveB.fn(tB, actualTime, EMPTY_PARAMS);
|
|
113
113
|
trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
|
|
114
114
|
} else {
|
|
@@ -135,14 +135,14 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
135
135
|
trail.clear();
|
|
136
136
|
},
|
|
137
137
|
jump(newT, { clearTrail = false } = {}) {
|
|
138
|
-
t = (newT % curve.period + curve.period) % curve.period;
|
|
138
|
+
t = ((newT % curve.period) + curve.period) % curve.period;
|
|
139
139
|
if (clearTrail) {
|
|
140
140
|
trail.clear();
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
seek(targetT, { wrap = false, step = curve.period / trailLength } = {}) {
|
|
144
144
|
const advance = curve.speed * step;
|
|
145
|
-
const target = (targetT % curve.period + curve.period) % curve.period;
|
|
145
|
+
const target = ((targetT % curve.period) + curve.period) % curve.period;
|
|
146
146
|
const targetTime = target / curve.speed;
|
|
147
147
|
t = target;
|
|
148
148
|
actualTime = targetTime;
|
|
@@ -151,7 +151,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
151
151
|
const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
|
|
152
152
|
for (let i = count - 1; i >= 0; i--) {
|
|
153
153
|
const sampleT = target - i * advance;
|
|
154
|
-
const wrappedT = (sampleT % curve.period + curve.period) % curve.period;
|
|
154
|
+
const wrappedT = ((sampleT % curve.period) + curve.period) % curve.period;
|
|
155
155
|
const time = targetTime - i * step;
|
|
156
156
|
const point = curve.fn(wrappedT, time, EMPTY_PARAMS);
|
|
157
157
|
trail.push(point.x, point.y);
|
|
@@ -168,13 +168,16 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
168
168
|
...frozenB,
|
|
169
169
|
fn: (sampleT, time, params) => {
|
|
170
170
|
const a = frozenA.fn(sampleT, time, params);
|
|
171
|
-
const tB =
|
|
171
|
+
const tB =
|
|
172
|
+
frozenStrategy === "normalized"
|
|
173
|
+
? (sampleT / frozenA.period) * frozenB.period
|
|
174
|
+
: sampleT;
|
|
172
175
|
const b = frozenB.fn(tB, time, params);
|
|
173
176
|
return {
|
|
174
177
|
x: a.x + (b.x - a.x) * frozenAlpha,
|
|
175
|
-
y: a.y + (b.y - a.y) * frozenAlpha
|
|
178
|
+
y: a.y + (b.y - a.y) * frozenAlpha,
|
|
176
179
|
};
|
|
177
|
-
}
|
|
180
|
+
},
|
|
178
181
|
};
|
|
179
182
|
}
|
|
180
183
|
_morphStrategy = strategy;
|
|
@@ -187,7 +190,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
187
190
|
completeMorph() {
|
|
188
191
|
if (morphCurveB !== null) {
|
|
189
192
|
if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
|
|
190
|
-
t = t / curve.period * morphCurveB.period;
|
|
193
|
+
t = (t / curve.period) * morphCurveB.period;
|
|
191
194
|
}
|
|
192
195
|
curve = morphCurveB;
|
|
193
196
|
}
|
|
@@ -199,19 +202,22 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
199
202
|
const points2 = new Array(steps);
|
|
200
203
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
201
204
|
for (let i = 0; i < steps; i++) {
|
|
202
|
-
const sampleT = i / (steps - 1) * curve.period;
|
|
205
|
+
const sampleT = (i / (steps - 1)) * curve.period;
|
|
203
206
|
const a = sampleSkeleton(curve, sampleT);
|
|
204
|
-
const tB =
|
|
207
|
+
const tB =
|
|
208
|
+
_morphStrategy === "normalized"
|
|
209
|
+
? (sampleT / curve.period) * morphCurveB.period
|
|
210
|
+
: sampleT;
|
|
205
211
|
const b = sampleSkeleton(morphCurveB, tB);
|
|
206
212
|
points2[i] = {
|
|
207
213
|
x: a.x + (b.x - a.x) * _morphAlpha,
|
|
208
|
-
y: a.y + (b.y - a.y) * _morphAlpha
|
|
214
|
+
y: a.y + (b.y - a.y) * _morphAlpha,
|
|
209
215
|
};
|
|
210
216
|
}
|
|
211
217
|
return points2;
|
|
212
218
|
}
|
|
213
219
|
for (let i = 0; i < steps; i++) {
|
|
214
|
-
const sampleT = i / (steps - 1) * curve.period;
|
|
220
|
+
const sampleT = (i / (steps - 1)) * curve.period;
|
|
215
221
|
points2[i] = sampleSkeleton(curve, sampleT);
|
|
216
222
|
}
|
|
217
223
|
return points2;
|
|
@@ -253,7 +259,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
253
259
|
_speedTransition.reject(new Error("Speed transition cancelled"));
|
|
254
260
|
_speedTransition = null;
|
|
255
261
|
}
|
|
256
|
-
}
|
|
262
|
+
},
|
|
257
263
|
};
|
|
258
264
|
}
|
|
259
265
|
|
|
@@ -292,7 +298,15 @@ function computeNormal(trail, i) {
|
|
|
292
298
|
const tangent = computeTangent(trail, i);
|
|
293
299
|
return { x: -tangent.y, y: tangent.x };
|
|
294
300
|
}
|
|
295
|
-
function computeTrailQuad(
|
|
301
|
+
function computeTrailQuad(
|
|
302
|
+
trail,
|
|
303
|
+
i,
|
|
304
|
+
trailCount,
|
|
305
|
+
toX,
|
|
306
|
+
toY,
|
|
307
|
+
minWidth = TRAIL_MIN_WIDTH,
|
|
308
|
+
maxWidth = TRAIL_MAX_WIDTH,
|
|
309
|
+
) {
|
|
296
310
|
const progress = i / (trailCount - 1);
|
|
297
311
|
const nextProgress = (i + 1) / (trailCount - 1);
|
|
298
312
|
const opacity = Math.pow(progress, TRAIL_FADE_CURVE) * TRAIL_MAX_OPACITY;
|
|
@@ -316,13 +330,16 @@ function computeTrailQuad(trail, i, trailCount, toX, toY, minWidth = TRAIL_MIN_W
|
|
|
316
330
|
r1x: nx - n1.x * w1,
|
|
317
331
|
r1y: ny - n1.y * w1,
|
|
318
332
|
opacity,
|
|
319
|
-
progress
|
|
333
|
+
progress,
|
|
320
334
|
};
|
|
321
335
|
}
|
|
322
336
|
function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_PADDING_MIN) {
|
|
323
337
|
if (pts.length === 0) return null;
|
|
324
338
|
const first = pts[0];
|
|
325
|
-
let minX = first.x,
|
|
339
|
+
let minX = first.x,
|
|
340
|
+
maxX = first.x,
|
|
341
|
+
minY = first.y,
|
|
342
|
+
maxY = first.y;
|
|
326
343
|
for (const p of pts) {
|
|
327
344
|
if (p.x < minX) {
|
|
328
345
|
minX = p.x;
|
|
@@ -341,7 +358,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
341
358
|
const h = maxY - minY;
|
|
342
359
|
if (w === 0 && h === 0) {
|
|
343
360
|
throw new Error(
|
|
344
|
-
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
361
|
+
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t.",
|
|
345
362
|
);
|
|
346
363
|
}
|
|
347
364
|
const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
|
|
@@ -352,12 +369,12 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
352
369
|
scaleXProportional,
|
|
353
370
|
scaleYProportional,
|
|
354
371
|
scaleXMinPadding,
|
|
355
|
-
scaleYMinPadding
|
|
372
|
+
scaleYMinPadding,
|
|
356
373
|
);
|
|
357
374
|
return {
|
|
358
375
|
scale,
|
|
359
376
|
offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
|
|
360
|
-
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
377
|
+
offsetY: (logicalHeight - h * scale) / 2 - minY * scale,
|
|
361
378
|
};
|
|
362
379
|
}
|
|
363
380
|
function enginePassthroughs(engine) {
|
|
@@ -368,7 +385,7 @@ function enginePassthroughs(engine) {
|
|
|
368
385
|
getSpeed: engine.getSpeed,
|
|
369
386
|
resetSpeed: engine.resetSpeed,
|
|
370
387
|
setSpeedOver: engine.setSpeedOver,
|
|
371
|
-
getSarmalSkeleton: engine.getSarmalSkeleton
|
|
388
|
+
getSarmalSkeleton: engine.getSarmalSkeleton,
|
|
372
389
|
};
|
|
373
390
|
}
|
|
374
391
|
var palettes = {
|
|
@@ -377,16 +394,16 @@ var palettes = {
|
|
|
377
394
|
ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"],
|
|
378
395
|
ice: ["#1e3a8a", "#67e8f9"],
|
|
379
396
|
fire: ["#7f1d1d", "#fbbf24"],
|
|
380
|
-
forest: ["#14532d", "#86efac"]
|
|
397
|
+
forest: ["#14532d", "#86efac"],
|
|
381
398
|
};
|
|
382
399
|
function hexToRgb(hex) {
|
|
383
400
|
const n = parseInt(hex.slice(1), 16);
|
|
384
|
-
return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
|
|
401
|
+
return { r: n >> 16, g: (n >> 8) & 255, b: n & 255 };
|
|
385
402
|
}
|
|
386
403
|
var lerpRgb = (a, b, t) => ({
|
|
387
404
|
r: Math.round(a.r + (b.r - a.r) * t),
|
|
388
405
|
g: Math.round(a.g + (b.g - a.g) * t),
|
|
389
|
-
b: Math.round(a.b + (b.b - a.b) * t)
|
|
406
|
+
b: Math.round(a.b + (b.b - a.b) * t),
|
|
390
407
|
});
|
|
391
408
|
function getPaletteColor(palette, position, timeOffset = 0) {
|
|
392
409
|
if (palette.length === 0) {
|
|
@@ -395,7 +412,7 @@ function getPaletteColor(palette, position, timeOffset = 0) {
|
|
|
395
412
|
if (palette.length === 1) {
|
|
396
413
|
return hexToRgb(palette[0]);
|
|
397
414
|
}
|
|
398
|
-
const cyclePos = ((position + timeOffset) % 1 + 1) % 1;
|
|
415
|
+
const cyclePos = (((position + timeOffset) % 1) + 1) % 1;
|
|
399
416
|
const scaled = cyclePos * palette.length;
|
|
400
417
|
const idx = Math.floor(scaled);
|
|
401
418
|
const t = scaled - idx;
|
|
@@ -410,7 +427,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
|
410
427
|
"headColor",
|
|
411
428
|
"skeletonColor",
|
|
412
429
|
"trailStyle",
|
|
413
|
-
"headRadius"
|
|
430
|
+
"headRadius",
|
|
414
431
|
]);
|
|
415
432
|
function validateRenderOptions(partial) {
|
|
416
433
|
for (const key of Object.keys(partial)) {
|
|
@@ -438,7 +455,7 @@ function assertTrailColor(value) {
|
|
|
438
455
|
if (typeof value === "string") {
|
|
439
456
|
if (!HEX_COLOR_RE.test(value)) {
|
|
440
457
|
throw new TypeError(
|
|
441
|
-
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"
|
|
458
|
+
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`,
|
|
442
459
|
);
|
|
443
460
|
}
|
|
444
461
|
return;
|
|
@@ -446,21 +463,21 @@ function assertTrailColor(value) {
|
|
|
446
463
|
if (Array.isArray(value)) {
|
|
447
464
|
if (value.length < 2) {
|
|
448
465
|
throw new RangeError(
|
|
449
|
-
`[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}
|
|
466
|
+
`[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`,
|
|
450
467
|
);
|
|
451
468
|
}
|
|
452
469
|
for (let i = 0; i < value.length; i++) {
|
|
453
470
|
const entry = value[i];
|
|
454
471
|
if (typeof entry !== "string" || !HEX_COLOR_RE.test(entry)) {
|
|
455
472
|
throw new TypeError(
|
|
456
|
-
`[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}
|
|
473
|
+
`[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`,
|
|
457
474
|
);
|
|
458
475
|
}
|
|
459
476
|
}
|
|
460
477
|
return;
|
|
461
478
|
}
|
|
462
479
|
throw new TypeError(
|
|
463
|
-
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}
|
|
480
|
+
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`,
|
|
464
481
|
);
|
|
465
482
|
}
|
|
466
483
|
function assertHeadColor(value) {
|
|
@@ -469,7 +486,7 @@ function assertHeadColor(value) {
|
|
|
469
486
|
}
|
|
470
487
|
if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
|
|
471
488
|
throw new TypeError(
|
|
472
|
-
`[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}
|
|
489
|
+
`[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`,
|
|
473
490
|
);
|
|
474
491
|
}
|
|
475
492
|
}
|
|
@@ -479,26 +496,26 @@ function assertSkeletonColor(value) {
|
|
|
479
496
|
}
|
|
480
497
|
if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
|
|
481
498
|
throw new TypeError(
|
|
482
|
-
`[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}
|
|
499
|
+
`[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`,
|
|
483
500
|
);
|
|
484
501
|
}
|
|
485
502
|
}
|
|
486
503
|
function assertTrailStyle(value) {
|
|
487
504
|
if (!TRAIL_STYLES.includes(value)) {
|
|
488
505
|
throw new RangeError(
|
|
489
|
-
`[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}
|
|
506
|
+
`[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`,
|
|
490
507
|
);
|
|
491
508
|
}
|
|
492
509
|
}
|
|
493
510
|
function assertHeadRadius(value) {
|
|
494
511
|
if (typeof value !== "number") {
|
|
495
512
|
throw new TypeError(
|
|
496
|
-
`[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}
|
|
513
|
+
`[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`,
|
|
497
514
|
);
|
|
498
515
|
}
|
|
499
516
|
if (!Number.isFinite(value) || value <= 0) {
|
|
500
517
|
throw new TypeError(
|
|
501
|
-
`[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}
|
|
518
|
+
`[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`,
|
|
502
519
|
);
|
|
503
520
|
}
|
|
504
521
|
}
|
|
@@ -520,13 +537,13 @@ function resolveHeadColor(trailColor, trailStyle) {
|
|
|
520
537
|
function warnIfTrailColorMismatch(trailColor, trailStyle) {
|
|
521
538
|
if (trailStyle === "default" && Array.isArray(trailColor)) {
|
|
522
539
|
console.warn(
|
|
523
|
-
'[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.'
|
|
540
|
+
'[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.',
|
|
524
541
|
);
|
|
525
542
|
return;
|
|
526
543
|
}
|
|
527
544
|
if (trailStyle !== "default" && typeof trailColor === "string") {
|
|
528
545
|
console.warn(
|
|
529
|
-
`[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
|
|
546
|
+
`[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.`,
|
|
530
547
|
);
|
|
531
548
|
}
|
|
532
549
|
}
|
|
@@ -536,7 +553,7 @@ var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160)
|
|
|
536
553
|
var WHITE_HEX = "#ffffff";
|
|
537
554
|
function hexToRgbComponents(hex) {
|
|
538
555
|
const n = parseInt(hex.slice(1), 16);
|
|
539
|
-
return `${n >> 16},${n >> 8 & 255},${n & 255}`;
|
|
556
|
+
return `${n >> 16},${(n >> 8) & 255},${n & 255}`;
|
|
540
557
|
}
|
|
541
558
|
function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
|
|
542
559
|
target.style.width = `${logicalWidth}px`;
|
|
@@ -663,7 +680,7 @@ function createRenderer(options) {
|
|
|
663
680
|
i,
|
|
664
681
|
trailCount,
|
|
665
682
|
toX,
|
|
666
|
-
toY
|
|
683
|
+
toY,
|
|
667
684
|
);
|
|
668
685
|
if (trailStyle === "default") {
|
|
669
686
|
ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
|
|
@@ -828,7 +845,7 @@ function createRenderer(options) {
|
|
|
828
845
|
if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
|
|
829
846
|
warnIfTrailColorMismatch(trailColor, trailStyle);
|
|
830
847
|
}
|
|
831
|
-
}
|
|
848
|
+
},
|
|
832
849
|
};
|
|
833
850
|
const pauseOnHidden = options.pauseOnHidden !== false;
|
|
834
851
|
function handleVisibilityChange() {
|
|
@@ -878,7 +895,7 @@ function sampleCurveSkeleton(curveDef) {
|
|
|
878
895
|
const samples = Math.ceil(period * 50);
|
|
879
896
|
const pts = Array.from({ length: samples });
|
|
880
897
|
for (let i = 0; i < samples; i++) {
|
|
881
|
-
const t = i / (samples - 1) * period;
|
|
898
|
+
const t = (i / (samples - 1)) * period;
|
|
882
899
|
pts[i] = curveDef.skeletonFn ? curveDef.skeletonFn(t) : curveDef.fn(t, 0, EMPTY_PARAMS2);
|
|
883
900
|
}
|
|
884
901
|
return pts;
|
|
@@ -891,7 +908,7 @@ function createSVGRenderer(options) {
|
|
|
891
908
|
const poolSize = engine.trailLength;
|
|
892
909
|
if (poolSize > HIGH_TRAIL_LENGTH_THRESHOLD) {
|
|
893
910
|
console.warn(
|
|
894
|
-
`[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails
|
|
911
|
+
`[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails.`,
|
|
895
912
|
);
|
|
896
913
|
}
|
|
897
914
|
let trailStyle = options.trailStyle ?? "default";
|
|
@@ -910,9 +927,9 @@ function createSVGRenderer(options) {
|
|
|
910
927
|
return rect.width && rect.height ? Math.min(rect.width, rect.height) : 200;
|
|
911
928
|
}
|
|
912
929
|
const containerPx = getContainerPixelSize();
|
|
913
|
-
const svgTrailMinWidth = TRAIL_MIN_WIDTH * viewSize / containerPx;
|
|
914
|
-
const svgTrailMaxWidth = TRAIL_MAX_WIDTH * viewSize / containerPx;
|
|
915
|
-
const svgSkeletonStrokeWidth = String(SKELETON_STROKE_WIDTH_PX * viewSize / containerPx);
|
|
930
|
+
const svgTrailMinWidth = (TRAIL_MIN_WIDTH * viewSize) / containerPx;
|
|
931
|
+
const svgTrailMaxWidth = (TRAIL_MAX_WIDTH * viewSize) / containerPx;
|
|
932
|
+
const svgSkeletonStrokeWidth = String((SKELETON_STROKE_WIDTH_PX * viewSize) / containerPx);
|
|
916
933
|
headRadius = options.headRadius ?? SVG_DEFAULT_HEAD_RADIUS;
|
|
917
934
|
container.setAttribute("viewBox", `0 0 ${viewSize} ${viewSize}`);
|
|
918
935
|
container.setAttribute("role", "img");
|
|
@@ -1000,7 +1017,7 @@ function createSVGRenderer(options) {
|
|
|
1000
1017
|
px,
|
|
1001
1018
|
py,
|
|
1002
1019
|
svgTrailMinWidth,
|
|
1003
|
-
svgTrailMaxWidth
|
|
1020
|
+
svgTrailMaxWidth,
|
|
1004
1021
|
);
|
|
1005
1022
|
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`;
|
|
1006
1023
|
trailPaths[i].setAttribute("d", d);
|
|
@@ -1028,7 +1045,8 @@ function createSVGRenderer(options) {
|
|
|
1028
1045
|
let animationId = null;
|
|
1029
1046
|
let lastTime = 0;
|
|
1030
1047
|
let pausedByVisibility = false;
|
|
1031
|
-
const prefersReducedMotion =
|
|
1048
|
+
const prefersReducedMotion =
|
|
1049
|
+
typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1032
1050
|
let morphResolve = null;
|
|
1033
1051
|
let morphReject = null;
|
|
1034
1052
|
let morphDurationMs = DEFAULT_MORPH_DURATION_MS;
|
|
@@ -1046,7 +1064,7 @@ function createSVGRenderer(options) {
|
|
|
1046
1064
|
skeletonPathA.setAttribute("visibility", "visible");
|
|
1047
1065
|
skeletonPathA.setAttribute(
|
|
1048
1066
|
"stroke-opacity",
|
|
1049
|
-
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY)
|
|
1067
|
+
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY),
|
|
1050
1068
|
);
|
|
1051
1069
|
}
|
|
1052
1070
|
if (morphPathBBuilt) {
|
|
@@ -1200,7 +1218,7 @@ function createSVGRenderer(options) {
|
|
|
1200
1218
|
if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
|
|
1201
1219
|
warnIfTrailColorMismatch(trailColor, trailStyle);
|
|
1202
1220
|
}
|
|
1203
|
-
}
|
|
1221
|
+
},
|
|
1204
1222
|
};
|
|
1205
1223
|
const pauseOnHidden = options.pauseOnHidden !== false;
|
|
1206
1224
|
function handleVisibilityChange() {
|
|
@@ -1238,7 +1256,13 @@ var PERIOD = 2 * Math.PI;
|
|
|
1238
1256
|
function catmullRom1D(p0, p1, p2, p3, u) {
|
|
1239
1257
|
const u2 = u * u;
|
|
1240
1258
|
const u3 = u2 * u;
|
|
1241
|
-
return
|
|
1259
|
+
return (
|
|
1260
|
+
0.5 *
|
|
1261
|
+
(2 * p1 +
|
|
1262
|
+
(-p0 + p2) * u +
|
|
1263
|
+
(2 * p0 - 5 * p1 + 4 * p2 - p3) * u2 +
|
|
1264
|
+
(-p0 + 3 * p1 - 3 * p2 + p3) * u3)
|
|
1265
|
+
);
|
|
1242
1266
|
}
|
|
1243
1267
|
function evaluateCatmullRom(points2, t) {
|
|
1244
1268
|
const N = points2.length;
|
|
@@ -1248,7 +1272,7 @@ function evaluateCatmullRom(points2, t) {
|
|
|
1248
1272
|
if (N === 1) {
|
|
1249
1273
|
return { x: points2[0][0], y: points2[0][1] };
|
|
1250
1274
|
}
|
|
1251
|
-
t = (t % PERIOD + PERIOD) % PERIOD;
|
|
1275
|
+
t = ((t % PERIOD) + PERIOD) % PERIOD;
|
|
1252
1276
|
const segmentSize = PERIOD / N;
|
|
1253
1277
|
let i = Math.floor(t / segmentSize);
|
|
1254
1278
|
if (i >= N) {
|
|
@@ -1262,7 +1286,7 @@ function evaluateCatmullRom(points2, t) {
|
|
|
1262
1286
|
const p3 = points2[(i + 2) % N];
|
|
1263
1287
|
return {
|
|
1264
1288
|
x: catmullRom1D(p0[0], p1[0], p2[0], p3[0], u),
|
|
1265
|
-
y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u)
|
|
1289
|
+
y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u),
|
|
1266
1290
|
};
|
|
1267
1291
|
}
|
|
1268
1292
|
function drawCurve(points2, opts) {
|
|
@@ -1272,13 +1296,13 @@ function drawCurve(points2, opts) {
|
|
|
1272
1296
|
const first = points2[0];
|
|
1273
1297
|
if (points2.every((p) => p[0] === first[0] && p[1] === first[1])) {
|
|
1274
1298
|
console.warn(
|
|
1275
|
-
"[sarmal].drawCurve: all control points are identical. The curve will be a single point."
|
|
1299
|
+
"[sarmal].drawCurve: all control points are identical. The curve will be a single point.",
|
|
1276
1300
|
);
|
|
1277
1301
|
}
|
|
1278
1302
|
const maxAbs = points2.reduce((m, p) => Math.max(m, Math.abs(p[0]), Math.abs(p[1])), 0);
|
|
1279
1303
|
if (maxAbs > 2) {
|
|
1280
1304
|
console.warn(
|
|
1281
|
-
`[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1]
|
|
1305
|
+
`[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1].`,
|
|
1282
1306
|
);
|
|
1283
1307
|
}
|
|
1284
1308
|
const pts = points2.map(([x, y]) => [x, y]);
|
|
@@ -1286,7 +1310,6 @@ function drawCurve(points2, opts) {
|
|
|
1286
1310
|
name: opts?.name ?? "drawn",
|
|
1287
1311
|
fn: (t) => evaluateCatmullRom(pts, t),
|
|
1288
1312
|
period: PERIOD,
|
|
1289
|
-
kind: "drawn"
|
|
1290
1313
|
};
|
|
1291
1314
|
}
|
|
1292
1315
|
|
|
@@ -1312,11 +1335,11 @@ var points = [
|
|
|
1312
1335
|
[-0.69, -0.84],
|
|
1313
1336
|
[-0.87, -0.66],
|
|
1314
1337
|
[-0.9, -0.47],
|
|
1315
|
-
[-0.76, -0.35]
|
|
1338
|
+
[-0.76, -0.35],
|
|
1316
1339
|
];
|
|
1317
1340
|
var artemis2 = {
|
|
1318
1341
|
...drawCurve(points, { name: "Artemis II" }),
|
|
1319
|
-
speed: 0.7
|
|
1342
|
+
speed: 0.7,
|
|
1320
1343
|
};
|
|
1321
1344
|
|
|
1322
1345
|
// src/curves/astroid.ts
|
|
@@ -1326,14 +1349,14 @@ function astroidFn(t, _time, _params) {
|
|
|
1326
1349
|
const s = Math.sin(t);
|
|
1327
1350
|
return {
|
|
1328
1351
|
x: c * c * c,
|
|
1329
|
-
y: s * s * s
|
|
1352
|
+
y: s * s * s,
|
|
1330
1353
|
};
|
|
1331
1354
|
}
|
|
1332
1355
|
var astroid = {
|
|
1333
1356
|
name: "Astroid",
|
|
1334
1357
|
fn: astroidFn,
|
|
1335
1358
|
period: TWO_PI2,
|
|
1336
|
-
speed: 1.1
|
|
1359
|
+
speed: 1.1,
|
|
1337
1360
|
};
|
|
1338
1361
|
|
|
1339
1362
|
// src/curves/deltoid.ts
|
|
@@ -1341,14 +1364,14 @@ var TWO_PI3 = Math.PI * 2;
|
|
|
1341
1364
|
function deltoidFn(t, _time, _params) {
|
|
1342
1365
|
return {
|
|
1343
1366
|
x: 2 * Math.cos(t) + Math.cos(2 * t),
|
|
1344
|
-
y: 2 * Math.sin(t) - Math.sin(2 * t)
|
|
1367
|
+
y: 2 * Math.sin(t) - Math.sin(2 * t),
|
|
1345
1368
|
};
|
|
1346
1369
|
}
|
|
1347
1370
|
var deltoid = {
|
|
1348
1371
|
name: "Deltoid",
|
|
1349
1372
|
fn: deltoidFn,
|
|
1350
1373
|
period: TWO_PI3,
|
|
1351
|
-
speed: 0.9
|
|
1374
|
+
speed: 0.9,
|
|
1352
1375
|
};
|
|
1353
1376
|
|
|
1354
1377
|
// src/curves/epicycloid3.ts
|
|
@@ -1356,14 +1379,14 @@ var TWO_PI4 = Math.PI * 2;
|
|
|
1356
1379
|
function epicycloid3Fn(t, _time, _params) {
|
|
1357
1380
|
return {
|
|
1358
1381
|
x: 4 * Math.cos(t) - Math.cos(4 * t),
|
|
1359
|
-
y: 4 * Math.sin(t) - Math.sin(4 * t)
|
|
1382
|
+
y: 4 * Math.sin(t) - Math.sin(4 * t),
|
|
1360
1383
|
};
|
|
1361
1384
|
}
|
|
1362
1385
|
var epicycloid3 = {
|
|
1363
1386
|
name: "Epicycloid (n=3)",
|
|
1364
1387
|
fn: epicycloid3Fn,
|
|
1365
1388
|
period: TWO_PI4,
|
|
1366
|
-
speed: 0.75
|
|
1389
|
+
speed: 0.75,
|
|
1367
1390
|
};
|
|
1368
1391
|
|
|
1369
1392
|
// src/curves/epitrochoid7.ts
|
|
@@ -1372,14 +1395,14 @@ function epitrochoid7Fn(t, _time, _params) {
|
|
|
1372
1395
|
const d = 1 + 0.55 * Math.sin(t * 0.5);
|
|
1373
1396
|
return {
|
|
1374
1397
|
x: 7 * Math.cos(t) - d * Math.cos(7 * t),
|
|
1375
|
-
y: 7 * Math.sin(t) - d * Math.sin(7 * t)
|
|
1398
|
+
y: 7 * Math.sin(t) - d * Math.sin(7 * t),
|
|
1376
1399
|
};
|
|
1377
1400
|
}
|
|
1378
1401
|
function epitrochoid7SkeletonFn(t) {
|
|
1379
1402
|
const d = 1.275;
|
|
1380
1403
|
return {
|
|
1381
1404
|
x: 7 * Math.cos(t) - d * Math.cos(7 * t),
|
|
1382
|
-
y: 7 * Math.sin(t) - d * Math.sin(7 * t)
|
|
1405
|
+
y: 7 * Math.sin(t) - d * Math.sin(7 * t),
|
|
1383
1406
|
};
|
|
1384
1407
|
}
|
|
1385
1408
|
var epitrochoid7 = {
|
|
@@ -1387,7 +1410,7 @@ var epitrochoid7 = {
|
|
|
1387
1410
|
fn: epitrochoid7Fn,
|
|
1388
1411
|
period: TWO_PI5,
|
|
1389
1412
|
speed: 1.4,
|
|
1390
|
-
skeletonFn: epitrochoid7SkeletonFn
|
|
1413
|
+
skeletonFn: epitrochoid7SkeletonFn,
|
|
1391
1414
|
};
|
|
1392
1415
|
|
|
1393
1416
|
// src/curves/lissajous32.ts
|
|
@@ -1396,7 +1419,7 @@ function lissajous32Fn(t, time, _params) {
|
|
|
1396
1419
|
const phi = time * 0.45;
|
|
1397
1420
|
return {
|
|
1398
1421
|
x: Math.sin(3 * t + phi),
|
|
1399
|
-
y: Math.sin(2 * t)
|
|
1422
|
+
y: Math.sin(2 * t),
|
|
1400
1423
|
};
|
|
1401
1424
|
}
|
|
1402
1425
|
var lissajous32 = {
|
|
@@ -1404,7 +1427,7 @@ var lissajous32 = {
|
|
|
1404
1427
|
fn: lissajous32Fn,
|
|
1405
1428
|
period: TWO_PI6,
|
|
1406
1429
|
speed: 2,
|
|
1407
|
-
skeleton: "live"
|
|
1430
|
+
skeleton: "live",
|
|
1408
1431
|
};
|
|
1409
1432
|
|
|
1410
1433
|
// src/curves/lissajous43.ts
|
|
@@ -1413,7 +1436,7 @@ function lissajous43Fn(t, time, _params) {
|
|
|
1413
1436
|
const phi = time * 0.38;
|
|
1414
1437
|
return {
|
|
1415
1438
|
x: Math.sin(4 * t + phi),
|
|
1416
|
-
y: Math.sin(3 * t)
|
|
1439
|
+
y: Math.sin(3 * t),
|
|
1417
1440
|
};
|
|
1418
1441
|
}
|
|
1419
1442
|
var lissajous43 = {
|
|
@@ -1421,17 +1444,18 @@ var lissajous43 = {
|
|
|
1421
1444
|
fn: lissajous43Fn,
|
|
1422
1445
|
period: TWO_PI7,
|
|
1423
1446
|
speed: 1.8,
|
|
1424
|
-
skeleton: "live"
|
|
1447
|
+
skeleton: "live",
|
|
1425
1448
|
};
|
|
1426
1449
|
|
|
1427
1450
|
// src/curves/lame.ts
|
|
1428
1451
|
var TWO_PI8 = Math.PI * 2;
|
|
1429
1452
|
function lameFn(t, time, _params) {
|
|
1430
1453
|
const p = 1.75 + 1.25 * Math.sin(time * 0.48);
|
|
1431
|
-
const c = Math.cos(t),
|
|
1454
|
+
const c = Math.cos(t),
|
|
1455
|
+
s = Math.sin(t);
|
|
1432
1456
|
return {
|
|
1433
1457
|
x: Math.sign(c) * Math.pow(Math.abs(c), p),
|
|
1434
|
-
y: Math.sign(s) * Math.pow(Math.abs(s), p)
|
|
1458
|
+
y: Math.sign(s) * Math.pow(Math.abs(s), p),
|
|
1435
1459
|
};
|
|
1436
1460
|
}
|
|
1437
1461
|
var lame = {
|
|
@@ -1439,7 +1463,7 @@ var lame = {
|
|
|
1439
1463
|
fn: lameFn,
|
|
1440
1464
|
period: TWO_PI8,
|
|
1441
1465
|
speed: 1,
|
|
1442
|
-
skeleton: "live"
|
|
1466
|
+
skeleton: "live",
|
|
1443
1467
|
};
|
|
1444
1468
|
|
|
1445
1469
|
// src/curves/rose3.ts
|
|
@@ -1448,14 +1472,14 @@ function rose3Fn(t, _time, _params) {
|
|
|
1448
1472
|
const r = Math.cos(3 * t);
|
|
1449
1473
|
return {
|
|
1450
1474
|
x: r * Math.cos(t),
|
|
1451
|
-
y: r * Math.sin(t)
|
|
1475
|
+
y: r * Math.sin(t),
|
|
1452
1476
|
};
|
|
1453
1477
|
}
|
|
1454
1478
|
var rose3 = {
|
|
1455
1479
|
name: "Rose (n=3)",
|
|
1456
1480
|
fn: rose3Fn,
|
|
1457
1481
|
period: TWO_PI9,
|
|
1458
|
-
speed: 1.15
|
|
1482
|
+
speed: 1.15,
|
|
1459
1483
|
};
|
|
1460
1484
|
|
|
1461
1485
|
// src/curves/rose5.ts
|
|
@@ -1464,78 +1488,87 @@ function rose5Fn(t, _time, _params) {
|
|
|
1464
1488
|
const r = Math.cos(5 * t);
|
|
1465
1489
|
return {
|
|
1466
1490
|
x: r * Math.cos(t),
|
|
1467
|
-
y: r * Math.sin(t)
|
|
1491
|
+
y: r * Math.sin(t),
|
|
1468
1492
|
};
|
|
1469
1493
|
}
|
|
1470
1494
|
var rose5 = {
|
|
1471
1495
|
name: "Rose (n=5)",
|
|
1472
1496
|
fn: rose5Fn,
|
|
1473
1497
|
period: TWO_PI10,
|
|
1474
|
-
speed: 1
|
|
1498
|
+
speed: 1,
|
|
1475
1499
|
};
|
|
1476
1500
|
|
|
1477
1501
|
// src/curves/rose52.ts
|
|
1478
1502
|
var FOUR_PI = Math.PI * 4;
|
|
1479
1503
|
function rose52Fn(t, _time, _params) {
|
|
1480
|
-
const r = Math.cos(5 / 2 * t);
|
|
1504
|
+
const r = Math.cos((5 / 2) * t);
|
|
1481
1505
|
return {
|
|
1482
1506
|
x: r * Math.cos(t),
|
|
1483
|
-
y: r * Math.sin(t)
|
|
1507
|
+
y: r * Math.sin(t),
|
|
1484
1508
|
};
|
|
1485
1509
|
}
|
|
1486
1510
|
var rose52 = {
|
|
1487
1511
|
name: "Rose (n=5/2)",
|
|
1488
1512
|
fn: rose52Fn,
|
|
1489
1513
|
period: FOUR_PI,
|
|
1490
|
-
speed: 0.8
|
|
1514
|
+
speed: 0.8,
|
|
1491
1515
|
};
|
|
1492
1516
|
|
|
1493
1517
|
// src/curves/star.ts
|
|
1494
1518
|
var TWO_PI11 = Math.PI * 2;
|
|
1495
1519
|
function starFn(t, _time, _params) {
|
|
1496
|
-
const r =
|
|
1520
|
+
const r =
|
|
1521
|
+
Math.abs(Math.cos((5 / 2) * t)) +
|
|
1522
|
+
0.35 * Math.abs(Math.cos((15 / 2) * t)) +
|
|
1523
|
+
0.15 * Math.abs(Math.cos((25 / 2) * t));
|
|
1497
1524
|
return {
|
|
1498
1525
|
x: r * Math.cos(t),
|
|
1499
|
-
y: r * Math.sin(t)
|
|
1526
|
+
y: r * Math.sin(t),
|
|
1500
1527
|
};
|
|
1501
1528
|
}
|
|
1502
1529
|
var star = {
|
|
1503
1530
|
name: "Star",
|
|
1504
1531
|
fn: starFn,
|
|
1505
1532
|
period: TWO_PI11,
|
|
1506
|
-
speed: 1
|
|
1533
|
+
speed: 1,
|
|
1507
1534
|
};
|
|
1508
1535
|
|
|
1509
1536
|
// src/curves/star4.ts
|
|
1510
1537
|
var TWO_PI12 = Math.PI * 2;
|
|
1511
1538
|
function star4Fn(t, _time, _params) {
|
|
1512
|
-
const r =
|
|
1539
|
+
const r =
|
|
1540
|
+
Math.abs(Math.cos(2 * t)) +
|
|
1541
|
+
0.35 * Math.abs(Math.cos(6 * t)) +
|
|
1542
|
+
0.15 * Math.abs(Math.cos(10 * t));
|
|
1513
1543
|
return {
|
|
1514
1544
|
x: r * Math.cos(t),
|
|
1515
|
-
y: r * Math.sin(t)
|
|
1545
|
+
y: r * Math.sin(t),
|
|
1516
1546
|
};
|
|
1517
1547
|
}
|
|
1518
1548
|
var star4 = {
|
|
1519
1549
|
name: "Star (4-arm)",
|
|
1520
1550
|
fn: star4Fn,
|
|
1521
1551
|
period: TWO_PI12,
|
|
1522
|
-
speed: 1
|
|
1552
|
+
speed: 1,
|
|
1523
1553
|
};
|
|
1524
1554
|
|
|
1525
1555
|
// src/curves/star7.ts
|
|
1526
1556
|
var TWO_PI13 = Math.PI * 2;
|
|
1527
1557
|
function star7Fn(t, _time, _params) {
|
|
1528
|
-
const r =
|
|
1558
|
+
const r =
|
|
1559
|
+
Math.abs(Math.cos((7 / 2) * t)) +
|
|
1560
|
+
0.35 * Math.abs(Math.cos((21 / 2) * t)) +
|
|
1561
|
+
0.15 * Math.abs(Math.cos((35 / 2) * t));
|
|
1529
1562
|
return {
|
|
1530
1563
|
x: r * Math.cos(t),
|
|
1531
|
-
y: r * Math.sin(t)
|
|
1564
|
+
y: r * Math.sin(t),
|
|
1532
1565
|
};
|
|
1533
1566
|
}
|
|
1534
1567
|
var star7 = {
|
|
1535
1568
|
name: "Star (7-arm)",
|
|
1536
1569
|
fn: star7Fn,
|
|
1537
1570
|
period: TWO_PI13,
|
|
1538
|
-
speed: 1
|
|
1571
|
+
speed: 1,
|
|
1539
1572
|
};
|
|
1540
1573
|
|
|
1541
1574
|
// src/curves/index.ts
|
|
@@ -1553,7 +1586,7 @@ var curves = {
|
|
|
1553
1586
|
lissajous32,
|
|
1554
1587
|
lissajous43,
|
|
1555
1588
|
epicycloid3,
|
|
1556
|
-
lame
|
|
1589
|
+
lame,
|
|
1557
1590
|
};
|
|
1558
1591
|
|
|
1559
1592
|
// src/index.ts
|
|
@@ -1563,6 +1596,27 @@ function createSarmal(canvas, curveDef, options) {
|
|
|
1563
1596
|
return createRenderer({ canvas, engine, ...rendererOpts });
|
|
1564
1597
|
}
|
|
1565
1598
|
|
|
1566
|
-
export {
|
|
1599
|
+
export {
|
|
1600
|
+
artemis2,
|
|
1601
|
+
astroid,
|
|
1602
|
+
computeBoundaries,
|
|
1603
|
+
createEngine,
|
|
1604
|
+
createRenderer,
|
|
1605
|
+
createSVGRenderer,
|
|
1606
|
+
createSarmal,
|
|
1607
|
+
createSarmalSVG,
|
|
1608
|
+
curves,
|
|
1609
|
+
deltoid,
|
|
1610
|
+
drawCurve,
|
|
1611
|
+
epicycloid3,
|
|
1612
|
+
epitrochoid7,
|
|
1613
|
+
evaluateCatmullRom,
|
|
1614
|
+
lame,
|
|
1615
|
+
lissajous32,
|
|
1616
|
+
lissajous43,
|
|
1617
|
+
palettes,
|
|
1618
|
+
rose3,
|
|
1619
|
+
rose5,
|
|
1620
|
+
};
|
|
1621
|
+
//# sourceMappingURL=index.js.map
|
|
1567
1622
|
//# sourceMappingURL=index.js.map
|
|
1568
|
-
//# sourceMappingURL=index.js.map
|