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