@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/auto-init.js CHANGED
@@ -61,32 +61,32 @@ 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);
74
74
  const trail = new CircularBuffer(trailLength);
75
- let t = 0;
75
+ let phase = 0;
76
76
  let actualTime = 0;
77
77
  let userSpeedOverride = null;
78
78
  let morphCurveB = null;
79
79
  let _morphAlpha = null;
80
80
  let _morphStrategy = "normalized";
81
81
  let _speedTransition = null;
82
- function sampleSkeleton(c, sampleT) {
82
+ function sampleSkeleton(c, samplePhase) {
83
83
  if (c.skeletonFn) {
84
- return c.skeletonFn(sampleT);
84
+ return c.skeletonFn(samplePhase);
85
85
  }
86
86
  if (c.skeleton === "live") {
87
- return c.fn(sampleT, actualTime, EMPTY_PARAMS);
87
+ return c.fn(samplePhase, actualTime, EMPTY_PARAMS);
88
88
  }
89
- return c.fn(sampleT, 0, EMPTY_PARAMS);
89
+ return c.fn(samplePhase, 0, EMPTY_PARAMS);
90
90
  }
91
91
  return {
92
92
  tick(deltaTime) {
@@ -104,15 +104,15 @@ function createEngine(curveDef, trailLength = 120) {
104
104
  if (morphCurveB !== null && _morphAlpha !== null) {
105
105
  effectiveSpeed = lerp(effectiveSpeed, morphCurveB.speed, _morphAlpha);
106
106
  }
107
- t = (t + effectiveSpeed * deltaTime) % curve.period;
107
+ phase = (phase + effectiveSpeed * deltaTime) % curve.period;
108
108
  actualTime += deltaTime;
109
109
  if (morphCurveB !== null && _morphAlpha !== null) {
110
- const a = curve.fn(t, actualTime, EMPTY_PARAMS);
111
- const tB = _morphStrategy === "normalized" ? (t / curve.period) * morphCurveB.period : t;
112
- const b = morphCurveB.fn(tB, actualTime, EMPTY_PARAMS);
110
+ const a = curve.fn(phase, actualTime, EMPTY_PARAMS);
111
+ const phaseB = _morphStrategy === "normalized" ? phase / curve.period * morphCurveB.period : phase;
112
+ const b = morphCurveB.fn(phaseB, actualTime, EMPTY_PARAMS);
113
113
  trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
114
114
  } else {
115
- const point = curve.fn(t, actualTime, EMPTY_PARAMS);
115
+ const point = curve.fn(phase, actualTime, EMPTY_PARAMS);
116
116
  trail.push(point.x, point.y);
117
117
  }
118
118
  return trail.toArray();
@@ -130,30 +130,30 @@ function createEngine(curveDef, trailLength = 120) {
130
130
  return _morphAlpha;
131
131
  },
132
132
  reset() {
133
- t = 0;
133
+ phase = 0;
134
134
  actualTime = 0;
135
135
  trail.clear();
136
136
  },
137
- jump(newT, { clearTrail = false } = {}) {
138
- t = ((newT % curve.period) + curve.period) % curve.period;
137
+ jump(newPhase, { clearTrail = false } = {}) {
138
+ phase = (newPhase % curve.period + curve.period) % curve.period;
139
139
  if (clearTrail) {
140
140
  trail.clear();
141
141
  }
142
142
  },
143
- seek(targetT, { wrap = false, step = curve.period / trailLength } = {}) {
143
+ seek(targetPhase, { 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 = (targetPhase % curve.period + curve.period) % curve.period;
146
146
  const targetTime = target / curve.speed;
147
- t = target;
147
+ phase = target;
148
148
  actualTime = targetTime;
149
149
  trail.clear();
150
150
  const pointsFromStart = Math.floor(target / advance) + 1;
151
151
  const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
152
152
  for (let i = count - 1; i >= 0; i--) {
153
- const sampleT = target - i * advance;
154
- const wrappedT = ((sampleT % curve.period) + curve.period) % curve.period;
155
- const time = targetTime - i * step;
156
- const point = curve.fn(wrappedT, time, EMPTY_PARAMS);
153
+ const samplePhase = target - i * advance;
154
+ const wrappedPhase = (samplePhase % curve.period + curve.period) % curve.period;
155
+ const elapsed = targetTime - i * step;
156
+ const point = curve.fn(wrappedPhase, elapsed, EMPTY_PARAMS);
157
157
  trail.push(point.x, point.y);
158
158
  }
159
159
  },
@@ -166,18 +166,15 @@ function createEngine(curveDef, trailLength = 120) {
166
166
  const frozenStrategy = _morphStrategy;
167
167
  curve = {
168
168
  ...frozenB,
169
- fn: (sampleT, time, params) => {
170
- const a = frozenA.fn(sampleT, time, params);
171
- const tB =
172
- frozenStrategy === "normalized"
173
- ? (sampleT / frozenA.period) * frozenB.period
174
- : sampleT;
175
- const b = frozenB.fn(tB, time, params);
169
+ fn: (samplePhase, elapsed, params) => {
170
+ const a = frozenA.fn(samplePhase, elapsed, params);
171
+ const phaseB = frozenStrategy === "normalized" ? samplePhase / frozenA.period * frozenB.period : samplePhase;
172
+ const b = frozenB.fn(phaseB, elapsed, params);
176
173
  return {
177
174
  x: a.x + (b.x - a.x) * frozenAlpha,
178
- y: a.y + (b.y - a.y) * frozenAlpha,
175
+ y: a.y + (b.y - a.y) * frozenAlpha
179
176
  };
180
- },
177
+ }
181
178
  };
182
179
  }
183
180
  _morphStrategy = strategy;
@@ -190,7 +187,7 @@ function createEngine(curveDef, trailLength = 120) {
190
187
  completeMorph() {
191
188
  if (morphCurveB !== null) {
192
189
  if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
193
- t = (t / curve.period) * morphCurveB.period;
190
+ phase = phase / curve.period * morphCurveB.period;
194
191
  }
195
192
  curve = morphCurveB;
196
193
  }
@@ -202,23 +199,20 @@ function createEngine(curveDef, trailLength = 120) {
202
199
  const points2 = new Array(steps);
203
200
  if (morphCurveB !== null && _morphAlpha !== null) {
204
201
  for (let i = 0; i < steps; i++) {
205
- const sampleT = (i / (steps - 1)) * curve.period;
206
- const a = sampleSkeleton(curve, sampleT);
207
- const tB =
208
- _morphStrategy === "normalized"
209
- ? (sampleT / curve.period) * morphCurveB.period
210
- : sampleT;
211
- const b = sampleSkeleton(morphCurveB, tB);
202
+ const samplePhase = i / (steps - 1) * curve.period;
203
+ const a = sampleSkeleton(curve, samplePhase);
204
+ const phaseB = _morphStrategy === "normalized" ? samplePhase / curve.period * morphCurveB.period : samplePhase;
205
+ const b = sampleSkeleton(morphCurveB, phaseB);
212
206
  points2[i] = {
213
207
  x: a.x + (b.x - a.x) * _morphAlpha,
214
- y: a.y + (b.y - a.y) * _morphAlpha,
208
+ y: a.y + (b.y - a.y) * _morphAlpha
215
209
  };
216
210
  }
217
211
  return points2;
218
212
  }
219
213
  for (let i = 0; i < steps; i++) {
220
- const sampleT = (i / (steps - 1)) * curve.period;
221
- points2[i] = sampleSkeleton(curve, sampleT);
214
+ const samplePhase = i / (steps - 1) * curve.period;
215
+ points2[i] = sampleSkeleton(curve, samplePhase);
222
216
  }
223
217
  return points2;
224
218
  },
@@ -259,7 +253,7 @@ function createEngine(curveDef, trailLength = 120) {
259
253
  _speedTransition.reject(new Error("Speed transition cancelled"));
260
254
  _speedTransition = null;
261
255
  }
262
- },
256
+ }
263
257
  };
264
258
  }
265
259
 
@@ -298,15 +292,7 @@ function computeNormal(trail, i) {
298
292
  const tangent = computeTangent(trail, i);
299
293
  return { x: -tangent.y, y: tangent.x };
300
294
  }
301
- function computeTrailQuad(
302
- trail,
303
- i,
304
- trailCount,
305
- toX,
306
- toY,
307
- minWidth = TRAIL_MIN_WIDTH,
308
- maxWidth = TRAIL_MAX_WIDTH,
309
- ) {
295
+ function computeTrailQuad(trail, i, trailCount, toX, toY, minWidth = TRAIL_MIN_WIDTH, maxWidth = TRAIL_MAX_WIDTH) {
310
296
  const progress = i / (trailCount - 1);
311
297
  const nextProgress = (i + 1) / (trailCount - 1);
312
298
  const opacity = Math.pow(progress, TRAIL_FADE_CURVE) * TRAIL_MAX_OPACITY;
@@ -330,16 +316,13 @@ function computeTrailQuad(
330
316
  r1x: nx - n1.x * w1,
331
317
  r1y: ny - n1.y * w1,
332
318
  opacity,
333
- progress,
319
+ progress
334
320
  };
335
321
  }
336
322
  function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_PADDING_MIN) {
337
323
  if (pts.length === 0) return null;
338
324
  const first = pts[0];
339
- let minX = first.x,
340
- maxX = first.x,
341
- minY = first.y,
342
- maxY = first.y;
325
+ let minX = first.x, maxX = first.x, minY = first.y, maxY = first.y;
343
326
  for (const p of pts) {
344
327
  if (p.x < minX) {
345
328
  minX = p.x;
@@ -358,7 +341,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
358
341
  const h = maxY - minY;
359
342
  if (w === 0 && h === 0) {
360
343
  throw new Error(
361
- "[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t.",
344
+ "[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
362
345
  );
363
346
  }
364
347
  const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
@@ -369,12 +352,12 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
369
352
  scaleXProportional,
370
353
  scaleYProportional,
371
354
  scaleXMinPadding,
372
- scaleYMinPadding,
355
+ scaleYMinPadding
373
356
  );
374
357
  return {
375
358
  scale,
376
359
  offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
377
- offsetY: (logicalHeight - h * scale) / 2 - minY * scale,
360
+ offsetY: (logicalHeight - h * scale) / 2 - minY * scale
378
361
  };
379
362
  }
380
363
  function enginePassthroughs(engine) {
@@ -385,17 +368,17 @@ function enginePassthroughs(engine) {
385
368
  getSpeed: engine.getSpeed,
386
369
  resetSpeed: engine.resetSpeed,
387
370
  setSpeedOver: engine.setSpeedOver,
388
- getSarmalSkeleton: engine.getSarmalSkeleton,
371
+ getSarmalSkeleton: engine.getSarmalSkeleton
389
372
  };
390
373
  }
391
374
  function hexToRgb(hex) {
392
375
  const n = parseInt(hex.slice(1), 16);
393
- return { r: n >> 16, g: (n >> 8) & 255, b: n & 255 };
376
+ return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
394
377
  }
395
378
  var lerpRgb = (a, b, t) => ({
396
379
  r: Math.round(a.r + (b.r - a.r) * t),
397
380
  g: Math.round(a.g + (b.g - a.g) * t),
398
- b: Math.round(a.b + (b.b - a.b) * t),
381
+ b: Math.round(a.b + (b.b - a.b) * t)
399
382
  });
400
383
  function getPaletteColor(palette, position, timeOffset = 0) {
401
384
  if (palette.length === 0) {
@@ -404,7 +387,7 @@ function getPaletteColor(palette, position, timeOffset = 0) {
404
387
  if (palette.length === 1) {
405
388
  return hexToRgb(palette[0]);
406
389
  }
407
- const cyclePos = (((position + timeOffset) % 1) + 1) % 1;
390
+ const cyclePos = ((position + timeOffset) % 1 + 1) % 1;
408
391
  const scaled = cyclePos * palette.length;
409
392
  const idx = Math.floor(scaled);
410
393
  const t = scaled - idx;
@@ -419,7 +402,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
419
402
  "headColor",
420
403
  "skeletonColor",
421
404
  "trailStyle",
422
- "headRadius",
405
+ "headRadius"
423
406
  ]);
424
407
  function validateRenderOptions(partial) {
425
408
  for (const key of Object.keys(partial)) {
@@ -447,7 +430,7 @@ function assertTrailColor(value) {
447
430
  if (typeof value === "string") {
448
431
  if (!HEX_COLOR_RE.test(value)) {
449
432
  throw new TypeError(
450
- `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`,
433
+ `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`
451
434
  );
452
435
  }
453
436
  return;
@@ -455,21 +438,21 @@ function assertTrailColor(value) {
455
438
  if (Array.isArray(value)) {
456
439
  if (value.length < 2) {
457
440
  throw new RangeError(
458
- `[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`,
441
+ `[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`
459
442
  );
460
443
  }
461
444
  for (let i = 0; i < value.length; i++) {
462
445
  const entry = value[i];
463
446
  if (typeof entry !== "string" || !HEX_COLOR_RE.test(entry)) {
464
447
  throw new TypeError(
465
- `[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`,
448
+ `[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`
466
449
  );
467
450
  }
468
451
  }
469
452
  return;
470
453
  }
471
454
  throw new TypeError(
472
- `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`,
455
+ `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`
473
456
  );
474
457
  }
475
458
  function assertHeadColor(value) {
@@ -478,7 +461,7 @@ function assertHeadColor(value) {
478
461
  }
479
462
  if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
480
463
  throw new TypeError(
481
- `[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`,
464
+ `[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`
482
465
  );
483
466
  }
484
467
  }
@@ -488,26 +471,26 @@ function assertSkeletonColor(value) {
488
471
  }
489
472
  if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
490
473
  throw new TypeError(
491
- `[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`,
474
+ `[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`
492
475
  );
493
476
  }
494
477
  }
495
478
  function assertTrailStyle(value) {
496
479
  if (!TRAIL_STYLES.includes(value)) {
497
480
  throw new RangeError(
498
- `[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`,
481
+ `[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`
499
482
  );
500
483
  }
501
484
  }
502
485
  function assertHeadRadius(value) {
503
486
  if (typeof value !== "number") {
504
487
  throw new TypeError(
505
- `[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`,
488
+ `[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`
506
489
  );
507
490
  }
508
491
  if (!Number.isFinite(value) || value <= 0) {
509
492
  throw new TypeError(
510
- `[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`,
493
+ `[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`
511
494
  );
512
495
  }
513
496
  }
@@ -529,13 +512,13 @@ function resolveHeadColor(trailColor, trailStyle) {
529
512
  function warnIfTrailColorMismatch(trailColor, trailStyle) {
530
513
  if (trailStyle === "default" && Array.isArray(trailColor)) {
531
514
  console.warn(
532
- '[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.',
515
+ '[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.'
533
516
  );
534
517
  return;
535
518
  }
536
519
  if (trailStyle !== "default" && typeof trailColor === "string") {
537
520
  console.warn(
538
- `[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.`,
521
+ `[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.`
539
522
  );
540
523
  }
541
524
  }
@@ -545,7 +528,7 @@ var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160)
545
528
  var WHITE_HEX = "#ffffff";
546
529
  function hexToRgbComponents(hex) {
547
530
  const n = parseInt(hex.slice(1), 16);
548
- return `${n >> 16},${(n >> 8) & 255},${n & 255}`;
531
+ return `${n >> 16},${n >> 8 & 255},${n & 255}`;
549
532
  }
550
533
  function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
551
534
  target.style.width = `${logicalWidth}px`;
@@ -672,7 +655,7 @@ function createRenderer(options) {
672
655
  i,
673
656
  trailCount,
674
657
  toX,
675
- toY,
658
+ toY
676
659
  );
677
660
  if (trailStyle === "default") {
678
661
  ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
@@ -752,8 +735,8 @@ function createRenderer(options) {
752
735
  if (!engine.isLiveSkeleton) {
753
736
  buildSkeletonCanvas();
754
737
  }
755
- if (options.initialT !== void 0) {
756
- engine.seek(options.initialT);
738
+ if (options.initialPhase !== void 0) {
739
+ engine.seek(options.initialPhase);
757
740
  }
758
741
  renderFrame(0);
759
742
  const shouldAutoStart = options.autoStart !== false;
@@ -837,7 +820,7 @@ function createRenderer(options) {
837
820
  if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
838
821
  warnIfTrailColorMismatch(trailColor, trailStyle);
839
822
  }
840
- },
823
+ }
841
824
  };
842
825
  const pauseOnHidden = options.pauseOnHidden !== false;
843
826
  function handleVisibilityChange() {
@@ -887,8 +870,8 @@ function sampleCurveSkeleton(curveDef) {
887
870
  const samples = Math.ceil(period * 50);
888
871
  const pts = Array.from({ length: samples });
889
872
  for (let i = 0; i < samples; i++) {
890
- const t = (i / (samples - 1)) * period;
891
- pts[i] = curveDef.skeletonFn ? curveDef.skeletonFn(t) : curveDef.fn(t, 0, EMPTY_PARAMS2);
873
+ const phase = i / (samples - 1) * period;
874
+ pts[i] = curveDef.skeletonFn ? curveDef.skeletonFn(phase) : curveDef.fn(phase, 0, EMPTY_PARAMS2);
892
875
  }
893
876
  return pts;
894
877
  }
@@ -900,7 +883,7 @@ function createSVGRenderer(options) {
900
883
  const poolSize = engine.trailLength;
901
884
  if (poolSize > HIGH_TRAIL_LENGTH_THRESHOLD) {
902
885
  console.warn(
903
- `[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails.`,
886
+ `[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails.`
904
887
  );
905
888
  }
906
889
  let trailStyle = options.trailStyle ?? "default";
@@ -919,9 +902,9 @@ function createSVGRenderer(options) {
919
902
  return rect.width && rect.height ? Math.min(rect.width, rect.height) : 200;
920
903
  }
921
904
  const containerPx = getContainerPixelSize();
922
- const svgTrailMinWidth = (TRAIL_MIN_WIDTH * viewSize) / containerPx;
923
- const svgTrailMaxWidth = (TRAIL_MAX_WIDTH * viewSize) / containerPx;
924
- const svgSkeletonStrokeWidth = String((SKELETON_STROKE_WIDTH_PX * viewSize) / containerPx);
905
+ const svgTrailMinWidth = TRAIL_MIN_WIDTH * viewSize / containerPx;
906
+ const svgTrailMaxWidth = TRAIL_MAX_WIDTH * viewSize / containerPx;
907
+ const svgSkeletonStrokeWidth = String(SKELETON_STROKE_WIDTH_PX * viewSize / containerPx);
925
908
  headRadius = options.headRadius ?? SVG_DEFAULT_HEAD_RADIUS;
926
909
  container.setAttribute("viewBox", `0 0 ${viewSize} ${viewSize}`);
927
910
  container.setAttribute("role", "img");
@@ -1009,7 +992,7 @@ function createSVGRenderer(options) {
1009
992
  px,
1010
993
  py,
1011
994
  svgTrailMinWidth,
1012
- svgTrailMaxWidth,
995
+ svgTrailMaxWidth
1013
996
  );
1014
997
  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`;
1015
998
  trailPaths[i].setAttribute("d", d);
@@ -1037,8 +1020,7 @@ function createSVGRenderer(options) {
1037
1020
  let animationId = null;
1038
1021
  let lastTime = 0;
1039
1022
  let pausedByVisibility = false;
1040
- const prefersReducedMotion =
1041
- typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1023
+ const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1042
1024
  let morphResolve = null;
1043
1025
  let morphReject = null;
1044
1026
  let morphDurationMs = DEFAULT_MORPH_DURATION_MS;
@@ -1056,7 +1038,7 @@ function createSVGRenderer(options) {
1056
1038
  skeletonPathA.setAttribute("visibility", "visible");
1057
1039
  skeletonPathA.setAttribute(
1058
1040
  "stroke-opacity",
1059
- String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY),
1041
+ String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY)
1060
1042
  );
1061
1043
  }
1062
1044
  if (morphPathBBuilt) {
@@ -1099,8 +1081,8 @@ function createSVGRenderer(options) {
1099
1081
  animationId = requestAnimationFrame(loop);
1100
1082
  }
1101
1083
  }
1102
- if (options.initialT !== void 0) {
1103
- engine.seek(options.initialT);
1084
+ if (options.initialPhase !== void 0) {
1085
+ engine.seek(options.initialPhase);
1104
1086
  }
1105
1087
  renderFrame(0);
1106
1088
  const shouldAutoStart = options.autoStart !== false;
@@ -1210,7 +1192,7 @@ function createSVGRenderer(options) {
1210
1192
  if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
1211
1193
  warnIfTrailColorMismatch(trailColor, trailStyle);
1212
1194
  }
1213
- },
1195
+ }
1214
1196
  };
1215
1197
  const pauseOnHidden = options.pauseOnHidden !== false;
1216
1198
  function handleVisibilityChange() {
@@ -1248,15 +1230,9 @@ var PERIOD = 2 * Math.PI;
1248
1230
  function catmullRom1D(p0, p1, p2, p3, u) {
1249
1231
  const u2 = u * u;
1250
1232
  const u3 = u2 * u;
1251
- return (
1252
- 0.5 *
1253
- (2 * p1 +
1254
- (-p0 + p2) * u +
1255
- (2 * p0 - 5 * p1 + 4 * p2 - p3) * u2 +
1256
- (-p0 + 3 * p1 - 3 * p2 + p3) * u3)
1257
- );
1233
+ return 0.5 * (2 * p1 + (-p0 + p2) * u + (2 * p0 - 5 * p1 + 4 * p2 - p3) * u2 + (-p0 + 3 * p1 - 3 * p2 + p3) * u3);
1258
1234
  }
1259
- function evaluateCatmullRom(points2, t) {
1235
+ function evaluateCatmullRom(points2, phase) {
1260
1236
  const N = points2.length;
1261
1237
  if (N === 0) {
1262
1238
  return { x: 0, y: 0 };
@@ -1264,13 +1240,13 @@ function evaluateCatmullRom(points2, t) {
1264
1240
  if (N === 1) {
1265
1241
  return { x: points2[0][0], y: points2[0][1] };
1266
1242
  }
1267
- t = ((t % PERIOD) + PERIOD) % PERIOD;
1243
+ phase = (phase % PERIOD + PERIOD) % PERIOD;
1268
1244
  const segmentSize = PERIOD / N;
1269
- let i = Math.floor(t / segmentSize);
1245
+ let i = Math.floor(phase / segmentSize);
1270
1246
  if (i >= N) {
1271
1247
  i = N - 1;
1272
1248
  }
1273
- let u = (t - i * segmentSize) / segmentSize;
1249
+ let u = (phase - i * segmentSize) / segmentSize;
1274
1250
  u = Math.max(0, Math.min(1, u));
1275
1251
  const p0 = points2[(i - 1 + N) % N];
1276
1252
  const p1 = points2[i];
@@ -1278,7 +1254,7 @@ function evaluateCatmullRom(points2, t) {
1278
1254
  const p3 = points2[(i + 2) % N];
1279
1255
  return {
1280
1256
  x: catmullRom1D(p0[0], p1[0], p2[0], p3[0], u),
1281
- y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u),
1257
+ y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u)
1282
1258
  };
1283
1259
  }
1284
1260
  function drawCurve(points2, opts) {
@@ -1288,20 +1264,20 @@ function drawCurve(points2, opts) {
1288
1264
  const first = points2[0];
1289
1265
  if (points2.every((p) => p[0] === first[0] && p[1] === first[1])) {
1290
1266
  console.warn(
1291
- "[sarmal].drawCurve: all control points are identical. The curve will be a single point.",
1267
+ "[sarmal].drawCurve: all control points are identical. The curve will be a single point."
1292
1268
  );
1293
1269
  }
1294
1270
  const maxAbs = points2.reduce((m, p) => Math.max(m, Math.abs(p[0]), Math.abs(p[1])), 0);
1295
1271
  if (maxAbs > 2) {
1296
1272
  console.warn(
1297
- `[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1].`,
1273
+ `[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1].`
1298
1274
  );
1299
1275
  }
1300
1276
  const pts = points2.map(([x, y]) => [x, y]);
1301
1277
  return {
1302
1278
  name: opts?.name ?? "drawn",
1303
- fn: (t) => evaluateCatmullRom(pts, t),
1304
- period: PERIOD,
1279
+ fn: (phase) => evaluateCatmullRom(pts, phase),
1280
+ period: PERIOD
1305
1281
  };
1306
1282
  }
1307
1283
 
@@ -1327,74 +1303,74 @@ var points = [
1327
1303
  [-0.69, -0.84],
1328
1304
  [-0.87, -0.66],
1329
1305
  [-0.9, -0.47],
1330
- [-0.76, -0.35],
1306
+ [-0.76, -0.35]
1331
1307
  ];
1332
1308
  var artemis2 = {
1333
1309
  ...drawCurve(points, { name: "Artemis II" }),
1334
- speed: 0.7,
1310
+ speed: 0.7
1335
1311
  };
1336
1312
 
1337
1313
  // src/curves/astroid.ts
1338
1314
  var TWO_PI2 = Math.PI * 2;
1339
- function astroidFn(t, _time, _params) {
1340
- const c = Math.cos(t);
1341
- const s = Math.sin(t);
1315
+ function astroidFn(phase, _elapsed, _params) {
1316
+ const c = Math.cos(phase);
1317
+ const s = Math.sin(phase);
1342
1318
  return {
1343
1319
  x: c * c * c,
1344
- y: s * s * s,
1320
+ y: s * s * s
1345
1321
  };
1346
1322
  }
1347
1323
  var astroid = {
1348
1324
  name: "Astroid",
1349
1325
  fn: astroidFn,
1350
1326
  period: TWO_PI2,
1351
- speed: 1.1,
1327
+ speed: 1.1
1352
1328
  };
1353
1329
 
1354
1330
  // src/curves/deltoid.ts
1355
1331
  var TWO_PI3 = Math.PI * 2;
1356
- function deltoidFn(t, _time, _params) {
1332
+ function deltoidFn(phase, _elapsed, _params) {
1357
1333
  return {
1358
- x: 2 * Math.cos(t) + Math.cos(2 * t),
1359
- y: 2 * Math.sin(t) - Math.sin(2 * t),
1334
+ x: 2 * Math.cos(phase) + Math.cos(2 * phase),
1335
+ y: 2 * Math.sin(phase) - Math.sin(2 * phase)
1360
1336
  };
1361
1337
  }
1362
1338
  var deltoid = {
1363
1339
  name: "Deltoid",
1364
1340
  fn: deltoidFn,
1365
1341
  period: TWO_PI3,
1366
- speed: 0.9,
1342
+ speed: 0.9
1367
1343
  };
1368
1344
 
1369
1345
  // src/curves/epicycloid3.ts
1370
1346
  var TWO_PI4 = Math.PI * 2;
1371
- function epicycloid3Fn(t, _time, _params) {
1347
+ function epicycloid3Fn(phase, _elapsed, _params) {
1372
1348
  return {
1373
- x: 4 * Math.cos(t) - Math.cos(4 * t),
1374
- y: 4 * Math.sin(t) - Math.sin(4 * t),
1349
+ x: 4 * Math.cos(phase) - Math.cos(4 * phase),
1350
+ y: 4 * Math.sin(phase) - Math.sin(4 * phase)
1375
1351
  };
1376
1352
  }
1377
1353
  var epicycloid3 = {
1378
1354
  name: "Epicycloid (n=3)",
1379
1355
  fn: epicycloid3Fn,
1380
1356
  period: TWO_PI4,
1381
- speed: 0.75,
1357
+ speed: 0.75
1382
1358
  };
1383
1359
 
1384
1360
  // src/curves/epitrochoid7.ts
1385
1361
  var TWO_PI5 = Math.PI * 2;
1386
- function epitrochoid7Fn(t, _time, _params) {
1387
- const d = 1 + 0.55 * Math.sin(t * 0.5);
1362
+ function epitrochoid7Fn(phase, _elapsed, _params) {
1363
+ const d = 1 + 0.55 * Math.sin(phase * 0.5);
1388
1364
  return {
1389
- x: 7 * Math.cos(t) - d * Math.cos(7 * t),
1390
- y: 7 * Math.sin(t) - d * Math.sin(7 * t),
1365
+ x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
1366
+ y: 7 * Math.sin(phase) - d * Math.sin(7 * phase)
1391
1367
  };
1392
1368
  }
1393
- function epitrochoid7SkeletonFn(t) {
1369
+ function epitrochoid7SkeletonFn(phase) {
1394
1370
  const d = 1.275;
1395
1371
  return {
1396
- x: 7 * Math.cos(t) - d * Math.cos(7 * t),
1397
- y: 7 * Math.sin(t) - d * Math.sin(7 * t),
1372
+ x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
1373
+ y: 7 * Math.sin(phase) - d * Math.sin(7 * phase)
1398
1374
  };
1399
1375
  }
1400
1376
  var epitrochoid7 = {
@@ -1402,16 +1378,16 @@ var epitrochoid7 = {
1402
1378
  fn: epitrochoid7Fn,
1403
1379
  period: TWO_PI5,
1404
1380
  speed: 1.4,
1405
- skeletonFn: epitrochoid7SkeletonFn,
1381
+ skeletonFn: epitrochoid7SkeletonFn
1406
1382
  };
1407
1383
 
1408
1384
  // src/curves/lissajous32.ts
1409
1385
  var TWO_PI6 = Math.PI * 2;
1410
- function lissajous32Fn(t, time, _params) {
1411
- const phi = time * 0.45;
1386
+ function lissajous32Fn(phase, elapsed, _params) {
1387
+ const phi = elapsed * 0.45;
1412
1388
  return {
1413
- x: Math.sin(3 * t + phi),
1414
- y: Math.sin(2 * t),
1389
+ x: Math.sin(3 * phase + phi),
1390
+ y: Math.sin(2 * phase)
1415
1391
  };
1416
1392
  }
1417
1393
  var lissajous32 = {
@@ -1419,16 +1395,16 @@ var lissajous32 = {
1419
1395
  fn: lissajous32Fn,
1420
1396
  period: TWO_PI6,
1421
1397
  speed: 2,
1422
- skeleton: "live",
1398
+ skeleton: "live"
1423
1399
  };
1424
1400
 
1425
1401
  // src/curves/lissajous43.ts
1426
1402
  var TWO_PI7 = Math.PI * 2;
1427
- function lissajous43Fn(t, time, _params) {
1428
- const phi = time * 0.38;
1403
+ function lissajous43Fn(phase, elapsed, _params) {
1404
+ const phi = elapsed * 0.38;
1429
1405
  return {
1430
- x: Math.sin(4 * t + phi),
1431
- y: Math.sin(3 * t),
1406
+ x: Math.sin(4 * phase + phi),
1407
+ y: Math.sin(3 * phase)
1432
1408
  };
1433
1409
  }
1434
1410
  var lissajous43 = {
@@ -1436,18 +1412,17 @@ var lissajous43 = {
1436
1412
  fn: lissajous43Fn,
1437
1413
  period: TWO_PI7,
1438
1414
  speed: 1.8,
1439
- skeleton: "live",
1415
+ skeleton: "live"
1440
1416
  };
1441
1417
 
1442
1418
  // src/curves/lame.ts
1443
1419
  var TWO_PI8 = Math.PI * 2;
1444
- function lameFn(t, time, _params) {
1445
- const p = 1.75 + 1.25 * Math.sin(time * 0.48);
1446
- const c = Math.cos(t),
1447
- s = Math.sin(t);
1420
+ function lameFn(phase, elapsed, _params) {
1421
+ const p = 1.75 + 1.25 * Math.sin(elapsed * 0.48);
1422
+ const c = Math.cos(phase), s = Math.sin(phase);
1448
1423
  return {
1449
1424
  x: Math.sign(c) * Math.pow(Math.abs(c), p),
1450
- y: Math.sign(s) * Math.pow(Math.abs(s), p),
1425
+ y: Math.sign(s) * Math.pow(Math.abs(s), p)
1451
1426
  };
1452
1427
  }
1453
1428
  var lame = {
@@ -1455,112 +1430,103 @@ var lame = {
1455
1430
  fn: lameFn,
1456
1431
  period: TWO_PI8,
1457
1432
  speed: 1,
1458
- skeleton: "live",
1433
+ skeleton: "live"
1459
1434
  };
1460
1435
 
1461
1436
  // src/curves/rose3.ts
1462
1437
  var TWO_PI9 = Math.PI * 2;
1463
- function rose3Fn(t, _time, _params) {
1464
- const r = Math.cos(3 * t);
1438
+ function rose3Fn(phase, _elapsed, _params) {
1439
+ const r = Math.cos(3 * phase);
1465
1440
  return {
1466
- x: r * Math.cos(t),
1467
- y: r * Math.sin(t),
1441
+ x: r * Math.cos(phase),
1442
+ y: r * Math.sin(phase)
1468
1443
  };
1469
1444
  }
1470
1445
  var rose3 = {
1471
1446
  name: "Rose (n=3)",
1472
1447
  fn: rose3Fn,
1473
1448
  period: TWO_PI9,
1474
- speed: 1.15,
1449
+ speed: 1.15
1475
1450
  };
1476
1451
 
1477
1452
  // src/curves/rose5.ts
1478
1453
  var TWO_PI10 = Math.PI * 2;
1479
- function rose5Fn(t, _time, _params) {
1480
- const r = Math.cos(5 * t);
1454
+ function rose5Fn(phase, _elapsed, _params) {
1455
+ const r = Math.cos(5 * phase);
1481
1456
  return {
1482
- x: r * Math.cos(t),
1483
- y: r * Math.sin(t),
1457
+ x: r * Math.cos(phase),
1458
+ y: r * Math.sin(phase)
1484
1459
  };
1485
1460
  }
1486
1461
  var rose5 = {
1487
1462
  name: "Rose (n=5)",
1488
1463
  fn: rose5Fn,
1489
1464
  period: TWO_PI10,
1490
- speed: 1,
1465
+ speed: 1
1491
1466
  };
1492
1467
 
1493
1468
  // src/curves/rose52.ts
1494
1469
  var FOUR_PI = Math.PI * 4;
1495
- function rose52Fn(t, _time, _params) {
1496
- const r = Math.cos((5 / 2) * t);
1470
+ function rose52Fn(phase, _elapsed, _params) {
1471
+ const r = Math.cos(5 / 2 * phase);
1497
1472
  return {
1498
- x: r * Math.cos(t),
1499
- y: r * Math.sin(t),
1473
+ x: r * Math.cos(phase),
1474
+ y: r * Math.sin(phase)
1500
1475
  };
1501
1476
  }
1502
1477
  var rose52 = {
1503
1478
  name: "Rose (n=5/2)",
1504
1479
  fn: rose52Fn,
1505
1480
  period: FOUR_PI,
1506
- speed: 0.8,
1481
+ speed: 0.8
1507
1482
  };
1508
1483
 
1509
1484
  // src/curves/star.ts
1510
1485
  var TWO_PI11 = Math.PI * 2;
1511
- function starFn(t, _time, _params) {
1512
- const r =
1513
- Math.abs(Math.cos((5 / 2) * t)) +
1514
- 0.35 * Math.abs(Math.cos((15 / 2) * t)) +
1515
- 0.15 * Math.abs(Math.cos((25 / 2) * t));
1486
+ function starFn(phase, _elapsed, _params) {
1487
+ 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));
1516
1488
  return {
1517
- x: r * Math.cos(t),
1518
- y: r * Math.sin(t),
1489
+ x: r * Math.cos(phase),
1490
+ y: r * Math.sin(phase)
1519
1491
  };
1520
1492
  }
1521
1493
  var star = {
1522
1494
  name: "Star",
1523
1495
  fn: starFn,
1524
1496
  period: TWO_PI11,
1525
- speed: 1,
1497
+ speed: 1
1526
1498
  };
1527
1499
 
1528
1500
  // src/curves/star4.ts
1529
1501
  var TWO_PI12 = Math.PI * 2;
1530
- function star4Fn(t, _time, _params) {
1531
- const r =
1532
- Math.abs(Math.cos(2 * t)) +
1533
- 0.35 * Math.abs(Math.cos(6 * t)) +
1534
- 0.15 * Math.abs(Math.cos(10 * t));
1502
+ function star4Fn(phase, _elapsed, _params) {
1503
+ const r = Math.abs(Math.cos(2 * phase)) + 0.35 * Math.abs(Math.cos(6 * phase)) + 0.15 * Math.abs(Math.cos(10 * phase));
1535
1504
  return {
1536
- x: r * Math.cos(t),
1537
- y: r * Math.sin(t),
1505
+ x: r * Math.cos(phase),
1506
+ y: r * Math.sin(phase)
1538
1507
  };
1539
1508
  }
1540
1509
  var star4 = {
1541
1510
  name: "Star (4-arm)",
1542
1511
  fn: star4Fn,
1543
1512
  period: TWO_PI12,
1544
- speed: 1,
1513
+ speed: 1
1545
1514
  };
1546
1515
 
1547
1516
  // src/curves/star7.ts
1548
1517
  var TWO_PI13 = Math.PI * 2;
1549
- function star7Fn(t, _time, _params) {
1550
- const r =
1551
- Math.abs(Math.cos((7 / 2) * t)) +
1552
- 0.35 * Math.abs(Math.cos((21 / 2) * t)) +
1553
- 0.15 * Math.abs(Math.cos((35 / 2) * t));
1518
+ function star7Fn(phase, _elapsed, _params) {
1519
+ 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));
1554
1520
  return {
1555
- x: r * Math.cos(t),
1556
- y: r * Math.sin(t),
1521
+ x: r * Math.cos(phase),
1522
+ y: r * Math.sin(phase)
1557
1523
  };
1558
1524
  }
1559
1525
  var star7 = {
1560
1526
  name: "Star (7-arm)",
1561
1527
  fn: star7Fn,
1562
1528
  period: TWO_PI13,
1563
- speed: 1,
1529
+ speed: 1
1564
1530
  };
1565
1531
 
1566
1532
  // src/curves/index.ts
@@ -1578,7 +1544,7 @@ var curves = {
1578
1544
  lissajous32,
1579
1545
  lissajous43,
1580
1546
  epicycloid3,
1581
- lame,
1547
+ lame
1582
1548
  };
1583
1549
 
1584
1550
  // src/index.ts
@@ -1595,21 +1561,22 @@ function parseTrailColor(value) {
1595
1561
  if (Array.isArray(parsed)) {
1596
1562
  return parsed;
1597
1563
  }
1598
- } catch {}
1564
+ } catch {
1565
+ }
1599
1566
  return value;
1600
1567
  }
1601
1568
  function buildOptions(el2) {
1602
1569
  return {
1603
- ...(el2.dataset.trailColor && {
1604
- trailColor: parseTrailColor(el2.dataset.trailColor),
1605
- }),
1606
- ...(el2.dataset.skeletonColor && { skeletonColor: el2.dataset.skeletonColor }),
1607
- ...(el2.dataset.headColor && { headColor: el2.dataset.headColor }),
1608
- ...(el2.dataset.headRadius && { headRadius: parseFloat(el2.dataset.headRadius) }),
1609
- ...(el2.dataset.trailLength && { trailLength: parseInt(el2.dataset.trailLength, 10) }),
1610
- ...(el2.dataset.trailStyle && {
1611
- trailStyle: el2.dataset.trailStyle,
1612
- }),
1570
+ ...el2.dataset.trailColor && {
1571
+ trailColor: parseTrailColor(el2.dataset.trailColor)
1572
+ },
1573
+ ...el2.dataset.skeletonColor && { skeletonColor: el2.dataset.skeletonColor },
1574
+ ...el2.dataset.headColor && { headColor: el2.dataset.headColor },
1575
+ ...el2.dataset.headRadius && { headRadius: parseFloat(el2.dataset.headRadius) },
1576
+ ...el2.dataset.trailLength && { trailLength: parseInt(el2.dataset.trailLength, 10) },
1577
+ ...el2.dataset.trailStyle && {
1578
+ trailStyle: el2.dataset.trailStyle
1579
+ }
1613
1580
  };
1614
1581
  }
1615
1582
  function init() {
@@ -1624,10 +1591,7 @@ function init() {
1624
1591
  return console.error(`[sarmal] "${curveName}" is not a valid curve name`);
1625
1592
  }
1626
1593
  const options = buildOptions(el2);
1627
- const instance =
1628
- el2 instanceof HTMLCanvasElement
1629
- ? createSarmal(el2, curveDef, options)
1630
- : createSarmalSVG(el2, curveDef, options);
1594
+ const instance = el2 instanceof HTMLCanvasElement ? createSarmal(el2, curveDef, options) : createSarmalSVG(el2, curveDef, options);
1631
1595
  if (el2.dataset.speed) {
1632
1596
  instance.setSpeed(parseFloat(el2.dataset.speed));
1633
1597
  }
@@ -1643,4 +1607,4 @@ if (document.readyState === "loading") {
1643
1607
 
1644
1608
  export { init };
1645
1609
  //# sourceMappingURL=auto-init.js.map
1646
- //# sourceMappingURL=auto-init.js.map
1610
+ //# sourceMappingURL=auto-init.js.map