@sarmal/core 0.17.0 → 0.17.3

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 (74) hide show
  1. package/README.md +4 -4
  2. package/dist/auto-init.cjs +89 -110
  3. package/dist/auto-init.cjs.map +1 -1
  4. package/dist/auto-init.js +88 -109
  5. package/dist/auto-init.js.map +1 -1
  6. package/dist/curves/artemis2.cjs +7 -10
  7. package/dist/curves/artemis2.d.cts +1 -1
  8. package/dist/curves/artemis2.d.ts +1 -1
  9. package/dist/curves/artemis2.js +6 -9
  10. package/dist/curves/astroid.cjs +4 -4
  11. package/dist/curves/astroid.d.cts +1 -1
  12. package/dist/curves/astroid.d.ts +1 -1
  13. package/dist/curves/astroid.js +3 -3
  14. package/dist/curves/deltoid.cjs +4 -4
  15. package/dist/curves/deltoid.d.cts +1 -1
  16. package/dist/curves/deltoid.d.ts +1 -1
  17. package/dist/curves/deltoid.js +3 -3
  18. package/dist/curves/epicycloid3.cjs +4 -4
  19. package/dist/curves/epicycloid3.d.cts +1 -1
  20. package/dist/curves/epicycloid3.d.ts +1 -1
  21. package/dist/curves/epicycloid3.js +3 -3
  22. package/dist/curves/epitrochoid7.cjs +5 -5
  23. package/dist/curves/epitrochoid7.d.cts +1 -1
  24. package/dist/curves/epitrochoid7.d.ts +1 -1
  25. package/dist/curves/epitrochoid7.js +4 -4
  26. package/dist/curves/index.cjs +40 -53
  27. package/dist/curves/index.d.cts +29 -29
  28. package/dist/curves/index.d.ts +29 -29
  29. package/dist/curves/index.js +40 -69
  30. package/dist/curves/lame.cjs +5 -6
  31. package/dist/curves/lame.d.cts +1 -1
  32. package/dist/curves/lame.d.ts +1 -1
  33. package/dist/curves/lame.js +4 -5
  34. package/dist/curves/lissajous32.cjs +4 -4
  35. package/dist/curves/lissajous32.d.cts +1 -1
  36. package/dist/curves/lissajous32.d.ts +1 -1
  37. package/dist/curves/lissajous32.js +3 -3
  38. package/dist/curves/lissajous43.cjs +4 -4
  39. package/dist/curves/lissajous43.d.cts +1 -1
  40. package/dist/curves/lissajous43.d.ts +1 -1
  41. package/dist/curves/lissajous43.js +3 -3
  42. package/dist/curves/rose3.cjs +4 -4
  43. package/dist/curves/rose3.d.cts +1 -1
  44. package/dist/curves/rose3.d.ts +1 -1
  45. package/dist/curves/rose3.js +3 -3
  46. package/dist/curves/rose5.cjs +4 -4
  47. package/dist/curves/rose5.d.cts +1 -1
  48. package/dist/curves/rose5.d.ts +1 -1
  49. package/dist/curves/rose5.js +3 -3
  50. package/dist/curves/rose52.cjs +5 -5
  51. package/dist/curves/rose52.d.cts +1 -1
  52. package/dist/curves/rose52.d.ts +1 -1
  53. package/dist/curves/rose52.js +4 -4
  54. package/dist/curves/star.cjs +5 -8
  55. package/dist/curves/star.d.cts +1 -1
  56. package/dist/curves/star.d.ts +1 -1
  57. package/dist/curves/star.js +4 -7
  58. package/dist/curves/star4.cjs +5 -8
  59. package/dist/curves/star4.d.cts +1 -1
  60. package/dist/curves/star4.d.ts +1 -1
  61. package/dist/curves/star4.js +4 -7
  62. package/dist/curves/star7.cjs +5 -8
  63. package/dist/curves/star7.d.cts +1 -1
  64. package/dist/curves/star7.d.ts +1 -1
  65. package/dist/curves/star7.js +4 -7
  66. package/dist/index.cjs +83 -106
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.d.cts +42 -78
  69. package/dist/index.d.ts +42 -78
  70. package/dist/index.js +83 -124
  71. package/dist/index.js.map +1 -1
  72. package/dist/types-BL9HhEmk.d.cts +246 -259
  73. package/dist/types-BL9HhEmk.d.ts +246 -259
  74. package/package.json +1 -1
package/README.md CHANGED
@@ -33,7 +33,7 @@ Or use directly from CDN:
33
33
 
34
34
  ```html
35
35
  <script type="module">
36
- import { createSarmal, curves } from "https://cdn.jsdelivr.net/npm/@sarmal/core/+esm";
36
+ import { createSarmal, rose3 } from "https://cdn.jsdelivr.net/npm/@sarmal/core/+esm";
37
37
  // your code here
38
38
  </script>
39
39
  ```
@@ -41,10 +41,10 @@ Or use directly from CDN:
41
41
  ## Quick Start
42
42
 
43
43
  ```javascript
44
- import { createSarmal, curves } from "@sarmal/core";
44
+ import { createSarmal, rose3 } from "@sarmal/core";
45
45
 
46
46
  const canvas = document.getElementById("my-canvas");
47
- const sarmal = createSarmal(canvas, curves.artemis2, {
47
+ const sarmal = createSarmal(canvas, rose3, {
48
48
  trailLength: 30,
49
49
  strokeStyle: "#00ffaa",
50
50
  lineWidth: 2,
@@ -57,7 +57,7 @@ Or with **auto-init** without having to write any JS:
57
57
 
58
58
  ```html
59
59
  <script src="https://cdn.jsdelivr.net/npm/@sarmal/core/dist/auto-init.js"></script>
60
- <canvas data-sarmal="artemis2" width="200" height="200"></canvas>
60
+ <canvas data-sarmal="rose3" width="200" height="200"></canvas>
61
61
  ```
62
62
 
63
63
  ## Standard Curves
@@ -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,16 +167,13 @@ 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 =
171
- frozenStrategy === "normalized"
172
- ? (sampleT / frozenA.period) * frozenB.period
173
- : sampleT;
170
+ const tB = frozenStrategy === "normalized" ? sampleT / frozenA.period * frozenB.period : sampleT;
174
171
  const b = frozenB.fn(tB, time, params);
175
172
  return {
176
173
  x: a.x + (b.x - a.x) * frozenAlpha,
177
- y: a.y + (b.y - a.y) * frozenAlpha,
174
+ y: a.y + (b.y - a.y) * frozenAlpha
178
175
  };
179
- },
176
+ }
180
177
  };
181
178
  }
182
179
  _morphStrategy = strategy;
@@ -189,7 +186,7 @@ function createEngine(curveDef, trailLength = 120) {
189
186
  completeMorph() {
190
187
  if (morphCurveB !== null) {
191
188
  if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
192
- t = (t / curve.period) * morphCurveB.period;
189
+ t = t / curve.period * morphCurveB.period;
193
190
  }
194
191
  curve = morphCurveB;
195
192
  }
@@ -201,22 +198,19 @@ function createEngine(curveDef, trailLength = 120) {
201
198
  const points = new Array(steps);
202
199
  if (morphCurveB !== null && _morphAlpha !== null) {
203
200
  for (let i = 0; i < steps; i++) {
204
- const sampleT = (i / (steps - 1)) * curve.period;
201
+ const sampleT = i / (steps - 1) * curve.period;
205
202
  const a = sampleSkeleton(curve, sampleT);
206
- const tB =
207
- _morphStrategy === "normalized"
208
- ? (sampleT / curve.period) * morphCurveB.period
209
- : sampleT;
203
+ const tB = _morphStrategy === "normalized" ? sampleT / curve.period * morphCurveB.period : sampleT;
210
204
  const b = sampleSkeleton(morphCurveB, tB);
211
205
  points[i] = {
212
206
  x: a.x + (b.x - a.x) * _morphAlpha,
213
- y: a.y + (b.y - a.y) * _morphAlpha,
207
+ y: a.y + (b.y - a.y) * _morphAlpha
214
208
  };
215
209
  }
216
210
  return points;
217
211
  }
218
212
  for (let i = 0; i < steps; i++) {
219
- const sampleT = (i / (steps - 1)) * curve.period;
213
+ const sampleT = i / (steps - 1) * curve.period;
220
214
  points[i] = sampleSkeleton(curve, sampleT);
221
215
  }
222
216
  return points;
@@ -258,7 +252,7 @@ function createEngine(curveDef, trailLength = 120) {
258
252
  _speedTransition.reject(new Error("Speed transition cancelled"));
259
253
  _speedTransition = null;
260
254
  }
261
- },
255
+ }
262
256
  };
263
257
  }
264
258
 
@@ -321,16 +315,13 @@ function computeTrailQuad(trail, i, trailCount, toX, toY) {
321
315
  r1x: nx - n1.x * w1,
322
316
  r1y: ny - n1.y * w1,
323
317
  opacity,
324
- progress,
318
+ progress
325
319
  };
326
320
  }
327
321
  function computeBoundaries(pts, logicalWidth, logicalHeight) {
328
322
  if (pts.length === 0) return null;
329
323
  const first = pts[0];
330
- let minX = first.x,
331
- maxX = first.x,
332
- minY = first.y,
333
- maxY = first.y;
324
+ let minX = first.x, maxX = first.x, minY = first.y, maxY = first.y;
334
325
  for (const p of pts) {
335
326
  if (p.x < minX) {
336
327
  minX = p.x;
@@ -349,7 +340,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight) {
349
340
  const h = maxY - minY;
350
341
  if (w === 0 && h === 0) {
351
342
  throw new Error(
352
- "[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t.",
343
+ "[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
353
344
  );
354
345
  }
355
346
  const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
@@ -360,12 +351,12 @@ function computeBoundaries(pts, logicalWidth, logicalHeight) {
360
351
  scaleXProportional,
361
352
  scaleYProportional,
362
353
  scaleXMinPadding,
363
- scaleYMinPadding,
354
+ scaleYMinPadding
364
355
  );
365
356
  return {
366
357
  scale,
367
358
  offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
368
- offsetY: (logicalHeight - h * scale) / 2 - minY * scale,
359
+ offsetY: (logicalHeight - h * scale) / 2 - minY * scale
369
360
  };
370
361
  }
371
362
  function enginePassthroughs(engine) {
@@ -375,17 +366,17 @@ function enginePassthroughs(engine) {
375
366
  setSpeed: engine.setSpeed,
376
367
  getSpeed: engine.getSpeed,
377
368
  resetSpeed: engine.resetSpeed,
378
- setSpeedOver: engine.setSpeedOver,
369
+ setSpeedOver: engine.setSpeedOver
379
370
  };
380
371
  }
381
372
  function hexToRgb(hex) {
382
373
  const n = parseInt(hex.slice(1), 16);
383
- return { r: n >> 16, g: (n >> 8) & 255, b: n & 255 };
374
+ return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
384
375
  }
385
376
  var lerpRgb = (a, b, t) => ({
386
377
  r: Math.round(a.r + (b.r - a.r) * t),
387
378
  g: Math.round(a.g + (b.g - a.g) * t),
388
- b: Math.round(a.b + (b.b - a.b) * t),
379
+ b: Math.round(a.b + (b.b - a.b) * t)
389
380
  });
390
381
  function getPaletteColor(palette, position, timeOffset = 0) {
391
382
  if (palette.length === 0) {
@@ -394,7 +385,7 @@ function getPaletteColor(palette, position, timeOffset = 0) {
394
385
  if (palette.length === 1) {
395
386
  return hexToRgb(palette[0]);
396
387
  }
397
- const cyclePos = (position + timeOffset) % 1;
388
+ const cyclePos = ((position + timeOffset) % 1 + 1) % 1;
398
389
  const scaled = cyclePos * palette.length;
399
390
  const idx = Math.floor(scaled);
400
391
  const t = scaled - idx;
@@ -408,7 +399,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
408
399
  "trailColor",
409
400
  "headColor",
410
401
  "skeletonColor",
411
- "trailStyle",
402
+ "trailStyle"
412
403
  ]);
413
404
  function validateRenderOptions(partial) {
414
405
  for (const key of Object.keys(partial)) {
@@ -433,7 +424,7 @@ function assertTrailColor(value) {
433
424
  if (typeof value === "string") {
434
425
  if (!HEX_COLOR_RE.test(value)) {
435
426
  throw new TypeError(
436
- `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`,
427
+ `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`
437
428
  );
438
429
  }
439
430
  return;
@@ -441,21 +432,21 @@ function assertTrailColor(value) {
441
432
  if (Array.isArray(value)) {
442
433
  if (value.length < 2) {
443
434
  throw new RangeError(
444
- `[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`,
435
+ `[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`
445
436
  );
446
437
  }
447
438
  for (let i = 0; i < value.length; i++) {
448
439
  const entry = value[i];
449
440
  if (typeof entry !== "string" || !HEX_COLOR_RE.test(entry)) {
450
441
  throw new TypeError(
451
- `[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`,
442
+ `[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`
452
443
  );
453
444
  }
454
445
  }
455
446
  return;
456
447
  }
457
448
  throw new TypeError(
458
- `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`,
449
+ `[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`
459
450
  );
460
451
  }
461
452
  function assertHeadColor(value) {
@@ -464,7 +455,7 @@ function assertHeadColor(value) {
464
455
  }
465
456
  if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
466
457
  throw new TypeError(
467
- `[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`,
458
+ `[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`
468
459
  );
469
460
  }
470
461
  }
@@ -474,14 +465,14 @@ function assertSkeletonColor(value) {
474
465
  }
475
466
  if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
476
467
  throw new TypeError(
477
- `[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`,
468
+ `[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`
478
469
  );
479
470
  }
480
471
  }
481
472
  function assertTrailStyle(value) {
482
473
  if (!TRAIL_STYLES.includes(value)) {
483
474
  throw new RangeError(
484
- `[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`,
475
+ `[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`
485
476
  );
486
477
  }
487
478
  }
@@ -503,13 +494,13 @@ function resolveHeadColor(trailColor, trailStyle) {
503
494
  function warnIfTrailColorMismatch(trailColor, trailStyle) {
504
495
  if (trailStyle === "default" && Array.isArray(trailColor)) {
505
496
  console.warn(
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.',
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.'
507
498
  );
508
499
  return;
509
500
  }
510
501
  if (trailStyle !== "default" && typeof trailColor === "string") {
511
502
  console.warn(
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.`,
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.`
513
504
  );
514
505
  }
515
506
  }
@@ -519,7 +510,7 @@ var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160)
519
510
  var WHITE_HEX = "#ffffff";
520
511
  function hexToRgbComponents(hex) {
521
512
  const n = parseInt(hex.slice(1), 16);
522
- return `${n >> 16},${(n >> 8) & 255},${n & 255}`;
513
+ return `${n >> 16},${n >> 8 & 255},${n & 255}`;
523
514
  }
524
515
  function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
525
516
  target.style.width = `${logicalWidth}px`;
@@ -644,7 +635,7 @@ function createRenderer(options) {
644
635
  i,
645
636
  trailCount,
646
637
  toX,
647
- toY,
638
+ toY
648
639
  );
649
640
  if (trailStyle === "default") {
650
641
  ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
@@ -805,7 +796,7 @@ function createRenderer(options) {
805
796
  if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
806
797
  warnIfTrailColorMismatch(trailColor, trailStyle);
807
798
  }
808
- },
799
+ }
809
800
  };
810
801
  if (shouldAutoStart) {
811
802
  instance.play();
@@ -816,22 +807,19 @@ function createRenderer(options) {
816
807
  // src/curves/artemis2.ts
817
808
  var TWO_PI2 = Math.PI * 2;
818
809
  function artemis2Fn(t, _time, _params) {
819
- const a = 0.35,
820
- b = 0.15,
821
- ox = 0.175;
822
- const s = Math.sin(t),
823
- c = Math.cos(t);
810
+ const a = 0.35, b = 0.15, ox = 0.175;
811
+ const s = Math.sin(t), c = Math.cos(t);
824
812
  const denom = 1 + s * s;
825
813
  return {
826
- x: (c * (1 + a * c)) / denom - ox,
827
- y: (s * c * (1 + b * c)) / denom,
814
+ x: c * (1 + a * c) / denom - ox,
815
+ y: s * c * (1 + b * c) / denom
828
816
  };
829
817
  }
830
818
  var artemis2 = {
831
819
  name: "Artemis II",
832
820
  fn: artemis2Fn,
833
821
  period: TWO_PI2,
834
- speed: 0.7,
822
+ speed: 0.7
835
823
  };
836
824
 
837
825
  // src/curves/astroid.ts
@@ -841,14 +829,14 @@ function astroidFn(t, _time, _params) {
841
829
  const s = Math.sin(t);
842
830
  return {
843
831
  x: c * c * c,
844
- y: s * s * s,
832
+ y: s * s * s
845
833
  };
846
834
  }
847
835
  var astroid = {
848
836
  name: "Astroid",
849
837
  fn: astroidFn,
850
838
  period: TWO_PI3,
851
- speed: 1.1,
839
+ speed: 1.1
852
840
  };
853
841
 
854
842
  // src/curves/deltoid.ts
@@ -856,14 +844,14 @@ var TWO_PI4 = Math.PI * 2;
856
844
  function deltoidFn(t, _time, _params) {
857
845
  return {
858
846
  x: 2 * Math.cos(t) + Math.cos(2 * t),
859
- y: 2 * Math.sin(t) - Math.sin(2 * t),
847
+ y: 2 * Math.sin(t) - Math.sin(2 * t)
860
848
  };
861
849
  }
862
850
  var deltoid = {
863
851
  name: "Deltoid",
864
852
  fn: deltoidFn,
865
853
  period: TWO_PI4,
866
- speed: 0.9,
854
+ speed: 0.9
867
855
  };
868
856
 
869
857
  // src/curves/epicycloid3.ts
@@ -871,14 +859,14 @@ var TWO_PI5 = Math.PI * 2;
871
859
  function epicycloid3Fn(t, _time, _params) {
872
860
  return {
873
861
  x: 4 * Math.cos(t) - Math.cos(4 * t),
874
- y: 4 * Math.sin(t) - Math.sin(4 * t),
862
+ y: 4 * Math.sin(t) - Math.sin(4 * t)
875
863
  };
876
864
  }
877
865
  var epicycloid3 = {
878
866
  name: "Epicycloid (n=3)",
879
867
  fn: epicycloid3Fn,
880
868
  period: TWO_PI5,
881
- speed: 0.75,
869
+ speed: 0.75
882
870
  };
883
871
 
884
872
  // src/curves/epitrochoid7.ts
@@ -887,14 +875,14 @@ function epitrochoid7Fn(t, _time, _params) {
887
875
  const d = 1 + 0.55 * Math.sin(t * 0.5);
888
876
  return {
889
877
  x: 7 * Math.cos(t) - d * Math.cos(7 * t),
890
- y: 7 * Math.sin(t) - d * Math.sin(7 * t),
878
+ y: 7 * Math.sin(t) - d * Math.sin(7 * t)
891
879
  };
892
880
  }
893
881
  function epitrochoid7SkeletonFn(t) {
894
882
  const d = 1.275;
895
883
  return {
896
884
  x: 7 * Math.cos(t) - d * Math.cos(7 * t),
897
- y: 7 * Math.sin(t) - d * Math.sin(7 * t),
885
+ y: 7 * Math.sin(t) - d * Math.sin(7 * t)
898
886
  };
899
887
  }
900
888
  var epitrochoid7 = {
@@ -902,7 +890,7 @@ var epitrochoid7 = {
902
890
  fn: epitrochoid7Fn,
903
891
  period: TWO_PI6,
904
892
  speed: 1.4,
905
- skeletonFn: epitrochoid7SkeletonFn,
893
+ skeletonFn: epitrochoid7SkeletonFn
906
894
  };
907
895
 
908
896
  // src/curves/lissajous32.ts
@@ -911,7 +899,7 @@ function lissajous32Fn(t, time, _params) {
911
899
  const phi = time * 0.45;
912
900
  return {
913
901
  x: Math.sin(3 * t + phi),
914
- y: Math.sin(2 * t),
902
+ y: Math.sin(2 * t)
915
903
  };
916
904
  }
917
905
  var lissajous32 = {
@@ -919,7 +907,7 @@ var lissajous32 = {
919
907
  fn: lissajous32Fn,
920
908
  period: TWO_PI7,
921
909
  speed: 2,
922
- skeleton: "live",
910
+ skeleton: "live"
923
911
  };
924
912
 
925
913
  // src/curves/lissajous43.ts
@@ -928,7 +916,7 @@ function lissajous43Fn(t, time, _params) {
928
916
  const phi = time * 0.38;
929
917
  return {
930
918
  x: Math.sin(4 * t + phi),
931
- y: Math.sin(3 * t),
919
+ y: Math.sin(3 * t)
932
920
  };
933
921
  }
934
922
  var lissajous43 = {
@@ -936,18 +924,17 @@ var lissajous43 = {
936
924
  fn: lissajous43Fn,
937
925
  period: TWO_PI8,
938
926
  speed: 1.8,
939
- skeleton: "live",
927
+ skeleton: "live"
940
928
  };
941
929
 
942
930
  // src/curves/lame.ts
943
931
  var TWO_PI9 = Math.PI * 2;
944
932
  function lameFn(t, time, _params) {
945
933
  const p = 1.75 + 1.25 * Math.sin(time * 0.48);
946
- const c = Math.cos(t),
947
- s = Math.sin(t);
934
+ const c = Math.cos(t), s = Math.sin(t);
948
935
  return {
949
936
  x: Math.sign(c) * Math.pow(Math.abs(c), p),
950
- y: Math.sign(s) * Math.pow(Math.abs(s), p),
937
+ y: Math.sign(s) * Math.pow(Math.abs(s), p)
951
938
  };
952
939
  }
953
940
  var lame = {
@@ -955,7 +942,7 @@ var lame = {
955
942
  fn: lameFn,
956
943
  period: TWO_PI9,
957
944
  speed: 1,
958
- skeleton: "live",
945
+ skeleton: "live"
959
946
  };
960
947
 
961
948
  // src/curves/rose3.ts
@@ -964,14 +951,14 @@ function rose3Fn(t, _time, _params) {
964
951
  const r = Math.cos(3 * t);
965
952
  return {
966
953
  x: r * Math.cos(t),
967
- y: r * Math.sin(t),
954
+ y: r * Math.sin(t)
968
955
  };
969
956
  }
970
957
  var rose3 = {
971
958
  name: "Rose (n=3)",
972
959
  fn: rose3Fn,
973
960
  period: TWO_PI10,
974
- speed: 1.15,
961
+ speed: 1.15
975
962
  };
976
963
 
977
964
  // src/curves/rose5.ts
@@ -980,87 +967,78 @@ function rose5Fn(t, _time, _params) {
980
967
  const r = Math.cos(5 * t);
981
968
  return {
982
969
  x: r * Math.cos(t),
983
- y: r * Math.sin(t),
970
+ y: r * Math.sin(t)
984
971
  };
985
972
  }
986
973
  var rose5 = {
987
974
  name: "Rose (n=5)",
988
975
  fn: rose5Fn,
989
976
  period: TWO_PI11,
990
- speed: 1,
977
+ speed: 1
991
978
  };
992
979
 
993
980
  // src/curves/rose52.ts
994
981
  var FOUR_PI = Math.PI * 4;
995
982
  function rose52Fn(t, _time, _params) {
996
- const r = Math.cos((5 / 2) * t);
983
+ const r = Math.cos(5 / 2 * t);
997
984
  return {
998
985
  x: r * Math.cos(t),
999
- y: r * Math.sin(t),
986
+ y: r * Math.sin(t)
1000
987
  };
1001
988
  }
1002
989
  var rose52 = {
1003
990
  name: "Rose (n=5/2)",
1004
991
  fn: rose52Fn,
1005
992
  period: FOUR_PI,
1006
- speed: 0.8,
993
+ speed: 0.8
1007
994
  };
1008
995
 
1009
996
  // src/curves/star.ts
1010
997
  var TWO_PI12 = Math.PI * 2;
1011
998
  function starFn(t, _time, _params) {
1012
- const r =
1013
- Math.abs(Math.cos((5 / 2) * t)) +
1014
- 0.35 * Math.abs(Math.cos((15 / 2) * t)) +
1015
- 0.15 * Math.abs(Math.cos((25 / 2) * t));
999
+ 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));
1016
1000
  return {
1017
1001
  x: r * Math.cos(t),
1018
- y: r * Math.sin(t),
1002
+ y: r * Math.sin(t)
1019
1003
  };
1020
1004
  }
1021
1005
  var star = {
1022
1006
  name: "Star",
1023
1007
  fn: starFn,
1024
1008
  period: TWO_PI12,
1025
- speed: 1,
1009
+ speed: 1
1026
1010
  };
1027
1011
 
1028
1012
  // src/curves/star4.ts
1029
1013
  var TWO_PI13 = Math.PI * 2;
1030
1014
  function star4Fn(t, _time, _params) {
1031
- const r =
1032
- Math.abs(Math.cos(2 * t)) +
1033
- 0.35 * Math.abs(Math.cos(6 * t)) +
1034
- 0.15 * Math.abs(Math.cos(10 * t));
1015
+ const r = Math.abs(Math.cos(2 * t)) + 0.35 * Math.abs(Math.cos(6 * t)) + 0.15 * Math.abs(Math.cos(10 * t));
1035
1016
  return {
1036
1017
  x: r * Math.cos(t),
1037
- y: r * Math.sin(t),
1018
+ y: r * Math.sin(t)
1038
1019
  };
1039
1020
  }
1040
1021
  var star4 = {
1041
1022
  name: "Star (4-arm)",
1042
1023
  fn: star4Fn,
1043
1024
  period: TWO_PI13,
1044
- speed: 1,
1025
+ speed: 1
1045
1026
  };
1046
1027
 
1047
1028
  // src/curves/star7.ts
1048
1029
  var TWO_PI14 = Math.PI * 2;
1049
1030
  function star7Fn(t, _time, _params) {
1050
- const r =
1051
- Math.abs(Math.cos((7 / 2) * t)) +
1052
- 0.35 * Math.abs(Math.cos((21 / 2) * t)) +
1053
- 0.15 * Math.abs(Math.cos((35 / 2) * t));
1031
+ 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));
1054
1032
  return {
1055
1033
  x: r * Math.cos(t),
1056
- y: r * Math.sin(t),
1034
+ y: r * Math.sin(t)
1057
1035
  };
1058
1036
  }
1059
1037
  var star7 = {
1060
1038
  name: "Star (7-arm)",
1061
1039
  fn: star7Fn,
1062
1040
  period: TWO_PI14,
1063
- speed: 1,
1041
+ speed: 1
1064
1042
  };
1065
1043
 
1066
1044
  // src/curves/index.ts
@@ -1078,7 +1056,7 @@ var curves = {
1078
1056
  lissajous32,
1079
1057
  lissajous43,
1080
1058
  epicycloid3,
1081
- lame,
1059
+ lame
1082
1060
  };
1083
1061
 
1084
1062
  // src/index.ts
@@ -1095,7 +1073,8 @@ function parseTrailColor(value) {
1095
1073
  if (Array.isArray(parsed)) {
1096
1074
  return parsed;
1097
1075
  }
1098
- } catch {}
1076
+ } catch {
1077
+ }
1099
1078
  return value;
1100
1079
  }
1101
1080
  function init() {
@@ -1110,16 +1089,16 @@ function init() {
1110
1089
  return console.error(`[sarmal] "${curveName}" is not a valid curve name`);
1111
1090
  }
1112
1091
  const instance = createSarmal(canvas, curveDef, {
1113
- ...(canvas.dataset.trailColor && {
1114
- trailColor: parseTrailColor(canvas.dataset.trailColor),
1115
- }),
1116
- ...(canvas.dataset.skeletonColor && { skeletonColor: canvas.dataset.skeletonColor }),
1117
- ...(canvas.dataset.headColor && { headColor: canvas.dataset.headColor }),
1118
- ...(canvas.dataset.headRadius && { headRadius: parseFloat(canvas.dataset.headRadius) }),
1119
- ...(canvas.dataset.trailLength && { trailLength: parseInt(canvas.dataset.trailLength, 10) }),
1120
- ...(canvas.dataset.trailStyle && {
1121
- trailStyle: canvas.dataset.trailStyle,
1122
- }),
1092
+ ...canvas.dataset.trailColor && {
1093
+ trailColor: parseTrailColor(canvas.dataset.trailColor)
1094
+ },
1095
+ ...canvas.dataset.skeletonColor && { skeletonColor: canvas.dataset.skeletonColor },
1096
+ ...canvas.dataset.headColor && { headColor: canvas.dataset.headColor },
1097
+ ...canvas.dataset.headRadius && { headRadius: parseFloat(canvas.dataset.headRadius) },
1098
+ ...canvas.dataset.trailLength && { trailLength: parseInt(canvas.dataset.trailLength, 10) },
1099
+ ...canvas.dataset.trailStyle && {
1100
+ trailStyle: canvas.dataset.trailStyle
1101
+ }
1123
1102
  });
1124
1103
  if (canvas.dataset.speed) {
1125
1104
  instance.setSpeed(parseFloat(canvas.dataset.speed));
@@ -1136,4 +1115,4 @@ if (document.readyState === "loading") {
1136
1115
 
1137
1116
  exports.init = init;
1138
1117
  //# sourceMappingURL=auto-init.cjs.map
1139
- //# sourceMappingURL=auto-init.cjs.map
1118
+ //# sourceMappingURL=auto-init.cjs.map