@sarmal/core 0.25.1 → 0.27.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 (113) hide show
  1. package/dist/auto-init.cjs +107 -104
  2. package/dist/auto-init.cjs.map +1 -1
  3. package/dist/auto-init.js +107 -104
  4. package/dist/auto-init.js.map +1 -1
  5. package/dist/cli.js +1048 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/curves/artemis2.cjs +5 -5
  8. package/dist/curves/artemis2.cjs.map +1 -1
  9. package/dist/curves/artemis2.d.cts +1 -1
  10. package/dist/curves/artemis2.d.ts +1 -1
  11. package/dist/curves/artemis2.js +5 -5
  12. package/dist/curves/artemis2.js.map +1 -1
  13. package/dist/curves/astroid.cjs +3 -3
  14. package/dist/curves/astroid.cjs.map +1 -1
  15. package/dist/curves/astroid.d.cts +1 -1
  16. package/dist/curves/astroid.d.ts +1 -1
  17. package/dist/curves/astroid.js +3 -3
  18. package/dist/curves/astroid.js.map +1 -1
  19. package/dist/curves/deltoid.cjs +3 -3
  20. package/dist/curves/deltoid.cjs.map +1 -1
  21. package/dist/curves/deltoid.d.cts +1 -1
  22. package/dist/curves/deltoid.d.ts +1 -1
  23. package/dist/curves/deltoid.js +3 -3
  24. package/dist/curves/deltoid.js.map +1 -1
  25. package/dist/curves/epicycloid3.cjs +3 -3
  26. package/dist/curves/epicycloid3.cjs.map +1 -1
  27. package/dist/curves/epicycloid3.d.cts +1 -1
  28. package/dist/curves/epicycloid3.d.ts +1 -1
  29. package/dist/curves/epicycloid3.js +3 -3
  30. package/dist/curves/epicycloid3.js.map +1 -1
  31. package/dist/curves/epitrochoid7.cjs +7 -7
  32. package/dist/curves/epitrochoid7.cjs.map +1 -1
  33. package/dist/curves/epitrochoid7.d.cts +1 -1
  34. package/dist/curves/epitrochoid7.d.ts +1 -1
  35. package/dist/curves/epitrochoid7.js +7 -7
  36. package/dist/curves/epitrochoid7.js.map +1 -1
  37. package/dist/curves/index.cjs +63 -63
  38. package/dist/curves/index.cjs.map +1 -1
  39. package/dist/curves/index.d.cts +1 -1
  40. package/dist/curves/index.d.ts +1 -1
  41. package/dist/curves/index.js +63 -63
  42. package/dist/curves/index.js.map +1 -1
  43. package/dist/curves/lame.cjs +4 -4
  44. package/dist/curves/lame.cjs.map +1 -1
  45. package/dist/curves/lame.d.cts +1 -1
  46. package/dist/curves/lame.d.ts +1 -1
  47. package/dist/curves/lame.js +4 -4
  48. package/dist/curves/lame.js.map +1 -1
  49. package/dist/curves/lissajous32.cjs +4 -4
  50. package/dist/curves/lissajous32.cjs.map +1 -1
  51. package/dist/curves/lissajous32.d.cts +1 -1
  52. package/dist/curves/lissajous32.d.ts +1 -1
  53. package/dist/curves/lissajous32.js +4 -4
  54. package/dist/curves/lissajous32.js.map +1 -1
  55. package/dist/curves/lissajous43.cjs +4 -4
  56. package/dist/curves/lissajous43.cjs.map +1 -1
  57. package/dist/curves/lissajous43.d.cts +1 -1
  58. package/dist/curves/lissajous43.d.ts +1 -1
  59. package/dist/curves/lissajous43.js +4 -4
  60. package/dist/curves/lissajous43.js.map +1 -1
  61. package/dist/curves/rose3.cjs +4 -4
  62. package/dist/curves/rose3.cjs.map +1 -1
  63. package/dist/curves/rose3.d.cts +1 -1
  64. package/dist/curves/rose3.d.ts +1 -1
  65. package/dist/curves/rose3.js +4 -4
  66. package/dist/curves/rose3.js.map +1 -1
  67. package/dist/curves/rose5.cjs +4 -4
  68. package/dist/curves/rose5.cjs.map +1 -1
  69. package/dist/curves/rose5.d.cts +1 -1
  70. package/dist/curves/rose5.d.ts +1 -1
  71. package/dist/curves/rose5.js +4 -4
  72. package/dist/curves/rose5.js.map +1 -1
  73. package/dist/curves/rose52.cjs +4 -4
  74. package/dist/curves/rose52.cjs.map +1 -1
  75. package/dist/curves/rose52.d.cts +1 -1
  76. package/dist/curves/rose52.d.ts +1 -1
  77. package/dist/curves/rose52.js +4 -4
  78. package/dist/curves/rose52.js.map +1 -1
  79. package/dist/curves/star.cjs +6 -6
  80. package/dist/curves/star.cjs.map +1 -1
  81. package/dist/curves/star.d.cts +1 -1
  82. package/dist/curves/star.d.ts +1 -1
  83. package/dist/curves/star.js +6 -6
  84. package/dist/curves/star.js.map +1 -1
  85. package/dist/curves/star4.cjs +6 -6
  86. package/dist/curves/star4.cjs.map +1 -1
  87. package/dist/curves/star4.d.cts +2 -2
  88. package/dist/curves/star4.d.ts +2 -2
  89. package/dist/curves/star4.js +6 -6
  90. package/dist/curves/star4.js.map +1 -1
  91. package/dist/curves/star7.cjs +6 -6
  92. package/dist/curves/star7.cjs.map +1 -1
  93. package/dist/curves/star7.d.cts +2 -2
  94. package/dist/curves/star7.d.ts +2 -2
  95. package/dist/curves/star7.js +6 -6
  96. package/dist/curves/star7.js.map +1 -1
  97. package/dist/index.cjs +107 -104
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.cts +13 -45
  100. package/dist/index.d.ts +13 -45
  101. package/dist/index.js +107 -104
  102. package/dist/index.js.map +1 -1
  103. package/dist/renderer-shared-OR--cv-t.d.ts +49 -0
  104. package/dist/renderer-shared-jqw_Q1WO.d.cts +49 -0
  105. package/dist/terminal.cjs +593 -0
  106. package/dist/terminal.cjs.map +1 -0
  107. package/dist/terminal.d.cts +44 -0
  108. package/dist/terminal.d.ts +44 -0
  109. package/dist/terminal.js +585 -0
  110. package/dist/terminal.js.map +1 -0
  111. package/dist/{types-Z9i1_AQZ.d.cts → types-zbxUgcmZ.d.cts} +30 -30
  112. package/dist/{types-Z9i1_AQZ.d.ts → types-zbxUgcmZ.d.ts} +30 -30
  113. package/package.json +11 -1
package/dist/index.d.cts CHANGED
@@ -3,19 +3,25 @@ import {
3
3
  E as Engine,
4
4
  S as SarmalInstance,
5
5
  C as CurveDef,
6
- P as Point,
7
6
  R as RendererOptions,
8
7
  a as ControlPoint,
8
+ P as Point,
9
9
  b as SarmalOptions,
10
- } from "./types-Z9i1_AQZ.cjs";
10
+ } from "./types-zbxUgcmZ.cjs";
11
11
  export {
12
12
  J as JumpOptions,
13
13
  c as RuntimeRenderOptions,
14
14
  d as SeekOptions,
15
15
  T as TrailColor,
16
16
  e as TrailStyle,
17
- } from "./types-Z9i1_AQZ.cjs";
17
+ } from "./types-zbxUgcmZ.cjs";
18
18
  export { CurveName, curves } from "./curves/index.cjs";
19
+ export {
20
+ B as BoundaryResult,
21
+ S as SarmalPalette,
22
+ c as computeBoundaries,
23
+ p as palettes,
24
+ } from "./renderer-shared-jqw_Q1WO.cjs";
19
25
  export { artemis2 } from "./curves/artemis2.cjs";
20
26
  export { astroid } from "./curves/astroid.cjs";
21
27
  export { deltoid } from "./curves/deltoid.cjs";
@@ -71,40 +77,6 @@ declare function createSarmalSVG(
71
77
  options?: SVGSarmalOptions,
72
78
  ): SarmalInstance;
73
79
 
74
- interface BoundaryResult {
75
- scale: number;
76
- offsetX: number;
77
- offsetY: number;
78
- }
79
- /**
80
- * Computes how to map engine coordinates into a viewport of the given logical size.
81
- * ! Returns `null` if `pts` is empty
82
- * ! Throws if all points are identical
83
- *
84
- * Padding per side is `max(FIT_PADDING * dim, minPaddingPx)`, so the stricter constraint wins.
85
- * `minPaddingPx` defaults to `FIT_PADDING_MIN` (4px) for pixel-space callers.
86
- * Pass `0` when the logical space is itself a normalized viewBox (e.g. SVG export).
87
- */
88
- declare function computeBoundaries(
89
- pts: Point[],
90
- logicalWidth: number,
91
- logicalHeight: number,
92
- minPaddingPx?: number,
93
- ): BoundaryResult | null;
94
- /**
95
- * Can be passed directly to `trailColor`,
96
- * or can be mixed/sliced before passing as a prop.
97
- */
98
- declare const palettes: {
99
- readonly bard: ["#a855f7", "#3b82f6", "#14b8a6", "#ec4899"];
100
- readonly sunset: ["#f97316", "#dc2626", "#9333ea", "#f472b6"];
101
- readonly ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"];
102
- readonly ice: ["#1e3a8a", "#67e8f9"];
103
- readonly fire: ["#7f1d1d", "#fbbf24"];
104
- readonly forest: ["#14532d", "#86efac"];
105
- };
106
- type SarmalPalette = keyof typeof palettes;
107
-
108
80
  declare function createEngine(curveDef: CurveDef, trailLength?: number): Engine;
109
81
 
110
82
  /**
@@ -121,11 +93,11 @@ declare function createRenderer(options: RendererOptions): SarmalInstance;
121
93
  * and each segment uses a phantom predecessor / successor so the
122
94
  * curve passes exactly through every control point.
123
95
  *
124
- * @param points At least 1 point. An empty array yields `(0, 0)`. A single point returns that point for every `t`
125
- * @param t Parametric position along the closed loop. Wraps into `[0, 2π)` automatically, so values outside that range are remapped rather than rejected
126
- * @returns The `(x, y)` position on the spline at time `t`
96
+ * @param points At least 1 point. An empty array yields `(0, 0)`. A single point returns that point for every `phase`
97
+ * @param phase Parametric position along the closed loop. Wraps into `[0, 2π)` automatically, so values outside that range are remapped rather than rejected
98
+ * @returns The `(x, y)` position on the spline at position `phase`
127
99
  */
128
- declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Point;
100
+ declare function evaluateCatmullRom(points: Array<ControlPoint>, phase: number): Point;
129
101
  /**
130
102
  * The returned curve definition produces a closed Catmull-Rom spline that
131
103
  * passes through every point in order, looping back from the last point to the first.
@@ -180,7 +152,6 @@ declare function createSarmal(
180
152
 
181
153
  export {
182
154
  BaseRendererOptions,
183
- type BoundaryResult,
184
155
  CurveDef,
185
156
  Engine,
186
157
  Point,
@@ -189,8 +160,6 @@ export {
189
160
  type SVGSarmalOptions,
190
161
  SarmalInstance,
191
162
  SarmalOptions,
192
- type SarmalPalette,
193
- computeBoundaries,
194
163
  createEngine,
195
164
  createRenderer,
196
165
  createSVGRenderer,
@@ -198,5 +167,4 @@ export {
198
167
  createSarmalSVG,
199
168
  drawCurve,
200
169
  evaluateCatmullRom,
201
- palettes,
202
170
  };
package/dist/index.d.ts CHANGED
@@ -3,19 +3,25 @@ import {
3
3
  E as Engine,
4
4
  S as SarmalInstance,
5
5
  C as CurveDef,
6
- P as Point,
7
6
  R as RendererOptions,
8
7
  a as ControlPoint,
8
+ P as Point,
9
9
  b as SarmalOptions,
10
- } from "./types-Z9i1_AQZ.js";
10
+ } from "./types-zbxUgcmZ.js";
11
11
  export {
12
12
  J as JumpOptions,
13
13
  c as RuntimeRenderOptions,
14
14
  d as SeekOptions,
15
15
  T as TrailColor,
16
16
  e as TrailStyle,
17
- } from "./types-Z9i1_AQZ.js";
17
+ } from "./types-zbxUgcmZ.js";
18
18
  export { CurveName, curves } from "./curves/index.js";
19
+ export {
20
+ B as BoundaryResult,
21
+ S as SarmalPalette,
22
+ c as computeBoundaries,
23
+ p as palettes,
24
+ } from "./renderer-shared-OR--cv-t.js";
19
25
  export { artemis2 } from "./curves/artemis2.js";
20
26
  export { astroid } from "./curves/astroid.js";
21
27
  export { deltoid } from "./curves/deltoid.js";
@@ -71,40 +77,6 @@ declare function createSarmalSVG(
71
77
  options?: SVGSarmalOptions,
72
78
  ): SarmalInstance;
73
79
 
74
- interface BoundaryResult {
75
- scale: number;
76
- offsetX: number;
77
- offsetY: number;
78
- }
79
- /**
80
- * Computes how to map engine coordinates into a viewport of the given logical size.
81
- * ! Returns `null` if `pts` is empty
82
- * ! Throws if all points are identical
83
- *
84
- * Padding per side is `max(FIT_PADDING * dim, minPaddingPx)`, so the stricter constraint wins.
85
- * `minPaddingPx` defaults to `FIT_PADDING_MIN` (4px) for pixel-space callers.
86
- * Pass `0` when the logical space is itself a normalized viewBox (e.g. SVG export).
87
- */
88
- declare function computeBoundaries(
89
- pts: Point[],
90
- logicalWidth: number,
91
- logicalHeight: number,
92
- minPaddingPx?: number,
93
- ): BoundaryResult | null;
94
- /**
95
- * Can be passed directly to `trailColor`,
96
- * or can be mixed/sliced before passing as a prop.
97
- */
98
- declare const palettes: {
99
- readonly bard: ["#a855f7", "#3b82f6", "#14b8a6", "#ec4899"];
100
- readonly sunset: ["#f97316", "#dc2626", "#9333ea", "#f472b6"];
101
- readonly ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"];
102
- readonly ice: ["#1e3a8a", "#67e8f9"];
103
- readonly fire: ["#7f1d1d", "#fbbf24"];
104
- readonly forest: ["#14532d", "#86efac"];
105
- };
106
- type SarmalPalette = keyof typeof palettes;
107
-
108
80
  declare function createEngine(curveDef: CurveDef, trailLength?: number): Engine;
109
81
 
110
82
  /**
@@ -121,11 +93,11 @@ declare function createRenderer(options: RendererOptions): SarmalInstance;
121
93
  * and each segment uses a phantom predecessor / successor so the
122
94
  * curve passes exactly through every control point.
123
95
  *
124
- * @param points At least 1 point. An empty array yields `(0, 0)`. A single point returns that point for every `t`
125
- * @param t Parametric position along the closed loop. Wraps into `[0, 2π)` automatically, so values outside that range are remapped rather than rejected
126
- * @returns The `(x, y)` position on the spline at time `t`
96
+ * @param points At least 1 point. An empty array yields `(0, 0)`. A single point returns that point for every `phase`
97
+ * @param phase Parametric position along the closed loop. Wraps into `[0, 2π)` automatically, so values outside that range are remapped rather than rejected
98
+ * @returns The `(x, y)` position on the spline at position `phase`
127
99
  */
128
- declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Point;
100
+ declare function evaluateCatmullRom(points: Array<ControlPoint>, phase: number): Point;
129
101
  /**
130
102
  * The returned curve definition produces a closed Catmull-Rom spline that
131
103
  * passes through every point in order, looping back from the last point to the first.
@@ -180,7 +152,6 @@ declare function createSarmal(
180
152
 
181
153
  export {
182
154
  BaseRendererOptions,
183
- type BoundaryResult,
184
155
  CurveDef,
185
156
  Engine,
186
157
  Point,
@@ -189,8 +160,6 @@ export {
189
160
  type SVGSarmalOptions,
190
161
  SarmalInstance,
191
162
  SarmalOptions,
192
- type SarmalPalette,
193
- computeBoundaries,
194
163
  createEngine,
195
164
  createRenderer,
196
165
  createSVGRenderer,
@@ -198,5 +167,4 @@ export {
198
167
  createSarmalSVG,
199
168
  drawCurve,
200
169
  evaluateCatmullRom,
201
- palettes,
202
170
  };
package/dist/index.js CHANGED
@@ -72,21 +72,21 @@ function createEngine(curveDef, trailLength = 120) {
72
72
  }
73
73
  let curve = resolveCurve(curveDef);
74
74
  const trail = new CircularBuffer(trailLength);
75
- let t = 0;
75
+ let phase = 0;
76
76
  let actualTime = 0;
77
77
  let userSpeedOverride = null;
78
78
  let morphCurveB = null;
79
79
  let _morphAlpha = null;
80
80
  let _morphStrategy = "normalized";
81
81
  let _speedTransition = null;
82
- function sampleSkeleton(c, sampleT) {
82
+ function sampleSkeleton(c, samplePhase) {
83
83
  if (c.skeletonFn) {
84
- return c.skeletonFn(sampleT);
84
+ return c.skeletonFn(samplePhase);
85
85
  }
86
86
  if (c.skeleton === "live") {
87
- return c.fn(sampleT, actualTime, EMPTY_PARAMS);
87
+ return c.fn(samplePhase, actualTime, EMPTY_PARAMS);
88
88
  }
89
- return c.fn(sampleT, 0, EMPTY_PARAMS);
89
+ return c.fn(samplePhase, 0, EMPTY_PARAMS);
90
90
  }
91
91
  return {
92
92
  tick(deltaTime) {
@@ -104,15 +104,16 @@ function createEngine(curveDef, trailLength = 120) {
104
104
  if (morphCurveB !== null && _morphAlpha !== null) {
105
105
  effectiveSpeed = lerp(effectiveSpeed, morphCurveB.speed, _morphAlpha);
106
106
  }
107
- t = (t + effectiveSpeed * deltaTime) % curve.period;
107
+ phase = (phase + effectiveSpeed * deltaTime) % curve.period;
108
108
  actualTime += deltaTime;
109
109
  if (morphCurveB !== null && _morphAlpha !== null) {
110
- const a = curve.fn(t, actualTime, EMPTY_PARAMS);
111
- const tB = _morphStrategy === "normalized" ? (t / curve.period) * morphCurveB.period : t;
112
- const b = morphCurveB.fn(tB, actualTime, EMPTY_PARAMS);
110
+ const a = curve.fn(phase, actualTime, EMPTY_PARAMS);
111
+ const phaseB =
112
+ _morphStrategy === "normalized" ? (phase / curve.period) * morphCurveB.period : phase;
113
+ const b = morphCurveB.fn(phaseB, actualTime, EMPTY_PARAMS);
113
114
  trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
114
115
  } else {
115
- const point = curve.fn(t, actualTime, EMPTY_PARAMS);
116
+ const point = curve.fn(phase, actualTime, EMPTY_PARAMS);
116
117
  trail.push(point.x, point.y);
117
118
  }
118
119
  return trail.toArray();
@@ -130,30 +131,30 @@ function createEngine(curveDef, trailLength = 120) {
130
131
  return _morphAlpha;
131
132
  },
132
133
  reset() {
133
- t = 0;
134
+ phase = 0;
134
135
  actualTime = 0;
135
136
  trail.clear();
136
137
  },
137
- jump(newT, { clearTrail = false } = {}) {
138
- t = ((newT % curve.period) + curve.period) % curve.period;
138
+ jump(newPhase, { clearTrail = false } = {}) {
139
+ phase = ((newPhase % curve.period) + curve.period) % curve.period;
139
140
  if (clearTrail) {
140
141
  trail.clear();
141
142
  }
142
143
  },
143
- seek(targetT, { wrap = false, step = curve.period / trailLength } = {}) {
144
+ seek(targetPhase, { wrap = false, step = curve.period / trailLength } = {}) {
144
145
  const advance = curve.speed * step;
145
- const target = ((targetT % curve.period) + curve.period) % curve.period;
146
+ const target = ((targetPhase % curve.period) + curve.period) % curve.period;
146
147
  const targetTime = target / curve.speed;
147
- t = target;
148
+ phase = target;
148
149
  actualTime = targetTime;
149
150
  trail.clear();
150
151
  const pointsFromStart = Math.floor(target / advance) + 1;
151
152
  const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
152
153
  for (let i = count - 1; i >= 0; i--) {
153
- const sampleT = target - i * advance;
154
- const wrappedT = ((sampleT % curve.period) + curve.period) % curve.period;
155
- const time = targetTime - i * step;
156
- const point = curve.fn(wrappedT, time, EMPTY_PARAMS);
154
+ const samplePhase = target - i * advance;
155
+ const wrappedPhase = ((samplePhase % curve.period) + curve.period) % curve.period;
156
+ const elapsed = targetTime - i * step;
157
+ const point = curve.fn(wrappedPhase, elapsed, EMPTY_PARAMS);
157
158
  trail.push(point.x, point.y);
158
159
  }
159
160
  },
@@ -166,13 +167,13 @@ function createEngine(curveDef, trailLength = 120) {
166
167
  const frozenStrategy = _morphStrategy;
167
168
  curve = {
168
169
  ...frozenB,
169
- fn: (sampleT, time, params) => {
170
- const a = frozenA.fn(sampleT, time, params);
171
- const tB =
170
+ fn: (samplePhase, elapsed, params) => {
171
+ const a = frozenA.fn(samplePhase, elapsed, params);
172
+ const phaseB =
172
173
  frozenStrategy === "normalized"
173
- ? (sampleT / frozenA.period) * frozenB.period
174
- : sampleT;
175
- const b = frozenB.fn(tB, time, params);
174
+ ? (samplePhase / frozenA.period) * frozenB.period
175
+ : samplePhase;
176
+ const b = frozenB.fn(phaseB, elapsed, params);
176
177
  return {
177
178
  x: a.x + (b.x - a.x) * frozenAlpha,
178
179
  y: a.y + (b.y - a.y) * frozenAlpha,
@@ -190,7 +191,7 @@ function createEngine(curveDef, trailLength = 120) {
190
191
  completeMorph() {
191
192
  if (morphCurveB !== null) {
192
193
  if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
193
- t = (t / curve.period) * morphCurveB.period;
194
+ phase = (phase / curve.period) * morphCurveB.period;
194
195
  }
195
196
  curve = morphCurveB;
196
197
  }
@@ -202,13 +203,13 @@ function createEngine(curveDef, trailLength = 120) {
202
203
  const points2 = new Array(steps);
203
204
  if (morphCurveB !== null && _morphAlpha !== null) {
204
205
  for (let i = 0; i < steps; i++) {
205
- const sampleT = (i / (steps - 1)) * curve.period;
206
- const a = sampleSkeleton(curve, sampleT);
207
- const tB =
206
+ const samplePhase = (i / (steps - 1)) * curve.period;
207
+ const a = sampleSkeleton(curve, samplePhase);
208
+ const phaseB =
208
209
  _morphStrategy === "normalized"
209
- ? (sampleT / curve.period) * morphCurveB.period
210
- : sampleT;
211
- const b = sampleSkeleton(morphCurveB, tB);
210
+ ? (samplePhase / curve.period) * morphCurveB.period
211
+ : samplePhase;
212
+ const b = sampleSkeleton(morphCurveB, phaseB);
212
213
  points2[i] = {
213
214
  x: a.x + (b.x - a.x) * _morphAlpha,
214
215
  y: a.y + (b.y - a.y) * _morphAlpha,
@@ -217,8 +218,8 @@ function createEngine(curveDef, trailLength = 120) {
217
218
  return points2;
218
219
  }
219
220
  for (let i = 0; i < steps; i++) {
220
- const sampleT = (i / (steps - 1)) * curve.period;
221
- points2[i] = sampleSkeleton(curve, sampleT);
221
+ const samplePhase = (i / (steps - 1)) * curve.period;
222
+ points2[i] = sampleSkeleton(curve, samplePhase);
222
223
  }
223
224
  return points2;
224
225
  },
@@ -760,8 +761,8 @@ function createRenderer(options) {
760
761
  if (!engine.isLiveSkeleton) {
761
762
  buildSkeletonCanvas();
762
763
  }
763
- if (options.initialT !== void 0) {
764
- engine.seek(options.initialT);
764
+ if (options.initialPhase !== void 0) {
765
+ engine.seek(options.initialPhase);
765
766
  }
766
767
  renderFrame(0);
767
768
  const shouldAutoStart = options.autoStart !== false;
@@ -895,8 +896,10 @@ function sampleCurveSkeleton(curveDef) {
895
896
  const samples = Math.ceil(period * 50);
896
897
  const pts = Array.from({ length: samples });
897
898
  for (let i = 0; i < samples; i++) {
898
- const t = (i / (samples - 1)) * period;
899
- pts[i] = curveDef.skeletonFn ? curveDef.skeletonFn(t) : curveDef.fn(t, 0, EMPTY_PARAMS2);
899
+ const phase = (i / (samples - 1)) * period;
900
+ pts[i] = curveDef.skeletonFn
901
+ ? curveDef.skeletonFn(phase)
902
+ : curveDef.fn(phase, 0, EMPTY_PARAMS2);
900
903
  }
901
904
  return pts;
902
905
  }
@@ -1107,8 +1110,8 @@ function createSVGRenderer(options) {
1107
1110
  animationId = requestAnimationFrame(loop);
1108
1111
  }
1109
1112
  }
1110
- if (options.initialT !== void 0) {
1111
- engine.seek(options.initialT);
1113
+ if (options.initialPhase !== void 0) {
1114
+ engine.seek(options.initialPhase);
1112
1115
  }
1113
1116
  renderFrame(0);
1114
1117
  const shouldAutoStart = options.autoStart !== false;
@@ -1264,7 +1267,7 @@ function catmullRom1D(p0, p1, p2, p3, u) {
1264
1267
  (-p0 + 3 * p1 - 3 * p2 + p3) * u3)
1265
1268
  );
1266
1269
  }
1267
- function evaluateCatmullRom(points2, t) {
1270
+ function evaluateCatmullRom(points2, phase) {
1268
1271
  const N = points2.length;
1269
1272
  if (N === 0) {
1270
1273
  return { x: 0, y: 0 };
@@ -1272,13 +1275,13 @@ function evaluateCatmullRom(points2, t) {
1272
1275
  if (N === 1) {
1273
1276
  return { x: points2[0][0], y: points2[0][1] };
1274
1277
  }
1275
- t = ((t % PERIOD) + PERIOD) % PERIOD;
1278
+ phase = ((phase % PERIOD) + PERIOD) % PERIOD;
1276
1279
  const segmentSize = PERIOD / N;
1277
- let i = Math.floor(t / segmentSize);
1280
+ let i = Math.floor(phase / segmentSize);
1278
1281
  if (i >= N) {
1279
1282
  i = N - 1;
1280
1283
  }
1281
- let u = (t - i * segmentSize) / segmentSize;
1284
+ let u = (phase - i * segmentSize) / segmentSize;
1282
1285
  u = Math.max(0, Math.min(1, u));
1283
1286
  const p0 = points2[(i - 1 + N) % N];
1284
1287
  const p1 = points2[i];
@@ -1308,7 +1311,7 @@ function drawCurve(points2, opts) {
1308
1311
  const pts = points2.map(([x, y]) => [x, y]);
1309
1312
  return {
1310
1313
  name: opts?.name ?? "drawn",
1311
- fn: (t) => evaluateCatmullRom(pts, t),
1314
+ fn: (phase) => evaluateCatmullRom(pts, phase),
1312
1315
  period: PERIOD,
1313
1316
  };
1314
1317
  }
@@ -1344,9 +1347,9 @@ var artemis2 = {
1344
1347
 
1345
1348
  // src/curves/astroid.ts
1346
1349
  var TWO_PI2 = Math.PI * 2;
1347
- function astroidFn(t, _time, _params) {
1348
- const c = Math.cos(t);
1349
- const s = Math.sin(t);
1350
+ function astroidFn(phase, _elapsed, _params) {
1351
+ const c = Math.cos(phase);
1352
+ const s = Math.sin(phase);
1350
1353
  return {
1351
1354
  x: c * c * c,
1352
1355
  y: s * s * s,
@@ -1361,10 +1364,10 @@ var astroid = {
1361
1364
 
1362
1365
  // src/curves/deltoid.ts
1363
1366
  var TWO_PI3 = Math.PI * 2;
1364
- function deltoidFn(t, _time, _params) {
1367
+ function deltoidFn(phase, _elapsed, _params) {
1365
1368
  return {
1366
- x: 2 * Math.cos(t) + Math.cos(2 * t),
1367
- y: 2 * Math.sin(t) - Math.sin(2 * t),
1369
+ x: 2 * Math.cos(phase) + Math.cos(2 * phase),
1370
+ y: 2 * Math.sin(phase) - Math.sin(2 * phase),
1368
1371
  };
1369
1372
  }
1370
1373
  var deltoid = {
@@ -1376,10 +1379,10 @@ var deltoid = {
1376
1379
 
1377
1380
  // src/curves/epicycloid3.ts
1378
1381
  var TWO_PI4 = Math.PI * 2;
1379
- function epicycloid3Fn(t, _time, _params) {
1382
+ function epicycloid3Fn(phase, _elapsed, _params) {
1380
1383
  return {
1381
- x: 4 * Math.cos(t) - Math.cos(4 * t),
1382
- y: 4 * Math.sin(t) - Math.sin(4 * t),
1384
+ x: 4 * Math.cos(phase) - Math.cos(4 * phase),
1385
+ y: 4 * Math.sin(phase) - Math.sin(4 * phase),
1383
1386
  };
1384
1387
  }
1385
1388
  var epicycloid3 = {
@@ -1391,18 +1394,18 @@ var epicycloid3 = {
1391
1394
 
1392
1395
  // src/curves/epitrochoid7.ts
1393
1396
  var TWO_PI5 = Math.PI * 2;
1394
- function epitrochoid7Fn(t, _time, _params) {
1395
- const d = 1 + 0.55 * Math.sin(t * 0.5);
1397
+ function epitrochoid7Fn(phase, _elapsed, _params) {
1398
+ const d = 1 + 0.55 * Math.sin(phase * 0.5);
1396
1399
  return {
1397
- x: 7 * Math.cos(t) - d * Math.cos(7 * t),
1398
- y: 7 * Math.sin(t) - d * Math.sin(7 * t),
1400
+ x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
1401
+ y: 7 * Math.sin(phase) - d * Math.sin(7 * phase),
1399
1402
  };
1400
1403
  }
1401
- function epitrochoid7SkeletonFn(t) {
1404
+ function epitrochoid7SkeletonFn(phase) {
1402
1405
  const d = 1.275;
1403
1406
  return {
1404
- x: 7 * Math.cos(t) - d * Math.cos(7 * t),
1405
- y: 7 * Math.sin(t) - d * Math.sin(7 * t),
1407
+ x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
1408
+ y: 7 * Math.sin(phase) - d * Math.sin(7 * phase),
1406
1409
  };
1407
1410
  }
1408
1411
  var epitrochoid7 = {
@@ -1415,11 +1418,11 @@ var epitrochoid7 = {
1415
1418
 
1416
1419
  // src/curves/lissajous32.ts
1417
1420
  var TWO_PI6 = Math.PI * 2;
1418
- function lissajous32Fn(t, time, _params) {
1419
- const phi = time * 0.45;
1421
+ function lissajous32Fn(phase, elapsed, _params) {
1422
+ const phi = elapsed * 0.45;
1420
1423
  return {
1421
- x: Math.sin(3 * t + phi),
1422
- y: Math.sin(2 * t),
1424
+ x: Math.sin(3 * phase + phi),
1425
+ y: Math.sin(2 * phase),
1423
1426
  };
1424
1427
  }
1425
1428
  var lissajous32 = {
@@ -1432,11 +1435,11 @@ var lissajous32 = {
1432
1435
 
1433
1436
  // src/curves/lissajous43.ts
1434
1437
  var TWO_PI7 = Math.PI * 2;
1435
- function lissajous43Fn(t, time, _params) {
1436
- const phi = time * 0.38;
1438
+ function lissajous43Fn(phase, elapsed, _params) {
1439
+ const phi = elapsed * 0.38;
1437
1440
  return {
1438
- x: Math.sin(4 * t + phi),
1439
- y: Math.sin(3 * t),
1441
+ x: Math.sin(4 * phase + phi),
1442
+ y: Math.sin(3 * phase),
1440
1443
  };
1441
1444
  }
1442
1445
  var lissajous43 = {
@@ -1449,10 +1452,10 @@ var lissajous43 = {
1449
1452
 
1450
1453
  // src/curves/lame.ts
1451
1454
  var TWO_PI8 = Math.PI * 2;
1452
- function lameFn(t, time, _params) {
1453
- const p = 1.75 + 1.25 * Math.sin(time * 0.48);
1454
- const c = Math.cos(t),
1455
- s = Math.sin(t);
1455
+ function lameFn(phase, elapsed, _params) {
1456
+ const p = 1.75 + 1.25 * Math.sin(elapsed * 0.48);
1457
+ const c = Math.cos(phase),
1458
+ s = Math.sin(phase);
1456
1459
  return {
1457
1460
  x: Math.sign(c) * Math.pow(Math.abs(c), p),
1458
1461
  y: Math.sign(s) * Math.pow(Math.abs(s), p),
@@ -1468,11 +1471,11 @@ var lame = {
1468
1471
 
1469
1472
  // src/curves/rose3.ts
1470
1473
  var TWO_PI9 = Math.PI * 2;
1471
- function rose3Fn(t, _time, _params) {
1472
- const r = Math.cos(3 * t);
1474
+ function rose3Fn(phase, _elapsed, _params) {
1475
+ const r = Math.cos(3 * phase);
1473
1476
  return {
1474
- x: r * Math.cos(t),
1475
- y: r * Math.sin(t),
1477
+ x: r * Math.cos(phase),
1478
+ y: r * Math.sin(phase),
1476
1479
  };
1477
1480
  }
1478
1481
  var rose3 = {
@@ -1484,11 +1487,11 @@ var rose3 = {
1484
1487
 
1485
1488
  // src/curves/rose5.ts
1486
1489
  var TWO_PI10 = Math.PI * 2;
1487
- function rose5Fn(t, _time, _params) {
1488
- const r = Math.cos(5 * t);
1490
+ function rose5Fn(phase, _elapsed, _params) {
1491
+ const r = Math.cos(5 * phase);
1489
1492
  return {
1490
- x: r * Math.cos(t),
1491
- y: r * Math.sin(t),
1493
+ x: r * Math.cos(phase),
1494
+ y: r * Math.sin(phase),
1492
1495
  };
1493
1496
  }
1494
1497
  var rose5 = {
@@ -1500,11 +1503,11 @@ var rose5 = {
1500
1503
 
1501
1504
  // src/curves/rose52.ts
1502
1505
  var FOUR_PI = Math.PI * 4;
1503
- function rose52Fn(t, _time, _params) {
1504
- const r = Math.cos((5 / 2) * t);
1506
+ function rose52Fn(phase, _elapsed, _params) {
1507
+ const r = Math.cos((5 / 2) * phase);
1505
1508
  return {
1506
- x: r * Math.cos(t),
1507
- y: r * Math.sin(t),
1509
+ x: r * Math.cos(phase),
1510
+ y: r * Math.sin(phase),
1508
1511
  };
1509
1512
  }
1510
1513
  var rose52 = {
@@ -1516,14 +1519,14 @@ var rose52 = {
1516
1519
 
1517
1520
  // src/curves/star.ts
1518
1521
  var TWO_PI11 = Math.PI * 2;
1519
- function starFn(t, _time, _params) {
1522
+ function starFn(phase, _elapsed, _params) {
1520
1523
  const r =
1521
- Math.abs(Math.cos((5 / 2) * t)) +
1522
- 0.35 * Math.abs(Math.cos((15 / 2) * t)) +
1523
- 0.15 * Math.abs(Math.cos((25 / 2) * t));
1524
+ Math.abs(Math.cos((5 / 2) * phase)) +
1525
+ 0.35 * Math.abs(Math.cos((15 / 2) * phase)) +
1526
+ 0.15 * Math.abs(Math.cos((25 / 2) * phase));
1524
1527
  return {
1525
- x: r * Math.cos(t),
1526
- y: r * Math.sin(t),
1528
+ x: r * Math.cos(phase),
1529
+ y: r * Math.sin(phase),
1527
1530
  };
1528
1531
  }
1529
1532
  var star = {
@@ -1535,14 +1538,14 @@ var star = {
1535
1538
 
1536
1539
  // src/curves/star4.ts
1537
1540
  var TWO_PI12 = Math.PI * 2;
1538
- function star4Fn(t, _time, _params) {
1541
+ function star4Fn(phase, _elapsed, _params) {
1539
1542
  const r =
1540
- Math.abs(Math.cos(2 * t)) +
1541
- 0.35 * Math.abs(Math.cos(6 * t)) +
1542
- 0.15 * Math.abs(Math.cos(10 * t));
1543
+ Math.abs(Math.cos(2 * phase)) +
1544
+ 0.35 * Math.abs(Math.cos(6 * phase)) +
1545
+ 0.15 * Math.abs(Math.cos(10 * phase));
1543
1546
  return {
1544
- x: r * Math.cos(t),
1545
- y: r * Math.sin(t),
1547
+ x: r * Math.cos(phase),
1548
+ y: r * Math.sin(phase),
1546
1549
  };
1547
1550
  }
1548
1551
  var star4 = {
@@ -1554,14 +1557,14 @@ var star4 = {
1554
1557
 
1555
1558
  // src/curves/star7.ts
1556
1559
  var TWO_PI13 = Math.PI * 2;
1557
- function star7Fn(t, _time, _params) {
1560
+ function star7Fn(phase, _elapsed, _params) {
1558
1561
  const r =
1559
- Math.abs(Math.cos((7 / 2) * t)) +
1560
- 0.35 * Math.abs(Math.cos((21 / 2) * t)) +
1561
- 0.15 * Math.abs(Math.cos((35 / 2) * t));
1562
+ Math.abs(Math.cos((7 / 2) * phase)) +
1563
+ 0.35 * Math.abs(Math.cos((21 / 2) * phase)) +
1564
+ 0.15 * Math.abs(Math.cos((35 / 2) * phase));
1562
1565
  return {
1563
- x: r * Math.cos(t),
1564
- y: r * Math.sin(t),
1566
+ x: r * Math.cos(phase),
1567
+ y: r * Math.sin(phase),
1565
1568
  };
1566
1569
  }
1567
1570
  var star7 = {