@sarmal/core 0.13.0 → 0.14.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 +84 -89
  2. package/dist/auto-init.cjs.map +1 -1
  3. package/dist/auto-init.d.cts +2 -1
  4. package/dist/auto-init.d.ts +2 -1
  5. package/dist/auto-init.js +83 -88
  6. package/dist/auto-init.js.map +1 -1
  7. package/dist/curves/artemis2.cjs +7 -10
  8. package/dist/curves/artemis2.d.cts +1 -1
  9. package/dist/curves/artemis2.d.ts +1 -1
  10. package/dist/curves/artemis2.js +6 -9
  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 +28 -32
  28. package/dist/curves/index.d.cts +21 -21
  29. package/dist/curves/index.d.ts +21 -21
  30. package/dist/curves/index.js +28 -44
  31. package/dist/curves/lame.cjs +5 -6
  32. package/dist/curves/lame.d.cts +1 -1
  33. package/dist/curves/lame.d.ts +1 -1
  34. package/dist/curves/lame.js +4 -5
  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 +98 -90
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.cts +23 -58
  54. package/dist/index.d.ts +23 -58
  55. package/dist/index.js +98 -107
  56. package/dist/index.js.map +1 -1
  57. package/dist/types-BQosOzlf.d.cts +276 -0
  58. package/dist/types-BQosOzlf.d.ts +276 -0
  59. package/package.json +1 -1
  60. package/dist/types-BW0bpL1Z.d.cts +0 -290
  61. package/dist/types-BW0bpL1Z.d.ts +0 -290
@@ -0,0 +1,276 @@
1
+ interface Point {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ interface CurveDef {
6
+ name: string;
7
+ /**
8
+ * The parametric function that defines the curve shape.
9
+ * @param t Current position along the curve, in [0, period)
10
+ * @param time Elapsed actual time in seconds. It is always increasing, and never resets on period wrap
11
+ * @param params Named parameter overrides. intentional forward-compatible parameter
12
+ */
13
+ fn: (t: number, time: number, params: Record<string, number>) => Point;
14
+ /**
15
+ * @default (Math.PI * 2)
16
+ */
17
+ period?: number;
18
+ /**
19
+ * @default 1
20
+ */
21
+ speed?: number;
22
+ /**
23
+ * To indicate a compatible library version when providing the curve definitions
24
+ * Intended for potential backwards compatibility scenarios and futureproofing
25
+ */
26
+ version?: number;
27
+ /**
28
+ * Skeleton rendering mode:
29
+ * - 'static': Skeleton is computed once at init from `fn(t, 0)` and cached
30
+ * - 'live': Skeleton is recomputed each frame using `fn(t, actualTime)` specifically for curves whose shape drifts *over time*
31
+ * @default "static"
32
+ */
33
+ skeleton?: "static" | "live";
34
+ /**
35
+ * An **override** function for computing a skeleton independent of `fn`
36
+ * If provided, this function is used instead of `fn` to sample the skeleton,
37
+ * and the result is cached just like like 'static' mode
38
+ * @param t The parametric time value from `0` to `period`
39
+ * @returns The point on the skeleton at time `t`
40
+ */
41
+ skeletonFn?: (t: number) => Point;
42
+ }
43
+ type JumpOptions = {
44
+ /**
45
+ * When true, clears the trail on jump. When false (default), the trail is left as-is.
46
+ * @default false
47
+ */
48
+ clearTrail?: boolean;
49
+ };
50
+ type SeekOptions = {
51
+ /**
52
+ * When true, the trail wraps around the period boundary,
53
+ * which results in a full trail even near `t=0`
54
+ * By default, the trail stops at `t=0`, which results in a partial trail near the start
55
+ * @default false
56
+ */
57
+ wrap?: boolean;
58
+ /**
59
+ * Time gap between each trail point (in same units as `t`)
60
+ * Smaller value means a trail that is more dense
61
+ * @default period / trailLength
62
+ */
63
+ step?: number;
64
+ };
65
+ type MorpStrategy = "raw" | "normalized";
66
+ /**
67
+ * The shared animation state types
68
+ * Both `Engine` and `SarmalInstance` extend this
69
+ * In the renderer, these are passthroughs
70
+ */
71
+ interface AnimationControls {
72
+ /**
73
+ * Resets the simulation state, clearing the trail and reverting internal time `t` to 0
74
+ * The next call to `tick` will start fresh from the beginning of the curve
75
+ */
76
+ reset(): void;
77
+ /**
78
+ * Instantly moves the head to position `t`.
79
+ *
80
+ * ! Does NOT update `actualTime`.
81
+ *
82
+ * Trail is left untouched by default. You can pass `clearTrail: true` to wipe it.
83
+ * Use for morphing mid-flight or any time you don't need trail context.
84
+ * @param t The position to jump to (will be wrapped into [0, period))
85
+ */
86
+ jump(t: number, options?: JumpOptions): void;
87
+ /**
88
+ * Moves to `t` AND reconstructs the trail as if the animation naturally arrived there from `t=0`
89
+ * Also updates `actualTime` to match. Trail is always rebuilt from scratch
90
+ * Use for initialisation or any jump where you want the trail to look meaningful
91
+ * @param t The position to seek to (will be wrapped into [0, period))
92
+ */
93
+ seek(t: number, options?: SeekOptions): void;
94
+ /**
95
+ * Overrides the animation speed at runtime
96
+ * `0` freezes `t` but the loop keeps running
97
+ * Negative values reverse traversal.
98
+ *
99
+ * ! Does NOT affect a curve's inherent speed given in CurveDef
100
+ * @param speed 0 = freeze, negative = reverse, no upper bound
101
+ */
102
+ setSpeed(speed: number): void;
103
+ /**
104
+ * Returns the *effective speed* the engine is currently using:
105
+ * `userSpeedOverride` if set, otherwise the curve's default speed.
106
+ * This is what `tick()` actually uses
107
+ */
108
+ getSpeed(): number;
109
+ /**
110
+ * Drops the speed override and defers back to the curve's inherent default speed.
111
+ * ! Sets `userSpeedOverride` to `null`
112
+ */
113
+ resetSpeed(): void;
114
+ /**
115
+ * Transitions to the target speed over `duration` milliseconds using linear interpolation.
116
+ * Resolves when the transition completes.
117
+ *
118
+ * Calling this while a transition is already in progress cancels the old transition
119
+ * (rejecting its Promise) and starts a new one from the current interpolated speed.
120
+ *
121
+ * @param speed Target speed
122
+ * @param duration Transition duration in milliseconds (must be > 0)
123
+ */
124
+ setSpeedOver(speed: number, duration: number): Promise<void>;
125
+ }
126
+ type MorphOptions = {
127
+ /**
128
+ * Duration of the morph transition in milliseconds
129
+ * @default 300
130
+ */
131
+ duration?: number;
132
+ /**
133
+ * Strategy for lerping between curves with different periods:
134
+ * - 'normalized': maps `t` proportionally into each curve's period (smooth for all period ratios)
135
+ * - 'raw': uses the same `t` for both curves (can produce incoherent results for mismatched periods)
136
+ * @default 'normalized'
137
+ */
138
+ morphStrategy?: MorpStrategy;
139
+ };
140
+ interface Engine extends AnimationControls {
141
+ /**
142
+ * Advances the Sarmal simulation by the given delta time (dt) in seconds.
143
+ * Internally, this increases the simulation time `t` by `speed * dt`,
144
+ * wraps `t` at `period`, evaluates the curve's parametric function `fn(t)`,
145
+ * and appends the new point to the trail.
146
+ * Returns the pre-allocated trail buffer, which has the *same* reference every call
147
+ * ! Do not use `Array.length` to determine size
148
+ * @param deltaTime Delta time in seconds (typically frame time from **requestAnimationFrame** or similar)
149
+ */
150
+ tick(deltaTime: number): Array<Point>;
151
+ /**
152
+ * Number of valid points in the trail buffer returned by the last `tick()` call
153
+ * ! Use this instead of `trail.length`
154
+ */
155
+ readonly trailCount: number;
156
+ /**
157
+ * Returns the *skeleton* of the curve.
158
+ * In technicality, it just represents the complete traversal of the curve over one full period,
159
+ * which is sampled at points from `t=0` to `t=period`
160
+ *
161
+ * For "static" skeletons, this returns the same array on every call
162
+ * For "live" skeletons, this returns a different array each frame
163
+ * For `skeletonFn` overrides, this returns the skeleton from that function, which is *always* static
164
+ *
165
+ * The number of sample points is automatically derived from the curve's period.
166
+ */
167
+ getSarmalSkeleton(): Array<Point>;
168
+ readonly isLiveSkeleton: boolean;
169
+ /**
170
+ * Begins a smooth transition from the current curve to `target`
171
+ * Saves the current curve as `curveA`, registers `target` as `curveB`, and resets `morphAlpha` to `0`
172
+ *
173
+ * If called while a morph is already in progress,
174
+ * the interpolated state is frozen and becomes the new `curveA`
175
+ * @param target The curve to transition to
176
+ * @param strategy 'normalized' maps t proportionally into each curve's period (default), 'raw' uses the same t
177
+ */
178
+ startMorph(target: CurveDef, strategy?: MorpStrategy): void;
179
+ /**
180
+ * Sets the interpolation amount between `curveA` and `curveB`.
181
+ * 0 = full curveA
182
+ * 1 = full curveB
183
+ * Called by the renderer each frame as `actualTime` advances
184
+ * @param alpha A value in [0, 1]
185
+ */
186
+ setMorphAlpha(alpha: number): void;
187
+ /**
188
+ * Finalises the morph: `curveB` becomes the new active curve and `morphAlpha` is reset to `null`
189
+ * ! Called by the renderer when alpha reaches `1`
190
+ */
191
+ completeMorph(): void;
192
+ /**
193
+ * Current interpolation progress between `curveA` and `curveB`
194
+ * `null` when no morph is in progress
195
+ */
196
+ readonly morphAlpha: number | null;
197
+ /**
198
+ * Cancels any in-progress speed transition initiated by `setSpeedOver()`.
199
+ * Called internally by the renderer's `stop()` method.
200
+ */
201
+ cancelSpeedTransition(): void;
202
+ }
203
+ interface SarmalInstance extends AnimationControls {
204
+ /** Starts the animation loop (requestAnimationFrame). If already running, does nothing. */
205
+ play(): void;
206
+ /** Pauses the animation loop (cancelAnimationFrame) and cancels any speed transition. Preserves state. */
207
+ pause(): void;
208
+ /** Stops the animation and cleans up resources */
209
+ destroy(): void;
210
+ /**
211
+ * Smoothly transitions from the current curve to `target`.
212
+ * The trail naturally reflects the new curve as new points are added.
213
+ * @param target The curve to transition to
214
+ * @param options.duration How long the morph takes in milliseconds (default: 300)
215
+ * @param options.morphStrategy 'normalized' uses proportional t mapping (default), 'raw' uses same t
216
+ * @returns Promise that resolves when the morph is complete
217
+ */
218
+ morphTo(target: CurveDef, options?: MorphOptions): Promise<void>;
219
+ }
220
+ /**
221
+ * With 'gradient-animated' the colors cycle along the trail over time
222
+ */
223
+ type TrailStyle = "default" | "gradient-static" | "gradient-animated";
224
+ type PalettePreset = "bard" | "sunset" | "ocean" | "ice" | "fire" | "forest";
225
+ /**
226
+ * Common renderer options shared between canvas and SVG renderers.
227
+ * Extracted to avoid duplication and ensure consistency.
228
+ */
229
+ interface BaseRendererOptions {
230
+ /**
231
+ * Whether to start the animation loop automatically on creation.
232
+ * @default true
233
+ */
234
+ autoStart?: boolean;
235
+ /**
236
+ * Initial position along the curve (t value). If provided, seek(initialT) is called before the first frame.
237
+ * @default undefined (no seek performed, starts at t=0)
238
+ */
239
+ initialT?: number;
240
+ /**
241
+ * @default '#ffffff'
242
+ */
243
+ skeletonColor?: string;
244
+ /**
245
+ * @default '#ffffff'
246
+ */
247
+ trailColor?: string;
248
+ /**
249
+ * @default '#ffffff'
250
+ */
251
+ headColor?: string;
252
+ /** @default 4 */
253
+ headRadius?: number;
254
+ /**
255
+ * Trail rendering style
256
+ * @default 'default'
257
+ */
258
+ trailStyle?: TrailStyle;
259
+ /**
260
+ * Color palette for gradient trails.
261
+ * Can be a preset name or a custom array of hex color strings.
262
+ * @default 'bard' for 'gradient-animated', 'ice' for 'gradient-static'
263
+ */
264
+ palette?: PalettePreset | string[];
265
+ }
266
+ interface RendererOptions extends BaseRendererOptions {
267
+ /** Target canvas element that will contain the Sarmal */
268
+ canvas: HTMLCanvasElement;
269
+ engine: Engine;
270
+ }
271
+ interface SarmalOptions extends Omit<RendererOptions, "canvas" | "engine"> {
272
+ /** @default 120 */
273
+ trailLength?: number;
274
+ }
275
+
276
+ export type { BaseRendererOptions as B, CurveDef as C, Engine as E, JumpOptions as J, PalettePreset as P, RendererOptions as R, SarmalInstance as S, TrailStyle as T, SarmalOptions as a, Point as b, SeekOptions as c };
@@ -0,0 +1,276 @@
1
+ interface Point {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ interface CurveDef {
6
+ name: string;
7
+ /**
8
+ * The parametric function that defines the curve shape.
9
+ * @param t Current position along the curve, in [0, period)
10
+ * @param time Elapsed actual time in seconds. It is always increasing, and never resets on period wrap
11
+ * @param params Named parameter overrides. intentional forward-compatible parameter
12
+ */
13
+ fn: (t: number, time: number, params: Record<string, number>) => Point;
14
+ /**
15
+ * @default (Math.PI * 2)
16
+ */
17
+ period?: number;
18
+ /**
19
+ * @default 1
20
+ */
21
+ speed?: number;
22
+ /**
23
+ * To indicate a compatible library version when providing the curve definitions
24
+ * Intended for potential backwards compatibility scenarios and futureproofing
25
+ */
26
+ version?: number;
27
+ /**
28
+ * Skeleton rendering mode:
29
+ * - 'static': Skeleton is computed once at init from `fn(t, 0)` and cached
30
+ * - 'live': Skeleton is recomputed each frame using `fn(t, actualTime)` specifically for curves whose shape drifts *over time*
31
+ * @default "static"
32
+ */
33
+ skeleton?: "static" | "live";
34
+ /**
35
+ * An **override** function for computing a skeleton independent of `fn`
36
+ * If provided, this function is used instead of `fn` to sample the skeleton,
37
+ * and the result is cached just like like 'static' mode
38
+ * @param t The parametric time value from `0` to `period`
39
+ * @returns The point on the skeleton at time `t`
40
+ */
41
+ skeletonFn?: (t: number) => Point;
42
+ }
43
+ type JumpOptions = {
44
+ /**
45
+ * When true, clears the trail on jump. When false (default), the trail is left as-is.
46
+ * @default false
47
+ */
48
+ clearTrail?: boolean;
49
+ };
50
+ type SeekOptions = {
51
+ /**
52
+ * When true, the trail wraps around the period boundary,
53
+ * which results in a full trail even near `t=0`
54
+ * By default, the trail stops at `t=0`, which results in a partial trail near the start
55
+ * @default false
56
+ */
57
+ wrap?: boolean;
58
+ /**
59
+ * Time gap between each trail point (in same units as `t`)
60
+ * Smaller value means a trail that is more dense
61
+ * @default period / trailLength
62
+ */
63
+ step?: number;
64
+ };
65
+ type MorpStrategy = "raw" | "normalized";
66
+ /**
67
+ * The shared animation state types
68
+ * Both `Engine` and `SarmalInstance` extend this
69
+ * In the renderer, these are passthroughs
70
+ */
71
+ interface AnimationControls {
72
+ /**
73
+ * Resets the simulation state, clearing the trail and reverting internal time `t` to 0
74
+ * The next call to `tick` will start fresh from the beginning of the curve
75
+ */
76
+ reset(): void;
77
+ /**
78
+ * Instantly moves the head to position `t`.
79
+ *
80
+ * ! Does NOT update `actualTime`.
81
+ *
82
+ * Trail is left untouched by default. You can pass `clearTrail: true` to wipe it.
83
+ * Use for morphing mid-flight or any time you don't need trail context.
84
+ * @param t The position to jump to (will be wrapped into [0, period))
85
+ */
86
+ jump(t: number, options?: JumpOptions): void;
87
+ /**
88
+ * Moves to `t` AND reconstructs the trail as if the animation naturally arrived there from `t=0`
89
+ * Also updates `actualTime` to match. Trail is always rebuilt from scratch
90
+ * Use for initialisation or any jump where you want the trail to look meaningful
91
+ * @param t The position to seek to (will be wrapped into [0, period))
92
+ */
93
+ seek(t: number, options?: SeekOptions): void;
94
+ /**
95
+ * Overrides the animation speed at runtime
96
+ * `0` freezes `t` but the loop keeps running
97
+ * Negative values reverse traversal.
98
+ *
99
+ * ! Does NOT affect a curve's inherent speed given in CurveDef
100
+ * @param speed 0 = freeze, negative = reverse, no upper bound
101
+ */
102
+ setSpeed(speed: number): void;
103
+ /**
104
+ * Returns the *effective speed* the engine is currently using:
105
+ * `userSpeedOverride` if set, otherwise the curve's default speed.
106
+ * This is what `tick()` actually uses
107
+ */
108
+ getSpeed(): number;
109
+ /**
110
+ * Drops the speed override and defers back to the curve's inherent default speed.
111
+ * ! Sets `userSpeedOverride` to `null`
112
+ */
113
+ resetSpeed(): void;
114
+ /**
115
+ * Transitions to the target speed over `duration` milliseconds using linear interpolation.
116
+ * Resolves when the transition completes.
117
+ *
118
+ * Calling this while a transition is already in progress cancels the old transition
119
+ * (rejecting its Promise) and starts a new one from the current interpolated speed.
120
+ *
121
+ * @param speed Target speed
122
+ * @param duration Transition duration in milliseconds (must be > 0)
123
+ */
124
+ setSpeedOver(speed: number, duration: number): Promise<void>;
125
+ }
126
+ type MorphOptions = {
127
+ /**
128
+ * Duration of the morph transition in milliseconds
129
+ * @default 300
130
+ */
131
+ duration?: number;
132
+ /**
133
+ * Strategy for lerping between curves with different periods:
134
+ * - 'normalized': maps `t` proportionally into each curve's period (smooth for all period ratios)
135
+ * - 'raw': uses the same `t` for both curves (can produce incoherent results for mismatched periods)
136
+ * @default 'normalized'
137
+ */
138
+ morphStrategy?: MorpStrategy;
139
+ };
140
+ interface Engine extends AnimationControls {
141
+ /**
142
+ * Advances the Sarmal simulation by the given delta time (dt) in seconds.
143
+ * Internally, this increases the simulation time `t` by `speed * dt`,
144
+ * wraps `t` at `period`, evaluates the curve's parametric function `fn(t)`,
145
+ * and appends the new point to the trail.
146
+ * Returns the pre-allocated trail buffer, which has the *same* reference every call
147
+ * ! Do not use `Array.length` to determine size
148
+ * @param deltaTime Delta time in seconds (typically frame time from **requestAnimationFrame** or similar)
149
+ */
150
+ tick(deltaTime: number): Array<Point>;
151
+ /**
152
+ * Number of valid points in the trail buffer returned by the last `tick()` call
153
+ * ! Use this instead of `trail.length`
154
+ */
155
+ readonly trailCount: number;
156
+ /**
157
+ * Returns the *skeleton* of the curve.
158
+ * In technicality, it just represents the complete traversal of the curve over one full period,
159
+ * which is sampled at points from `t=0` to `t=period`
160
+ *
161
+ * For "static" skeletons, this returns the same array on every call
162
+ * For "live" skeletons, this returns a different array each frame
163
+ * For `skeletonFn` overrides, this returns the skeleton from that function, which is *always* static
164
+ *
165
+ * The number of sample points is automatically derived from the curve's period.
166
+ */
167
+ getSarmalSkeleton(): Array<Point>;
168
+ readonly isLiveSkeleton: boolean;
169
+ /**
170
+ * Begins a smooth transition from the current curve to `target`
171
+ * Saves the current curve as `curveA`, registers `target` as `curveB`, and resets `morphAlpha` to `0`
172
+ *
173
+ * If called while a morph is already in progress,
174
+ * the interpolated state is frozen and becomes the new `curveA`
175
+ * @param target The curve to transition to
176
+ * @param strategy 'normalized' maps t proportionally into each curve's period (default), 'raw' uses the same t
177
+ */
178
+ startMorph(target: CurveDef, strategy?: MorpStrategy): void;
179
+ /**
180
+ * Sets the interpolation amount between `curveA` and `curveB`.
181
+ * 0 = full curveA
182
+ * 1 = full curveB
183
+ * Called by the renderer each frame as `actualTime` advances
184
+ * @param alpha A value in [0, 1]
185
+ */
186
+ setMorphAlpha(alpha: number): void;
187
+ /**
188
+ * Finalises the morph: `curveB` becomes the new active curve and `morphAlpha` is reset to `null`
189
+ * ! Called by the renderer when alpha reaches `1`
190
+ */
191
+ completeMorph(): void;
192
+ /**
193
+ * Current interpolation progress between `curveA` and `curveB`
194
+ * `null` when no morph is in progress
195
+ */
196
+ readonly morphAlpha: number | null;
197
+ /**
198
+ * Cancels any in-progress speed transition initiated by `setSpeedOver()`.
199
+ * Called internally by the renderer's `stop()` method.
200
+ */
201
+ cancelSpeedTransition(): void;
202
+ }
203
+ interface SarmalInstance extends AnimationControls {
204
+ /** Starts the animation loop (requestAnimationFrame). If already running, does nothing. */
205
+ play(): void;
206
+ /** Pauses the animation loop (cancelAnimationFrame) and cancels any speed transition. Preserves state. */
207
+ pause(): void;
208
+ /** Stops the animation and cleans up resources */
209
+ destroy(): void;
210
+ /**
211
+ * Smoothly transitions from the current curve to `target`.
212
+ * The trail naturally reflects the new curve as new points are added.
213
+ * @param target The curve to transition to
214
+ * @param options.duration How long the morph takes in milliseconds (default: 300)
215
+ * @param options.morphStrategy 'normalized' uses proportional t mapping (default), 'raw' uses same t
216
+ * @returns Promise that resolves when the morph is complete
217
+ */
218
+ morphTo(target: CurveDef, options?: MorphOptions): Promise<void>;
219
+ }
220
+ /**
221
+ * With 'gradient-animated' the colors cycle along the trail over time
222
+ */
223
+ type TrailStyle = "default" | "gradient-static" | "gradient-animated";
224
+ type PalettePreset = "bard" | "sunset" | "ocean" | "ice" | "fire" | "forest";
225
+ /**
226
+ * Common renderer options shared between canvas and SVG renderers.
227
+ * Extracted to avoid duplication and ensure consistency.
228
+ */
229
+ interface BaseRendererOptions {
230
+ /**
231
+ * Whether to start the animation loop automatically on creation.
232
+ * @default true
233
+ */
234
+ autoStart?: boolean;
235
+ /**
236
+ * Initial position along the curve (t value). If provided, seek(initialT) is called before the first frame.
237
+ * @default undefined (no seek performed, starts at t=0)
238
+ */
239
+ initialT?: number;
240
+ /**
241
+ * @default '#ffffff'
242
+ */
243
+ skeletonColor?: string;
244
+ /**
245
+ * @default '#ffffff'
246
+ */
247
+ trailColor?: string;
248
+ /**
249
+ * @default '#ffffff'
250
+ */
251
+ headColor?: string;
252
+ /** @default 4 */
253
+ headRadius?: number;
254
+ /**
255
+ * Trail rendering style
256
+ * @default 'default'
257
+ */
258
+ trailStyle?: TrailStyle;
259
+ /**
260
+ * Color palette for gradient trails.
261
+ * Can be a preset name or a custom array of hex color strings.
262
+ * @default 'bard' for 'gradient-animated', 'ice' for 'gradient-static'
263
+ */
264
+ palette?: PalettePreset | string[];
265
+ }
266
+ interface RendererOptions extends BaseRendererOptions {
267
+ /** Target canvas element that will contain the Sarmal */
268
+ canvas: HTMLCanvasElement;
269
+ engine: Engine;
270
+ }
271
+ interface SarmalOptions extends Omit<RendererOptions, "canvas" | "engine"> {
272
+ /** @default 120 */
273
+ trailLength?: number;
274
+ }
275
+
276
+ export type { BaseRendererOptions as B, CurveDef as C, Engine as E, JumpOptions as J, PalettePreset as P, RendererOptions as R, SarmalInstance as S, TrailStyle as T, SarmalOptions as a, Point as b, SeekOptions as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarmal/core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Curve path based loading indicators and their renderer",
5
5
  "keywords": [
6
6
  "animation",