@sarmal/core 0.24.0 → 0.25.1
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.
- package/dist/auto-init.cjs +245 -141
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.js +244 -140
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.cjs +87 -14
- package/dist/curves/artemis2.cjs.map +1 -1
- package/dist/curves/artemis2.d.cts +1 -5
- package/dist/curves/artemis2.d.ts +1 -5
- package/dist/curves/artemis2.js +86 -13
- package/dist/curves/artemis2.js.map +1 -1
- package/dist/curves/astroid.cjs +4 -4
- package/dist/curves/astroid.d.cts +1 -1
- package/dist/curves/astroid.d.ts +1 -1
- package/dist/curves/astroid.js +3 -3
- package/dist/curves/deltoid.cjs +4 -4
- package/dist/curves/deltoid.d.cts +1 -1
- package/dist/curves/deltoid.d.ts +1 -1
- package/dist/curves/deltoid.js +3 -3
- package/dist/curves/epicycloid3.cjs +4 -4
- package/dist/curves/epicycloid3.d.cts +1 -1
- package/dist/curves/epicycloid3.d.ts +1 -1
- package/dist/curves/epicycloid3.js +3 -3
- package/dist/curves/epitrochoid7.cjs +5 -5
- package/dist/curves/epitrochoid7.d.cts +1 -1
- package/dist/curves/epitrochoid7.d.ts +1 -1
- package/dist/curves/epitrochoid7.js +4 -4
- package/dist/curves/index.cjs +154 -71
- package/dist/curves/index.cjs.map +1 -1
- package/dist/curves/index.d.cts +29 -29
- package/dist/curves/index.d.ts +29 -29
- package/dist/curves/index.js +170 -71
- package/dist/curves/index.js.map +1 -1
- package/dist/curves/lame.cjs +6 -5
- package/dist/curves/lame.d.cts +1 -1
- package/dist/curves/lame.d.ts +1 -1
- package/dist/curves/lame.js +5 -4
- package/dist/curves/lissajous32.cjs +4 -4
- package/dist/curves/lissajous32.d.cts +1 -1
- package/dist/curves/lissajous32.d.ts +1 -1
- package/dist/curves/lissajous32.js +3 -3
- package/dist/curves/lissajous43.cjs +4 -4
- package/dist/curves/lissajous43.d.cts +1 -1
- package/dist/curves/lissajous43.d.ts +1 -1
- package/dist/curves/lissajous43.js +3 -3
- package/dist/curves/rose3.cjs +4 -4
- package/dist/curves/rose3.d.cts +1 -1
- package/dist/curves/rose3.d.ts +1 -1
- package/dist/curves/rose3.js +3 -3
- package/dist/curves/rose5.cjs +4 -4
- package/dist/curves/rose5.d.cts +1 -1
- package/dist/curves/rose5.d.ts +1 -1
- package/dist/curves/rose5.js +3 -3
- package/dist/curves/rose52.cjs +5 -5
- package/dist/curves/rose52.d.cts +1 -1
- package/dist/curves/rose52.d.ts +1 -1
- package/dist/curves/rose52.js +4 -4
- package/dist/curves/star.cjs +8 -5
- package/dist/curves/star.d.cts +1 -1
- package/dist/curves/star.d.ts +1 -1
- package/dist/curves/star.js +7 -4
- package/dist/curves/star4.cjs +8 -5
- package/dist/curves/star4.d.cts +1 -1
- package/dist/curves/star4.d.ts +1 -1
- package/dist/curves/star4.js +7 -4
- package/dist/curves/star7.cjs +8 -5
- package/dist/curves/star7.d.cts +1 -1
- package/dist/curves/star7.d.ts +1 -1
- package/dist/curves/star7.js +7 -4
- package/dist/index.cjs +232 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -36
- package/dist/index.d.ts +106 -36
- package/dist/index.js +252 -172
- package/dist/index.js.map +1 -1
- package/dist/types-Z9i1_AQZ.d.cts +339 -0
- package/dist/types-Z9i1_AQZ.d.ts +339 -0
- package/package.json +1 -1
- package/dist/types-CknrlCAf.d.cts +0 -314
- package/dist/types-CknrlCAf.d.ts +0 -314
package/dist/index.d.cts
CHANGED
|
@@ -1,31 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import {
|
|
2
|
+
B as BaseRendererOptions,
|
|
3
|
+
E as Engine,
|
|
4
|
+
S as SarmalInstance,
|
|
5
|
+
C as CurveDef,
|
|
6
|
+
P as Point,
|
|
7
|
+
R as RendererOptions,
|
|
8
|
+
a as ControlPoint,
|
|
9
|
+
b as SarmalOptions,
|
|
10
|
+
} from "./types-Z9i1_AQZ.cjs";
|
|
11
|
+
export {
|
|
12
|
+
J as JumpOptions,
|
|
13
|
+
c as RuntimeRenderOptions,
|
|
14
|
+
d as SeekOptions,
|
|
15
|
+
T as TrailColor,
|
|
16
|
+
e as TrailStyle,
|
|
17
|
+
} from "./types-Z9i1_AQZ.cjs";
|
|
18
|
+
export { CurveName, curves } from "./curves/index.cjs";
|
|
19
|
+
export { artemis2 } from "./curves/artemis2.cjs";
|
|
20
|
+
export { astroid } from "./curves/astroid.cjs";
|
|
21
|
+
export { deltoid } from "./curves/deltoid.cjs";
|
|
22
|
+
export { epicycloid3 } from "./curves/epicycloid3.cjs";
|
|
23
|
+
export { epitrochoid7 } from "./curves/epitrochoid7.cjs";
|
|
24
|
+
export { lame } from "./curves/lame.cjs";
|
|
25
|
+
export { lissajous32 } from "./curves/lissajous32.cjs";
|
|
26
|
+
export { lissajous43 } from "./curves/lissajous43.cjs";
|
|
27
|
+
export { rose3 } from "./curves/rose3.cjs";
|
|
28
|
+
export { rose5 } from "./curves/rose5.cjs";
|
|
29
|
+
import "./curves/rose52.cjs";
|
|
30
|
+
import "./curves/star.cjs";
|
|
31
|
+
import "./curves/star4.cjs";
|
|
32
|
+
import "./curves/star7.cjs";
|
|
18
33
|
|
|
19
34
|
interface SVGRendererOptions extends BaseRendererOptions {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
/** SVG element the renderer draws into directly */
|
|
36
|
+
container: SVGSVGElement;
|
|
37
|
+
engine: Engine;
|
|
38
|
+
/** @default 'Loading' */
|
|
39
|
+
ariaLabel?: string;
|
|
25
40
|
}
|
|
26
41
|
interface SVGSarmalOptions extends Omit<SVGRendererOptions, "container" | "engine"> {
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
/** @default 120 */
|
|
43
|
+
trailLength?: number;
|
|
29
44
|
}
|
|
30
45
|
/**
|
|
31
46
|
* Creates a live SVG renderer for sarmal animations
|
|
@@ -50,19 +65,43 @@ declare function createSVGRenderer(options: SVGRendererOptions): SarmalInstance;
|
|
|
50
65
|
* controlled.pause() // Pause later
|
|
51
66
|
* ```
|
|
52
67
|
*/
|
|
53
|
-
declare function createSarmalSVG(
|
|
68
|
+
declare function createSarmalSVG(
|
|
69
|
+
container: SVGSVGElement,
|
|
70
|
+
curveDef: CurveDef,
|
|
71
|
+
options?: SVGSarmalOptions,
|
|
72
|
+
): SarmalInstance;
|
|
54
73
|
|
|
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;
|
|
55
94
|
/**
|
|
56
95
|
* Can be passed directly to `trailColor`,
|
|
57
96
|
* or can be mixed/sliced before passing as a prop.
|
|
58
97
|
*/
|
|
59
98
|
declare const palettes: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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"];
|
|
66
105
|
};
|
|
67
106
|
type SarmalPalette = keyof typeof palettes;
|
|
68
107
|
|
|
@@ -86,7 +125,7 @@ declare function createRenderer(options: RendererOptions): SarmalInstance;
|
|
|
86
125
|
* @param t Parametric position along the closed loop. Wraps into `[0, 2π)` automatically, so values outside that range are remapped rather than rejected
|
|
87
126
|
* @returns The `(x, y)` position on the spline at time `t`
|
|
88
127
|
*/
|
|
89
|
-
declare function evaluateCatmullRom(points: Array<
|
|
128
|
+
declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Point;
|
|
90
129
|
/**
|
|
91
130
|
* The returned curve definition produces a closed Catmull-Rom spline that
|
|
92
131
|
* passes through every point in order, looping back from the last point to the first.
|
|
@@ -94,8 +133,9 @@ declare function evaluateCatmullRom(points: Array<[number, number]>, t: number):
|
|
|
94
133
|
* @param points Array of control points in **normalized `[−1, 1]` space**,
|
|
95
134
|
* matching the playground's draw-mode coordinate system.
|
|
96
135
|
* ! Must contain at least 3 points.
|
|
136
|
+
* @param opts Optional overrides for the returned `CurveDef`.
|
|
137
|
+
* @param opts.name Display name for the curve. Defaults to `"drawn"`.
|
|
97
138
|
* @returns A `CurveDef` with `period: 2π` and the spline evaluator as its `fn`.
|
|
98
|
-
* `name` is set to `"custom"`.
|
|
99
139
|
* @throws If `points` has fewer than 3 entries.
|
|
100
140
|
*
|
|
101
141
|
* @example
|
|
@@ -111,7 +151,12 @@ declare function evaluateCatmullRom(points: Array<[number, number]>, t: number):
|
|
|
111
151
|
* createSarmal(canvas, curve)
|
|
112
152
|
* ```
|
|
113
153
|
*/
|
|
114
|
-
declare function drawCurve(
|
|
154
|
+
declare function drawCurve(
|
|
155
|
+
points: Array<ControlPoint>,
|
|
156
|
+
opts?: {
|
|
157
|
+
name?: string;
|
|
158
|
+
},
|
|
159
|
+
): CurveDef;
|
|
115
160
|
|
|
116
161
|
/**
|
|
117
162
|
* Creates a sarmal animation on a canvas element
|
|
@@ -127,6 +172,31 @@ declare function drawCurve(points: Array<[number, number]>): CurveDef;
|
|
|
127
172
|
* controlled.pause() // Pause later
|
|
128
173
|
* ```
|
|
129
174
|
*/
|
|
130
|
-
declare function createSarmal(
|
|
175
|
+
declare function createSarmal(
|
|
176
|
+
canvas: HTMLCanvasElement,
|
|
177
|
+
curveDef: CurveDef,
|
|
178
|
+
options?: SarmalOptions,
|
|
179
|
+
): SarmalInstance;
|
|
131
180
|
|
|
132
|
-
export {
|
|
181
|
+
export {
|
|
182
|
+
BaseRendererOptions,
|
|
183
|
+
type BoundaryResult,
|
|
184
|
+
CurveDef,
|
|
185
|
+
Engine,
|
|
186
|
+
Point,
|
|
187
|
+
RendererOptions,
|
|
188
|
+
type SVGRendererOptions,
|
|
189
|
+
type SVGSarmalOptions,
|
|
190
|
+
SarmalInstance,
|
|
191
|
+
SarmalOptions,
|
|
192
|
+
type SarmalPalette,
|
|
193
|
+
computeBoundaries,
|
|
194
|
+
createEngine,
|
|
195
|
+
createRenderer,
|
|
196
|
+
createSVGRenderer,
|
|
197
|
+
createSarmal,
|
|
198
|
+
createSarmalSVG,
|
|
199
|
+
drawCurve,
|
|
200
|
+
evaluateCatmullRom,
|
|
201
|
+
palettes,
|
|
202
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import {
|
|
2
|
+
B as BaseRendererOptions,
|
|
3
|
+
E as Engine,
|
|
4
|
+
S as SarmalInstance,
|
|
5
|
+
C as CurveDef,
|
|
6
|
+
P as Point,
|
|
7
|
+
R as RendererOptions,
|
|
8
|
+
a as ControlPoint,
|
|
9
|
+
b as SarmalOptions,
|
|
10
|
+
} from "./types-Z9i1_AQZ.js";
|
|
11
|
+
export {
|
|
12
|
+
J as JumpOptions,
|
|
13
|
+
c as RuntimeRenderOptions,
|
|
14
|
+
d as SeekOptions,
|
|
15
|
+
T as TrailColor,
|
|
16
|
+
e as TrailStyle,
|
|
17
|
+
} from "./types-Z9i1_AQZ.js";
|
|
18
|
+
export { CurveName, curves } from "./curves/index.js";
|
|
19
|
+
export { artemis2 } from "./curves/artemis2.js";
|
|
20
|
+
export { astroid } from "./curves/astroid.js";
|
|
21
|
+
export { deltoid } from "./curves/deltoid.js";
|
|
22
|
+
export { epicycloid3 } from "./curves/epicycloid3.js";
|
|
23
|
+
export { epitrochoid7 } from "./curves/epitrochoid7.js";
|
|
24
|
+
export { lame } from "./curves/lame.js";
|
|
25
|
+
export { lissajous32 } from "./curves/lissajous32.js";
|
|
26
|
+
export { lissajous43 } from "./curves/lissajous43.js";
|
|
27
|
+
export { rose3 } from "./curves/rose3.js";
|
|
28
|
+
export { rose5 } from "./curves/rose5.js";
|
|
29
|
+
import "./curves/rose52.js";
|
|
30
|
+
import "./curves/star.js";
|
|
31
|
+
import "./curves/star4.js";
|
|
32
|
+
import "./curves/star7.js";
|
|
18
33
|
|
|
19
34
|
interface SVGRendererOptions extends BaseRendererOptions {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
/** SVG element the renderer draws into directly */
|
|
36
|
+
container: SVGSVGElement;
|
|
37
|
+
engine: Engine;
|
|
38
|
+
/** @default 'Loading' */
|
|
39
|
+
ariaLabel?: string;
|
|
25
40
|
}
|
|
26
41
|
interface SVGSarmalOptions extends Omit<SVGRendererOptions, "container" | "engine"> {
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
/** @default 120 */
|
|
43
|
+
trailLength?: number;
|
|
29
44
|
}
|
|
30
45
|
/**
|
|
31
46
|
* Creates a live SVG renderer for sarmal animations
|
|
@@ -50,19 +65,43 @@ declare function createSVGRenderer(options: SVGRendererOptions): SarmalInstance;
|
|
|
50
65
|
* controlled.pause() // Pause later
|
|
51
66
|
* ```
|
|
52
67
|
*/
|
|
53
|
-
declare function createSarmalSVG(
|
|
68
|
+
declare function createSarmalSVG(
|
|
69
|
+
container: SVGSVGElement,
|
|
70
|
+
curveDef: CurveDef,
|
|
71
|
+
options?: SVGSarmalOptions,
|
|
72
|
+
): SarmalInstance;
|
|
54
73
|
|
|
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;
|
|
55
94
|
/**
|
|
56
95
|
* Can be passed directly to `trailColor`,
|
|
57
96
|
* or can be mixed/sliced before passing as a prop.
|
|
58
97
|
*/
|
|
59
98
|
declare const palettes: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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"];
|
|
66
105
|
};
|
|
67
106
|
type SarmalPalette = keyof typeof palettes;
|
|
68
107
|
|
|
@@ -86,7 +125,7 @@ declare function createRenderer(options: RendererOptions): SarmalInstance;
|
|
|
86
125
|
* @param t Parametric position along the closed loop. Wraps into `[0, 2π)` automatically, so values outside that range are remapped rather than rejected
|
|
87
126
|
* @returns The `(x, y)` position on the spline at time `t`
|
|
88
127
|
*/
|
|
89
|
-
declare function evaluateCatmullRom(points: Array<
|
|
128
|
+
declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Point;
|
|
90
129
|
/**
|
|
91
130
|
* The returned curve definition produces a closed Catmull-Rom spline that
|
|
92
131
|
* passes through every point in order, looping back from the last point to the first.
|
|
@@ -94,8 +133,9 @@ declare function evaluateCatmullRom(points: Array<[number, number]>, t: number):
|
|
|
94
133
|
* @param points Array of control points in **normalized `[−1, 1]` space**,
|
|
95
134
|
* matching the playground's draw-mode coordinate system.
|
|
96
135
|
* ! Must contain at least 3 points.
|
|
136
|
+
* @param opts Optional overrides for the returned `CurveDef`.
|
|
137
|
+
* @param opts.name Display name for the curve. Defaults to `"drawn"`.
|
|
97
138
|
* @returns A `CurveDef` with `period: 2π` and the spline evaluator as its `fn`.
|
|
98
|
-
* `name` is set to `"custom"`.
|
|
99
139
|
* @throws If `points` has fewer than 3 entries.
|
|
100
140
|
*
|
|
101
141
|
* @example
|
|
@@ -111,7 +151,12 @@ declare function evaluateCatmullRom(points: Array<[number, number]>, t: number):
|
|
|
111
151
|
* createSarmal(canvas, curve)
|
|
112
152
|
* ```
|
|
113
153
|
*/
|
|
114
|
-
declare function drawCurve(
|
|
154
|
+
declare function drawCurve(
|
|
155
|
+
points: Array<ControlPoint>,
|
|
156
|
+
opts?: {
|
|
157
|
+
name?: string;
|
|
158
|
+
},
|
|
159
|
+
): CurveDef;
|
|
115
160
|
|
|
116
161
|
/**
|
|
117
162
|
* Creates a sarmal animation on a canvas element
|
|
@@ -127,6 +172,31 @@ declare function drawCurve(points: Array<[number, number]>): CurveDef;
|
|
|
127
172
|
* controlled.pause() // Pause later
|
|
128
173
|
* ```
|
|
129
174
|
*/
|
|
130
|
-
declare function createSarmal(
|
|
175
|
+
declare function createSarmal(
|
|
176
|
+
canvas: HTMLCanvasElement,
|
|
177
|
+
curveDef: CurveDef,
|
|
178
|
+
options?: SarmalOptions,
|
|
179
|
+
): SarmalInstance;
|
|
131
180
|
|
|
132
|
-
export {
|
|
181
|
+
export {
|
|
182
|
+
BaseRendererOptions,
|
|
183
|
+
type BoundaryResult,
|
|
184
|
+
CurveDef,
|
|
185
|
+
Engine,
|
|
186
|
+
Point,
|
|
187
|
+
RendererOptions,
|
|
188
|
+
type SVGRendererOptions,
|
|
189
|
+
type SVGSarmalOptions,
|
|
190
|
+
SarmalInstance,
|
|
191
|
+
SarmalOptions,
|
|
192
|
+
type SarmalPalette,
|
|
193
|
+
computeBoundaries,
|
|
194
|
+
createEngine,
|
|
195
|
+
createRenderer,
|
|
196
|
+
createSVGRenderer,
|
|
197
|
+
createSarmal,
|
|
198
|
+
createSarmalSVG,
|
|
199
|
+
drawCurve,
|
|
200
|
+
evaluateCatmullRom,
|
|
201
|
+
palettes,
|
|
202
|
+
};
|