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