@sarmal/core 0.12.0 → 0.13.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 (61) hide show
  1. package/dist/auto-init.cjs +114 -82
  2. package/dist/auto-init.cjs.map +1 -1
  3. package/dist/auto-init.d.cts +1 -2
  4. package/dist/auto-init.d.ts +1 -2
  5. package/dist/auto-init.js +113 -81
  6. package/dist/auto-init.js.map +1 -1
  7. package/dist/curves/artemis2.cjs +10 -7
  8. package/dist/curves/artemis2.d.cts +1 -1
  9. package/dist/curves/artemis2.d.ts +1 -1
  10. package/dist/curves/artemis2.js +9 -6
  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 +32 -28
  28. package/dist/curves/index.d.cts +21 -21
  29. package/dist/curves/index.d.ts +21 -21
  30. package/dist/curves/index.js +44 -28
  31. package/dist/curves/lame.cjs +6 -5
  32. package/dist/curves/lame.d.cts +1 -1
  33. package/dist/curves/lame.d.ts +1 -1
  34. package/dist/curves/lame.js +5 -4
  35. package/dist/curves/lissajous32.cjs +4 -4
  36. package/dist/curves/lissajous32.d.cts +1 -1
  37. package/dist/curves/lissajous32.d.ts +1 -1
  38. package/dist/curves/lissajous32.js +3 -3
  39. package/dist/curves/lissajous43.cjs +4 -4
  40. package/dist/curves/lissajous43.d.cts +1 -1
  41. package/dist/curves/lissajous43.d.ts +1 -1
  42. package/dist/curves/lissajous43.js +3 -3
  43. package/dist/curves/rose3.cjs +4 -4
  44. package/dist/curves/rose3.d.cts +1 -1
  45. package/dist/curves/rose3.d.ts +1 -1
  46. package/dist/curves/rose3.js +3 -3
  47. package/dist/curves/rose5.cjs +4 -4
  48. package/dist/curves/rose5.d.cts +1 -1
  49. package/dist/curves/rose5.d.ts +1 -1
  50. package/dist/curves/rose5.js +3 -3
  51. package/dist/index.cjs +135 -87
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.cts +69 -34
  54. package/dist/index.d.ts +69 -34
  55. package/dist/index.js +152 -87
  56. package/dist/index.js.map +1 -1
  57. package/dist/types-BW0bpL1Z.d.cts +290 -0
  58. package/dist/types-BW0bpL1Z.d.ts +290 -0
  59. package/package.json +1 -1
  60. package/dist/types-BzgdhxE0.d.cts +0 -260
  61. package/dist/types-BzgdhxE0.d.ts +0 -260
@@ -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 {
@@ -134,14 +134,14 @@ function createEngine(curveDef, trailLength = 120) {
134
134
  trail.clear();
135
135
  },
136
136
  jump(newT, { clearTrail = false } = {}) {
137
- t = (newT % curve.period + curve.period) % curve.period;
137
+ t = ((newT % curve.period) + curve.period) % curve.period;
138
138
  if (clearTrail) {
139
139
  trail.clear();
140
140
  }
141
141
  },
142
142
  seek(targetT, { wrap = false, step = curve.period / trailLength } = {}) {
143
143
  const advance = curve.speed * step;
144
- const target = (targetT % curve.period + curve.period) % curve.period;
144
+ const target = ((targetT % curve.period) + curve.period) % curve.period;
145
145
  const targetTime = target / curve.speed;
146
146
  t = target;
147
147
  actualTime = targetTime;
@@ -150,7 +150,7 @@ function createEngine(curveDef, trailLength = 120) {
150
150
  const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
151
151
  for (let i = count - 1; i >= 0; i--) {
152
152
  const sampleT = target - i * advance;
153
- const wrappedT = (sampleT % curve.period + curve.period) % curve.period;
153
+ const wrappedT = ((sampleT % curve.period) + curve.period) % curve.period;
154
154
  const time = targetTime - i * step;
155
155
  const point = curve.fn(wrappedT, time, EMPTY_PARAMS);
156
156
  trail.push(point.x, point.y);
@@ -167,13 +167,16 @@ function createEngine(curveDef, trailLength = 120) {
167
167
  ...frozenB,
168
168
  fn: (sampleT, time, params) => {
169
169
  const a = frozenA.fn(sampleT, time, params);
170
- const tB = frozenStrategy === "normalized" ? sampleT / frozenA.period * frozenB.period : sampleT;
170
+ const tB =
171
+ frozenStrategy === "normalized"
172
+ ? (sampleT / frozenA.period) * frozenB.period
173
+ : sampleT;
171
174
  const b = frozenB.fn(tB, time, params);
172
175
  return {
173
176
  x: a.x + (b.x - a.x) * frozenAlpha,
174
- y: a.y + (b.y - a.y) * frozenAlpha
177
+ y: a.y + (b.y - a.y) * frozenAlpha,
175
178
  };
176
- }
179
+ },
177
180
  };
178
181
  }
179
182
  _morphStrategy = strategy;
@@ -186,7 +189,7 @@ function createEngine(curveDef, trailLength = 120) {
186
189
  completeMorph() {
187
190
  if (morphCurveB !== null) {
188
191
  if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
189
- t = t / curve.period * morphCurveB.period;
192
+ t = (t / curve.period) * morphCurveB.period;
190
193
  }
191
194
  curve = morphCurveB;
192
195
  }
@@ -198,19 +201,22 @@ function createEngine(curveDef, trailLength = 120) {
198
201
  const points = new Array(steps);
199
202
  if (morphCurveB !== null && _morphAlpha !== null) {
200
203
  for (let i = 0; i < steps; i++) {
201
- const sampleT = i / (steps - 1) * curve.period;
204
+ const sampleT = (i / (steps - 1)) * curve.period;
202
205
  const a = sampleSkeleton(curve, sampleT);
203
- const tB = _morphStrategy === "normalized" ? sampleT / curve.period * morphCurveB.period : sampleT;
206
+ const tB =
207
+ _morphStrategy === "normalized"
208
+ ? (sampleT / curve.period) * morphCurveB.period
209
+ : sampleT;
204
210
  const b = sampleSkeleton(morphCurveB, tB);
205
211
  points[i] = {
206
212
  x: a.x + (b.x - a.x) * _morphAlpha,
207
- y: a.y + (b.y - a.y) * _morphAlpha
213
+ y: a.y + (b.y - a.y) * _morphAlpha,
208
214
  };
209
215
  }
210
216
  return points;
211
217
  }
212
218
  for (let i = 0; i < steps; i++) {
213
- const sampleT = i / (steps - 1) * curve.period;
219
+ const sampleT = (i / (steps - 1)) * curve.period;
214
220
  points[i] = sampleSkeleton(curve, sampleT);
215
221
  }
216
222
  return points;
@@ -252,7 +258,7 @@ function createEngine(curveDef, trailLength = 120) {
252
258
  _speedTransition.reject(new Error("Speed transition cancelled"));
253
259
  _speedTransition = null;
254
260
  }
255
- }
261
+ },
256
262
  };
257
263
  }
258
264
 
@@ -260,6 +266,7 @@ function createEngine(curveDef, trailLength = 120) {
260
266
  var DEFAULT_MORPH_DURATION_MS = 300;
261
267
  var DEFAULT_SKELETON_OPACITY = 0.15;
262
268
  var FIT_PADDING = 0.1;
269
+ var FIT_PADDING_MIN = 4;
263
270
  var TRAIL_FADE_CURVE = 1.5;
264
271
  var TRAIL_MAX_OPACITY = 0.88;
265
272
  var TRAIL_MIN_WIDTH = 0.5;
@@ -314,13 +321,16 @@ function computeTrailQuad(trail, i, trailCount, toX, toY) {
314
321
  r1x: nx - n1.x * w1,
315
322
  r1y: ny - n1.y * w1,
316
323
  opacity,
317
- progress
324
+ progress,
318
325
  };
319
326
  }
320
327
  function computeBoundaries(pts, logicalWidth, logicalHeight) {
321
328
  if (pts.length === 0) return null;
322
329
  const first = pts[0];
323
- let minX = first.x, maxX = first.x, minY = first.y, maxY = first.y;
330
+ let minX = first.x,
331
+ maxX = first.x,
332
+ minY = first.y,
333
+ maxY = first.y;
324
334
  for (const p of pts) {
325
335
  if (p.x < minX) {
326
336
  minX = p.x;
@@ -339,16 +349,23 @@ function computeBoundaries(pts, logicalWidth, logicalHeight) {
339
349
  const h = maxY - minY;
340
350
  if (w === 0 && h === 0) {
341
351
  throw new Error(
342
- "[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
352
+ "[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t.",
343
353
  );
344
354
  }
345
- const scaleX = logicalWidth / (w * (1 + FIT_PADDING * 2));
346
- const scaleY = logicalHeight / (h * (1 + FIT_PADDING * 2));
347
- const scale = Math.min(scaleX, scaleY);
355
+ const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
356
+ const scaleYProportional = logicalHeight / (h * (1 + FIT_PADDING * 2));
357
+ const scaleXMinPadding = (logicalWidth - FIT_PADDING_MIN * 2) / w;
358
+ const scaleYMinPadding = (logicalHeight - FIT_PADDING_MIN * 2) / h;
359
+ const scale = Math.min(
360
+ scaleXProportional,
361
+ scaleYProportional,
362
+ scaleXMinPadding,
363
+ scaleYMinPadding,
364
+ );
348
365
  return {
349
366
  scale,
350
367
  offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
351
- offsetY: (logicalHeight - h * scale) / 2 - minY * scale
368
+ offsetY: (logicalHeight - h * scale) / 2 - minY * scale,
352
369
  };
353
370
  }
354
371
  function enginePassthroughs(engine) {
@@ -358,7 +375,7 @@ function enginePassthroughs(engine) {
358
375
  setSpeed: engine.setSpeed,
359
376
  getSpeed: engine.getSpeed,
360
377
  resetSpeed: engine.resetSpeed,
361
- setSpeedOver: engine.setSpeedOver
378
+ setSpeedOver: engine.setSpeedOver,
362
379
  };
363
380
  }
364
381
 
@@ -370,7 +387,7 @@ var GRADIENT = {
370
387
  ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"],
371
388
  ice: ["#1e3a8a", "#67e8f9"],
372
389
  fire: ["#7f1d1d", "#fbbf24"],
373
- forest: ["#14532d", "#86efac"]
390
+ forest: ["#14532d", "#86efac"],
374
391
  };
375
392
  var PRESETS = {
376
393
  bard: GRADIENT.bard,
@@ -378,16 +395,16 @@ var PRESETS = {
378
395
  ocean: GRADIENT.ocean,
379
396
  ice: GRADIENT.ice,
380
397
  fire: GRADIENT.fire,
381
- forest: GRADIENT.forest
398
+ forest: GRADIENT.forest,
382
399
  };
383
400
  function hexToRgb(hex) {
384
401
  const n = parseInt(hex.slice(1), 16);
385
- return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
402
+ return { r: n >> 16, g: (n >> 8) & 255, b: n & 255 };
386
403
  }
387
404
  var lerpRgb = (a, b, t) => ({
388
405
  r: Math.round(a.r + (b.r - a.r) * t),
389
406
  g: Math.round(a.g + (b.g - a.g) * t),
390
- b: Math.round(a.b + (b.b - a.b) * t)
407
+ b: Math.round(a.b + (b.b - a.b) * t),
391
408
  });
392
409
  function getPaletteColor(palette, position, timeOffset = 0) {
393
410
  if (palette.length === 0) return { r: 255, g: 255, b: 255 };
@@ -407,7 +424,7 @@ function resolvePalette(palette, trailStyle) {
407
424
  }
408
425
  function hexToRgbComponents(hex) {
409
426
  const n = parseInt(hex.slice(1), 16);
410
- return `${n >> 16},${n >> 8 & 255},${n & 255}`;
427
+ return `${n >> 16},${(n >> 8) & 255},${n & 255}`;
411
428
  }
412
429
  function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
413
430
  target.style.width = `${logicalWidth}px`;
@@ -435,7 +452,7 @@ function createRenderer(options) {
435
452
  const opts = {
436
453
  skeletonColor: options.skeletonColor ?? DEFAULT_SKELETON_COLOR,
437
454
  trailColor,
438
- headColor: options.headColor ?? defaultHeadColor()
455
+ headColor: options.headColor ?? defaultHeadColor(),
439
456
  };
440
457
  const trailRgb = hexToRgbComponents(opts.trailColor);
441
458
  const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
@@ -536,7 +553,7 @@ function createRenderer(options) {
536
553
  i,
537
554
  trailCount,
538
555
  toX,
539
- toY
556
+ toY,
540
557
  );
541
558
  if (trailStyle === "default") {
542
559
  ctx.fillStyle = `rgba(${trailRgb},${opacity})`;
@@ -560,16 +577,14 @@ function createRenderer(options) {
560
577
  }
561
578
  const x = head.x * scale + offsetX;
562
579
  const y = head.y * scale + offsetY;
563
- const r = options.headRadius ?? Math.max(2, 3 * Math.sqrt(Math.min(logicalWidth, logicalHeight) / 160));
580
+ const r =
581
+ options.headRadius ?? Math.max(2, 3 * Math.sqrt(Math.min(logicalWidth, logicalHeight) / 160));
564
582
  ctx.fillStyle = opts.headColor;
565
583
  ctx.beginPath();
566
584
  ctx.arc(x, y, r, 0, Math.PI * 2);
567
585
  ctx.fill();
568
586
  }
569
- function render() {
570
- const now = performance.now();
571
- const deltaTime = Math.min((now - lastTime) / 1e3, 1 / 30);
572
- lastTime = now;
587
+ function renderFrame(deltaTime) {
573
588
  if (trailStyle === "gradient-animated") {
574
589
  gradientAnimTime += deltaTime * 1e3;
575
590
  }
@@ -605,22 +620,33 @@ function createRenderer(options) {
605
620
  drawSkeleton();
606
621
  drawTrail();
607
622
  drawHead();
608
- animationId = requestAnimationFrame(render);
623
+ }
624
+ function loop() {
625
+ const now = performance.now();
626
+ const deltaTime = Math.min((now - lastTime) / 1e3, 1 / 30);
627
+ lastTime = now;
628
+ renderFrame(deltaTime);
629
+ animationId = requestAnimationFrame(loop);
609
630
  }
610
631
  skeleton = engine.getSarmalSkeleton();
611
632
  calculateBoundaries();
612
633
  if (!engine.isLiveSkeleton) {
613
634
  buildSkeletonCanvas();
614
635
  }
615
- return {
616
- start() {
636
+ if (options.initialT !== void 0) {
637
+ engine.seek(options.initialT);
638
+ }
639
+ renderFrame(0);
640
+ const shouldAutoStart = options.autoStart !== false;
641
+ const instance = {
642
+ play() {
617
643
  if (animationId !== null) {
618
644
  return;
619
645
  }
620
646
  lastTime = performance.now();
621
- render();
647
+ loop();
622
648
  },
623
- stop() {
649
+ pause() {
624
650
  if (animationId === null) {
625
651
  return;
626
652
  }
@@ -653,26 +679,33 @@ function createRenderer(options) {
653
679
  return new Promise((resolve) => {
654
680
  morphResolve = resolve;
655
681
  });
656
- }
682
+ },
657
683
  };
684
+ if (shouldAutoStart) {
685
+ instance.play();
686
+ }
687
+ return instance;
658
688
  }
659
689
 
660
690
  // src/curves/artemis2.ts
661
691
  var TWO_PI2 = Math.PI * 2;
662
692
  function artemis2Fn(t, _time, _params) {
663
- const a = 0.35, b = 0.15, ox = 0.175;
664
- const s = Math.sin(t), c = Math.cos(t);
693
+ const a = 0.35,
694
+ b = 0.15,
695
+ ox = 0.175;
696
+ const s = Math.sin(t),
697
+ c = Math.cos(t);
665
698
  const denom = 1 + s * s;
666
699
  return {
667
- x: c * (1 + a * c) / denom - ox,
668
- y: s * c * (1 + b * c) / denom
700
+ x: (c * (1 + a * c)) / denom - ox,
701
+ y: (s * c * (1 + b * c)) / denom,
669
702
  };
670
703
  }
671
704
  var artemis2 = {
672
705
  name: "Artemis II",
673
706
  fn: artemis2Fn,
674
707
  period: TWO_PI2,
675
- speed: 0.7
708
+ speed: 0.7,
676
709
  };
677
710
 
678
711
  // src/curves/astroid.ts
@@ -682,14 +715,14 @@ function astroidFn(t, _time, _params) {
682
715
  const s = Math.sin(t);
683
716
  return {
684
717
  x: c * c * c,
685
- y: s * s * s
718
+ y: s * s * s,
686
719
  };
687
720
  }
688
721
  var astroid = {
689
722
  name: "Astroid",
690
723
  fn: astroidFn,
691
724
  period: TWO_PI3,
692
- speed: 1.1
725
+ speed: 1.1,
693
726
  };
694
727
 
695
728
  // src/curves/deltoid.ts
@@ -697,14 +730,14 @@ var TWO_PI4 = Math.PI * 2;
697
730
  function deltoidFn(t, _time, _params) {
698
731
  return {
699
732
  x: 2 * Math.cos(t) + Math.cos(2 * t),
700
- y: 2 * Math.sin(t) - Math.sin(2 * t)
733
+ y: 2 * Math.sin(t) - Math.sin(2 * t),
701
734
  };
702
735
  }
703
736
  var deltoid = {
704
737
  name: "Deltoid",
705
738
  fn: deltoidFn,
706
739
  period: TWO_PI4,
707
- speed: 0.9
740
+ speed: 0.9,
708
741
  };
709
742
 
710
743
  // src/curves/epicycloid3.ts
@@ -712,14 +745,14 @@ var TWO_PI5 = Math.PI * 2;
712
745
  function epicycloid3Fn(t, _time, _params) {
713
746
  return {
714
747
  x: 4 * Math.cos(t) - Math.cos(4 * t),
715
- y: 4 * Math.sin(t) - Math.sin(4 * t)
748
+ y: 4 * Math.sin(t) - Math.sin(4 * t),
716
749
  };
717
750
  }
718
751
  var epicycloid3 = {
719
752
  name: "Epicycloid (n=3)",
720
753
  fn: epicycloid3Fn,
721
754
  period: TWO_PI5,
722
- speed: 0.75
755
+ speed: 0.75,
723
756
  };
724
757
 
725
758
  // src/curves/epitrochoid7.ts
@@ -728,14 +761,14 @@ function epitrochoid7Fn(t, _time, _params) {
728
761
  const d = 1 + 0.55 * Math.sin(t * 0.5);
729
762
  return {
730
763
  x: 7 * Math.cos(t) - d * Math.cos(7 * t),
731
- y: 7 * Math.sin(t) - d * Math.sin(7 * t)
764
+ y: 7 * Math.sin(t) - d * Math.sin(7 * t),
732
765
  };
733
766
  }
734
767
  function epitrochoid7SkeletonFn(t) {
735
768
  const d = 1.275;
736
769
  return {
737
770
  x: 7 * Math.cos(t) - d * Math.cos(7 * t),
738
- y: 7 * Math.sin(t) - d * Math.sin(7 * t)
771
+ y: 7 * Math.sin(t) - d * Math.sin(7 * t),
739
772
  };
740
773
  }
741
774
  var epitrochoid7 = {
@@ -743,7 +776,7 @@ var epitrochoid7 = {
743
776
  fn: epitrochoid7Fn,
744
777
  period: TWO_PI6,
745
778
  speed: 1.4,
746
- skeletonFn: epitrochoid7SkeletonFn
779
+ skeletonFn: epitrochoid7SkeletonFn,
747
780
  };
748
781
 
749
782
  // src/curves/lissajous32.ts
@@ -752,7 +785,7 @@ function lissajous32Fn(t, time, _params) {
752
785
  const phi = time * 0.45;
753
786
  return {
754
787
  x: Math.sin(3 * t + phi),
755
- y: Math.sin(2 * t)
788
+ y: Math.sin(2 * t),
756
789
  };
757
790
  }
758
791
  var lissajous32 = {
@@ -760,7 +793,7 @@ var lissajous32 = {
760
793
  fn: lissajous32Fn,
761
794
  period: TWO_PI7,
762
795
  speed: 2,
763
- skeleton: "live"
796
+ skeleton: "live",
764
797
  };
765
798
 
766
799
  // src/curves/lissajous43.ts
@@ -769,7 +802,7 @@ function lissajous43Fn(t, time, _params) {
769
802
  const phi = time * 0.38;
770
803
  return {
771
804
  x: Math.sin(4 * t + phi),
772
- y: Math.sin(3 * t)
805
+ y: Math.sin(3 * t),
773
806
  };
774
807
  }
775
808
  var lissajous43 = {
@@ -777,17 +810,18 @@ var lissajous43 = {
777
810
  fn: lissajous43Fn,
778
811
  period: TWO_PI8,
779
812
  speed: 1.8,
780
- skeleton: "live"
813
+ skeleton: "live",
781
814
  };
782
815
 
783
816
  // src/curves/lame.ts
784
817
  var TWO_PI9 = Math.PI * 2;
785
818
  function lameFn(t, time, _params) {
786
819
  const p = 1.75 + 1.25 * Math.sin(time * 0.48);
787
- const c = Math.cos(t), s = Math.sin(t);
820
+ const c = Math.cos(t),
821
+ s = Math.sin(t);
788
822
  return {
789
823
  x: Math.sign(c) * Math.pow(Math.abs(c), p),
790
- y: Math.sign(s) * Math.pow(Math.abs(s), p)
824
+ y: Math.sign(s) * Math.pow(Math.abs(s), p),
791
825
  };
792
826
  }
793
827
  var lame = {
@@ -795,7 +829,7 @@ var lame = {
795
829
  fn: lameFn,
796
830
  period: TWO_PI9,
797
831
  speed: 1,
798
- skeleton: "live"
832
+ skeleton: "live",
799
833
  };
800
834
 
801
835
  // src/curves/rose3.ts
@@ -804,14 +838,14 @@ function rose3Fn(t, _time, _params) {
804
838
  const r = Math.cos(3 * t);
805
839
  return {
806
840
  x: r * Math.cos(t),
807
- y: r * Math.sin(t)
841
+ y: r * Math.sin(t),
808
842
  };
809
843
  }
810
844
  var rose3 = {
811
845
  name: "Rose (n=3)",
812
846
  fn: rose3Fn,
813
847
  period: TWO_PI10,
814
- speed: 1.15
848
+ speed: 1.15,
815
849
  };
816
850
 
817
851
  // src/curves/rose5.ts
@@ -820,14 +854,14 @@ function rose5Fn(t, _time, _params) {
820
854
  const r = Math.cos(5 * t);
821
855
  return {
822
856
  x: r * Math.cos(t),
823
- y: r * Math.sin(t)
857
+ y: r * Math.sin(t),
824
858
  };
825
859
  }
826
860
  var rose5 = {
827
861
  name: "Rose (n=5)",
828
862
  fn: rose5Fn,
829
863
  period: TWO_PI11,
830
- speed: 1
864
+ speed: 1,
831
865
  };
832
866
 
833
867
  // src/curves/index.ts
@@ -841,7 +875,7 @@ var curves = {
841
875
  lissajous32,
842
876
  lissajous43,
843
877
  epicycloid3,
844
- lame
878
+ lame,
845
879
  };
846
880
 
847
881
  // src/index.ts
@@ -858,8 +892,7 @@ function parsePalette(value) {
858
892
  if (Array.isArray(parsed)) {
859
893
  return parsed;
860
894
  }
861
- } catch {
862
- }
895
+ } catch {}
863
896
  return value;
864
897
  }
865
898
  function init() {
@@ -873,18 +906,17 @@ function init() {
873
906
  if (!curveDef) {
874
907
  return console.error(`[sarmal] "${curveName}" is not a valid curve name`);
875
908
  }
876
- const sarmal = createSarmal(canvas, curveDef, {
877
- ...canvas.dataset.trailColor && { trailColor: canvas.dataset.trailColor },
878
- ...canvas.dataset.skeletonColor && { skeletonColor: canvas.dataset.skeletonColor },
879
- ...canvas.dataset.headColor && { headColor: canvas.dataset.headColor },
880
- ...canvas.dataset.headRadius && { headRadius: parseFloat(canvas.dataset.headRadius) },
881
- ...canvas.dataset.trailLength && { trailLength: parseInt(canvas.dataset.trailLength, 10) },
882
- ...canvas.dataset.trailStyle && {
883
- trailStyle: canvas.dataset.trailStyle
884
- },
885
- ...canvas.dataset.palette && { palette: parsePalette(canvas.dataset.palette) }
909
+ createSarmal(canvas, curveDef, {
910
+ ...(canvas.dataset.trailColor && { trailColor: canvas.dataset.trailColor }),
911
+ ...(canvas.dataset.skeletonColor && { skeletonColor: canvas.dataset.skeletonColor }),
912
+ ...(canvas.dataset.headColor && { headColor: canvas.dataset.headColor }),
913
+ ...(canvas.dataset.headRadius && { headRadius: parseFloat(canvas.dataset.headRadius) }),
914
+ ...(canvas.dataset.trailLength && { trailLength: parseInt(canvas.dataset.trailLength, 10) }),
915
+ ...(canvas.dataset.trailStyle && {
916
+ trailStyle: canvas.dataset.trailStyle,
917
+ }),
918
+ ...(canvas.dataset.palette && { palette: parsePalette(canvas.dataset.palette) }),
886
919
  });
887
- sarmal.start();
888
920
  });
889
921
  }
890
922
  if (document.readyState === "loading") {
@@ -895,4 +927,4 @@ if (document.readyState === "loading") {
895
927
  requestAnimationFrame(init);
896
928
  }
897
929
  //# sourceMappingURL=auto-init.cjs.map
898
- //# sourceMappingURL=auto-init.cjs.map
930
+ //# sourceMappingURL=auto-init.cjs.map