@sarmal/core 0.15.1 → 0.16.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 (57) hide show
  1. package/dist/auto-init.cjs +98 -77
  2. package/dist/auto-init.cjs.map +1 -1
  3. package/dist/auto-init.js +97 -76
  4. package/dist/auto-init.js.map +1 -1
  5. package/dist/curves/artemis2.cjs +10 -7
  6. package/dist/curves/artemis2.d.cts +1 -1
  7. package/dist/curves/artemis2.d.ts +1 -1
  8. package/dist/curves/artemis2.js +9 -6
  9. package/dist/curves/astroid.cjs +4 -4
  10. package/dist/curves/astroid.d.cts +1 -1
  11. package/dist/curves/astroid.d.ts +1 -1
  12. package/dist/curves/astroid.js +3 -3
  13. package/dist/curves/deltoid.cjs +4 -4
  14. package/dist/curves/deltoid.d.cts +1 -1
  15. package/dist/curves/deltoid.d.ts +1 -1
  16. package/dist/curves/deltoid.js +3 -3
  17. package/dist/curves/epicycloid3.cjs +4 -4
  18. package/dist/curves/epicycloid3.d.cts +1 -1
  19. package/dist/curves/epicycloid3.d.ts +1 -1
  20. package/dist/curves/epicycloid3.js +3 -3
  21. package/dist/curves/epitrochoid7.cjs +5 -5
  22. package/dist/curves/epitrochoid7.d.cts +1 -1
  23. package/dist/curves/epitrochoid7.d.ts +1 -1
  24. package/dist/curves/epitrochoid7.js +4 -4
  25. package/dist/curves/index.cjs +32 -28
  26. package/dist/curves/index.d.cts +21 -21
  27. package/dist/curves/index.d.ts +21 -21
  28. package/dist/curves/index.js +44 -28
  29. package/dist/curves/lame.cjs +6 -5
  30. package/dist/curves/lame.d.cts +1 -1
  31. package/dist/curves/lame.d.ts +1 -1
  32. package/dist/curves/lame.js +5 -4
  33. package/dist/curves/lissajous32.cjs +4 -4
  34. package/dist/curves/lissajous32.d.cts +1 -1
  35. package/dist/curves/lissajous32.d.ts +1 -1
  36. package/dist/curves/lissajous32.js +3 -3
  37. package/dist/curves/lissajous43.cjs +4 -4
  38. package/dist/curves/lissajous43.d.cts +1 -1
  39. package/dist/curves/lissajous43.d.ts +1 -1
  40. package/dist/curves/lissajous43.js +3 -3
  41. package/dist/curves/rose3.cjs +4 -4
  42. package/dist/curves/rose3.d.cts +1 -1
  43. package/dist/curves/rose3.d.ts +1 -1
  44. package/dist/curves/rose3.js +3 -3
  45. package/dist/curves/rose5.cjs +4 -4
  46. package/dist/curves/rose5.d.cts +1 -1
  47. package/dist/curves/rose5.d.ts +1 -1
  48. package/dist/curves/rose5.js +3 -3
  49. package/dist/index.cjs +112 -77
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +66 -29
  52. package/dist/index.d.ts +66 -29
  53. package/dist/index.js +130 -77
  54. package/dist/index.js.map +1 -1
  55. package/dist/types-BL9HhEmk.d.cts +259 -246
  56. package/dist/types-BL9HhEmk.d.ts +259 -246
  57. package/package.json +1 -1
@@ -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
 
@@ -315,13 +321,16 @@ function computeTrailQuad(trail, i, trailCount, toX, toY) {
315
321
  r1x: nx - n1.x * w1,
316
322
  r1y: ny - n1.y * w1,
317
323
  opacity,
318
- progress
324
+ progress,
319
325
  };
320
326
  }
321
327
  function computeBoundaries(pts, logicalWidth, logicalHeight) {
322
328
  if (pts.length === 0) return null;
323
329
  const first = pts[0];
324
- 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;
325
334
  for (const p of pts) {
326
335
  if (p.x < minX) {
327
336
  minX = p.x;
@@ -340,7 +349,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight) {
340
349
  const h = maxY - minY;
341
350
  if (w === 0 && h === 0) {
342
351
  throw new Error(
343
- "[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.",
344
353
  );
345
354
  }
346
355
  const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
@@ -351,12 +360,12 @@ function computeBoundaries(pts, logicalWidth, logicalHeight) {
351
360
  scaleXProportional,
352
361
  scaleYProportional,
353
362
  scaleXMinPadding,
354
- scaleYMinPadding
363
+ scaleYMinPadding,
355
364
  );
356
365
  return {
357
366
  scale,
358
367
  offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
359
- offsetY: (logicalHeight - h * scale) / 2 - minY * scale
368
+ offsetY: (logicalHeight - h * scale) / 2 - minY * scale,
360
369
  };
361
370
  }
362
371
  function enginePassthroughs(engine) {
@@ -366,17 +375,17 @@ function enginePassthroughs(engine) {
366
375
  setSpeed: engine.setSpeed,
367
376
  getSpeed: engine.getSpeed,
368
377
  resetSpeed: engine.resetSpeed,
369
- setSpeedOver: engine.setSpeedOver
378
+ setSpeedOver: engine.setSpeedOver,
370
379
  };
371
380
  }
372
381
  function hexToRgb(hex) {
373
382
  const n = parseInt(hex.slice(1), 16);
374
- return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
383
+ return { r: n >> 16, g: (n >> 8) & 255, b: n & 255 };
375
384
  }
376
385
  var lerpRgb = (a, b, t) => ({
377
386
  r: Math.round(a.r + (b.r - a.r) * t),
378
387
  g: Math.round(a.g + (b.g - a.g) * t),
379
- b: Math.round(a.b + (b.b - a.b) * t)
388
+ b: Math.round(a.b + (b.b - a.b) * t),
380
389
  });
381
390
  function getPaletteColor(palette, position, timeOffset = 0) {
382
391
  if (palette.length === 0) {
@@ -399,7 +408,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
399
408
  "trailColor",
400
409
  "headColor",
401
410
  "skeletonColor",
402
- "trailStyle"
411
+ "trailStyle",
403
412
  ]);
404
413
  function validateRenderOptions(partial) {
405
414
  for (const key of Object.keys(partial)) {
@@ -424,7 +433,7 @@ function assertTrailColor(value) {
424
433
  if (typeof value === "string") {
425
434
  if (!HEX_COLOR_RE.test(value)) {
426
435
  throw new TypeError(
427
- `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`
436
+ `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`,
428
437
  );
429
438
  }
430
439
  return;
@@ -432,21 +441,21 @@ function assertTrailColor(value) {
432
441
  if (Array.isArray(value)) {
433
442
  if (value.length < 2) {
434
443
  throw new RangeError(
435
- `[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`
444
+ `[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`,
436
445
  );
437
446
  }
438
447
  for (let i = 0; i < value.length; i++) {
439
448
  const entry = value[i];
440
449
  if (typeof entry !== "string" || !HEX_COLOR_RE.test(entry)) {
441
450
  throw new TypeError(
442
- `[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`
451
+ `[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`,
443
452
  );
444
453
  }
445
454
  }
446
455
  return;
447
456
  }
448
457
  throw new TypeError(
449
- `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`
458
+ `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`,
450
459
  );
451
460
  }
452
461
  function assertHeadColor(value) {
@@ -455,7 +464,7 @@ function assertHeadColor(value) {
455
464
  }
456
465
  if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
457
466
  throw new TypeError(
458
- `[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`
467
+ `[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`,
459
468
  );
460
469
  }
461
470
  }
@@ -465,14 +474,14 @@ function assertSkeletonColor(value) {
465
474
  }
466
475
  if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
467
476
  throw new TypeError(
468
- `[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`
477
+ `[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`,
469
478
  );
470
479
  }
471
480
  }
472
481
  function assertTrailStyle(value) {
473
482
  if (!TRAIL_STYLES.includes(value)) {
474
483
  throw new RangeError(
475
- `[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`
484
+ `[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`,
476
485
  );
477
486
  }
478
487
  }
@@ -494,13 +503,13 @@ function resolveHeadColor(trailColor, trailStyle) {
494
503
  function warnIfTrailColorMismatch(trailColor, trailStyle) {
495
504
  if (trailStyle === "default" && Array.isArray(trailColor)) {
496
505
  console.warn(
497
- '[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.'
506
+ '[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.',
498
507
  );
499
508
  return;
500
509
  }
501
510
  if (trailStyle !== "default" && typeof trailColor === "string") {
502
511
  console.warn(
503
- `[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.`
512
+ `[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.`,
504
513
  );
505
514
  }
506
515
  }
@@ -510,7 +519,7 @@ var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160)
510
519
  var WHITE_HEX = "#ffffff";
511
520
  function hexToRgbComponents(hex) {
512
521
  const n = parseInt(hex.slice(1), 16);
513
- return `${n >> 16},${n >> 8 & 255},${n & 255}`;
522
+ return `${n >> 16},${(n >> 8) & 255},${n & 255}`;
514
523
  }
515
524
  function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
516
525
  target.style.width = `${logicalWidth}px`;
@@ -554,6 +563,7 @@ function createRenderer(options) {
554
563
  let animationId = null;
555
564
  let lastTime = 0;
556
565
  let morphResolve = null;
566
+ let morphReject = null;
557
567
  let morphDurationMs = DEFAULT_MORPH_DURATION_MS;
558
568
  let morphAlpha = 0;
559
569
  let gradientAnimTime = 0;
@@ -634,7 +644,7 @@ function createRenderer(options) {
634
644
  i,
635
645
  trailCount,
636
646
  toX,
637
- toY
647
+ toY,
638
648
  );
639
649
  if (trailStyle === "default") {
640
650
  ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
@@ -682,6 +692,7 @@ function createRenderer(options) {
682
692
  engine.completeMorph();
683
693
  morphResolve?.();
684
694
  morphResolve = null;
695
+ morphReject = null;
685
696
  morphAlpha = 0;
686
697
  skeleton = engine.getSarmalSkeleton();
687
698
  if (!engine.isLiveSkeleton) {
@@ -744,6 +755,11 @@ function createRenderer(options) {
744
755
  cancelAnimationFrame(animationId);
745
756
  animationId = null;
746
757
  }
758
+ if (morphReject !== null) {
759
+ morphReject(new Error("Instance destroyed during morph"));
760
+ morphResolve = null;
761
+ morphReject = null;
762
+ }
747
763
  },
748
764
  ...enginePassthroughs(engine),
749
765
  morphTo(target, options2) {
@@ -751,13 +767,15 @@ function createRenderer(options) {
751
767
  engine.completeMorph();
752
768
  morphResolve();
753
769
  morphResolve = null;
770
+ morphReject = null;
754
771
  morphAlpha = 0;
755
772
  }
756
773
  morphDurationMs = options2?.duration ?? DEFAULT_MORPH_DURATION_MS;
757
774
  morphAlpha = 0;
758
775
  engine.startMorph(target, options2?.morphStrategy);
759
- return new Promise((resolve) => {
776
+ return new Promise((resolve, reject) => {
760
777
  morphResolve = resolve;
778
+ morphReject = reject;
761
779
  });
762
780
  },
763
781
  setRenderOptions(partial) {
@@ -787,7 +805,7 @@ function createRenderer(options) {
787
805
  if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
788
806
  warnIfTrailColorMismatch(trailColor, trailStyle);
789
807
  }
790
- }
808
+ },
791
809
  };
792
810
  if (shouldAutoStart) {
793
811
  instance.play();
@@ -798,19 +816,22 @@ function createRenderer(options) {
798
816
  // src/curves/artemis2.ts
799
817
  var TWO_PI2 = Math.PI * 2;
800
818
  function artemis2Fn(t, _time, _params) {
801
- const a = 0.35, b = 0.15, ox = 0.175;
802
- const s = Math.sin(t), c = Math.cos(t);
819
+ const a = 0.35,
820
+ b = 0.15,
821
+ ox = 0.175;
822
+ const s = Math.sin(t),
823
+ c = Math.cos(t);
803
824
  const denom = 1 + s * s;
804
825
  return {
805
- x: c * (1 + a * c) / denom - ox,
806
- y: s * c * (1 + b * c) / denom
826
+ x: (c * (1 + a * c)) / denom - ox,
827
+ y: (s * c * (1 + b * c)) / denom,
807
828
  };
808
829
  }
809
830
  var artemis2 = {
810
831
  name: "Artemis II",
811
832
  fn: artemis2Fn,
812
833
  period: TWO_PI2,
813
- speed: 0.7
834
+ speed: 0.7,
814
835
  };
815
836
 
816
837
  // src/curves/astroid.ts
@@ -820,14 +841,14 @@ function astroidFn(t, _time, _params) {
820
841
  const s = Math.sin(t);
821
842
  return {
822
843
  x: c * c * c,
823
- y: s * s * s
844
+ y: s * s * s,
824
845
  };
825
846
  }
826
847
  var astroid = {
827
848
  name: "Astroid",
828
849
  fn: astroidFn,
829
850
  period: TWO_PI3,
830
- speed: 1.1
851
+ speed: 1.1,
831
852
  };
832
853
 
833
854
  // src/curves/deltoid.ts
@@ -835,14 +856,14 @@ var TWO_PI4 = Math.PI * 2;
835
856
  function deltoidFn(t, _time, _params) {
836
857
  return {
837
858
  x: 2 * Math.cos(t) + Math.cos(2 * t),
838
- y: 2 * Math.sin(t) - Math.sin(2 * t)
859
+ y: 2 * Math.sin(t) - Math.sin(2 * t),
839
860
  };
840
861
  }
841
862
  var deltoid = {
842
863
  name: "Deltoid",
843
864
  fn: deltoidFn,
844
865
  period: TWO_PI4,
845
- speed: 0.9
866
+ speed: 0.9,
846
867
  };
847
868
 
848
869
  // src/curves/epicycloid3.ts
@@ -850,14 +871,14 @@ var TWO_PI5 = Math.PI * 2;
850
871
  function epicycloid3Fn(t, _time, _params) {
851
872
  return {
852
873
  x: 4 * Math.cos(t) - Math.cos(4 * t),
853
- y: 4 * Math.sin(t) - Math.sin(4 * t)
874
+ y: 4 * Math.sin(t) - Math.sin(4 * t),
854
875
  };
855
876
  }
856
877
  var epicycloid3 = {
857
878
  name: "Epicycloid (n=3)",
858
879
  fn: epicycloid3Fn,
859
880
  period: TWO_PI5,
860
- speed: 0.75
881
+ speed: 0.75,
861
882
  };
862
883
 
863
884
  // src/curves/epitrochoid7.ts
@@ -866,14 +887,14 @@ function epitrochoid7Fn(t, _time, _params) {
866
887
  const d = 1 + 0.55 * Math.sin(t * 0.5);
867
888
  return {
868
889
  x: 7 * Math.cos(t) - d * Math.cos(7 * t),
869
- y: 7 * Math.sin(t) - d * Math.sin(7 * t)
890
+ y: 7 * Math.sin(t) - d * Math.sin(7 * t),
870
891
  };
871
892
  }
872
893
  function epitrochoid7SkeletonFn(t) {
873
894
  const d = 1.275;
874
895
  return {
875
896
  x: 7 * Math.cos(t) - d * Math.cos(7 * t),
876
- y: 7 * Math.sin(t) - d * Math.sin(7 * t)
897
+ y: 7 * Math.sin(t) - d * Math.sin(7 * t),
877
898
  };
878
899
  }
879
900
  var epitrochoid7 = {
@@ -881,7 +902,7 @@ var epitrochoid7 = {
881
902
  fn: epitrochoid7Fn,
882
903
  period: TWO_PI6,
883
904
  speed: 1.4,
884
- skeletonFn: epitrochoid7SkeletonFn
905
+ skeletonFn: epitrochoid7SkeletonFn,
885
906
  };
886
907
 
887
908
  // src/curves/lissajous32.ts
@@ -890,7 +911,7 @@ function lissajous32Fn(t, time, _params) {
890
911
  const phi = time * 0.45;
891
912
  return {
892
913
  x: Math.sin(3 * t + phi),
893
- y: Math.sin(2 * t)
914
+ y: Math.sin(2 * t),
894
915
  };
895
916
  }
896
917
  var lissajous32 = {
@@ -898,7 +919,7 @@ var lissajous32 = {
898
919
  fn: lissajous32Fn,
899
920
  period: TWO_PI7,
900
921
  speed: 2,
901
- skeleton: "live"
922
+ skeleton: "live",
902
923
  };
903
924
 
904
925
  // src/curves/lissajous43.ts
@@ -907,7 +928,7 @@ function lissajous43Fn(t, time, _params) {
907
928
  const phi = time * 0.38;
908
929
  return {
909
930
  x: Math.sin(4 * t + phi),
910
- y: Math.sin(3 * t)
931
+ y: Math.sin(3 * t),
911
932
  };
912
933
  }
913
934
  var lissajous43 = {
@@ -915,17 +936,18 @@ var lissajous43 = {
915
936
  fn: lissajous43Fn,
916
937
  period: TWO_PI8,
917
938
  speed: 1.8,
918
- skeleton: "live"
939
+ skeleton: "live",
919
940
  };
920
941
 
921
942
  // src/curves/lame.ts
922
943
  var TWO_PI9 = Math.PI * 2;
923
944
  function lameFn(t, time, _params) {
924
945
  const p = 1.75 + 1.25 * Math.sin(time * 0.48);
925
- const c = Math.cos(t), s = Math.sin(t);
946
+ const c = Math.cos(t),
947
+ s = Math.sin(t);
926
948
  return {
927
949
  x: Math.sign(c) * Math.pow(Math.abs(c), p),
928
- y: Math.sign(s) * Math.pow(Math.abs(s), p)
950
+ y: Math.sign(s) * Math.pow(Math.abs(s), p),
929
951
  };
930
952
  }
931
953
  var lame = {
@@ -933,7 +955,7 @@ var lame = {
933
955
  fn: lameFn,
934
956
  period: TWO_PI9,
935
957
  speed: 1,
936
- skeleton: "live"
958
+ skeleton: "live",
937
959
  };
938
960
 
939
961
  // src/curves/rose3.ts
@@ -942,14 +964,14 @@ function rose3Fn(t, _time, _params) {
942
964
  const r = Math.cos(3 * t);
943
965
  return {
944
966
  x: r * Math.cos(t),
945
- y: r * Math.sin(t)
967
+ y: r * Math.sin(t),
946
968
  };
947
969
  }
948
970
  var rose3 = {
949
971
  name: "Rose (n=3)",
950
972
  fn: rose3Fn,
951
973
  period: TWO_PI10,
952
- speed: 1.15
974
+ speed: 1.15,
953
975
  };
954
976
 
955
977
  // src/curves/rose5.ts
@@ -958,14 +980,14 @@ function rose5Fn(t, _time, _params) {
958
980
  const r = Math.cos(5 * t);
959
981
  return {
960
982
  x: r * Math.cos(t),
961
- y: r * Math.sin(t)
983
+ y: r * Math.sin(t),
962
984
  };
963
985
  }
964
986
  var rose5 = {
965
987
  name: "Rose (n=5)",
966
988
  fn: rose5Fn,
967
989
  period: TWO_PI11,
968
- speed: 1
990
+ speed: 1,
969
991
  };
970
992
 
971
993
  // src/curves/index.ts
@@ -979,7 +1001,7 @@ var curves = {
979
1001
  lissajous32,
980
1002
  lissajous43,
981
1003
  epicycloid3,
982
- lame
1004
+ lame,
983
1005
  };
984
1006
 
985
1007
  // src/index.ts
@@ -996,8 +1018,7 @@ function parseTrailColor(value) {
996
1018
  if (Array.isArray(parsed)) {
997
1019
  return parsed;
998
1020
  }
999
- } catch {
1000
- }
1021
+ } catch {}
1001
1022
  return value;
1002
1023
  }
1003
1024
  function init() {
@@ -1012,16 +1033,16 @@ function init() {
1012
1033
  return console.error(`[sarmal] "${curveName}" is not a valid curve name`);
1013
1034
  }
1014
1035
  const instance = createSarmal(canvas, curveDef, {
1015
- ...canvas.dataset.trailColor && {
1016
- trailColor: parseTrailColor(canvas.dataset.trailColor)
1017
- },
1018
- ...canvas.dataset.skeletonColor && { skeletonColor: canvas.dataset.skeletonColor },
1019
- ...canvas.dataset.headColor && { headColor: canvas.dataset.headColor },
1020
- ...canvas.dataset.headRadius && { headRadius: parseFloat(canvas.dataset.headRadius) },
1021
- ...canvas.dataset.trailLength && { trailLength: parseInt(canvas.dataset.trailLength, 10) },
1022
- ...canvas.dataset.trailStyle && {
1023
- trailStyle: canvas.dataset.trailStyle
1024
- }
1036
+ ...(canvas.dataset.trailColor && {
1037
+ trailColor: parseTrailColor(canvas.dataset.trailColor),
1038
+ }),
1039
+ ...(canvas.dataset.skeletonColor && { skeletonColor: canvas.dataset.skeletonColor }),
1040
+ ...(canvas.dataset.headColor && { headColor: canvas.dataset.headColor }),
1041
+ ...(canvas.dataset.headRadius && { headRadius: parseFloat(canvas.dataset.headRadius) }),
1042
+ ...(canvas.dataset.trailLength && { trailLength: parseInt(canvas.dataset.trailLength, 10) }),
1043
+ ...(canvas.dataset.trailStyle && {
1044
+ trailStyle: canvas.dataset.trailStyle,
1045
+ }),
1025
1046
  });
1026
1047
  if (canvas.dataset.speed) {
1027
1048
  instance.setSpeed(parseFloat(canvas.dataset.speed));
@@ -1038,4 +1059,4 @@ if (document.readyState === "loading") {
1038
1059
 
1039
1060
  exports.init = init;
1040
1061
  //# sourceMappingURL=auto-init.cjs.map
1041
- //# sourceMappingURL=auto-init.cjs.map
1062
+ //# sourceMappingURL=auto-init.cjs.map