@sarmal/core 0.25.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 +140 -105
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.js +139 -104
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.cjs +15 -10
- package/dist/curves/artemis2.cjs.map +1 -1
- package/dist/curves/artemis2.d.cts +1 -1
- package/dist/curves/artemis2.d.ts +1 -1
- package/dist/curves/artemis2.js +14 -9
- 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 +58 -43
- 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 +74 -43
- 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 +126 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -40
- package/dist/index.d.ts +92 -40
- package/dist/index.js +147 -93
- 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-BZpzgNau.d.cts +0 -332
- package/dist/types-BZpzgNau.d.ts +0 -332
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,12 +65,16 @@ 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
|
|
|
55
74
|
interface BoundaryResult {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
scale: number;
|
|
76
|
+
offsetX: number;
|
|
77
|
+
offsetY: number;
|
|
59
78
|
}
|
|
60
79
|
/**
|
|
61
80
|
* Computes how to map engine coordinates into a viewport of the given logical size.
|
|
@@ -66,18 +85,23 @@ interface BoundaryResult {
|
|
|
66
85
|
* `minPaddingPx` defaults to `FIT_PADDING_MIN` (4px) for pixel-space callers.
|
|
67
86
|
* Pass `0` when the logical space is itself a normalized viewBox (e.g. SVG export).
|
|
68
87
|
*/
|
|
69
|
-
declare function computeBoundaries(
|
|
88
|
+
declare function computeBoundaries(
|
|
89
|
+
pts: Point[],
|
|
90
|
+
logicalWidth: number,
|
|
91
|
+
logicalHeight: number,
|
|
92
|
+
minPaddingPx?: number,
|
|
93
|
+
): BoundaryResult | null;
|
|
70
94
|
/**
|
|
71
95
|
* Can be passed directly to `trailColor`,
|
|
72
96
|
* or can be mixed/sliced before passing as a prop.
|
|
73
97
|
*/
|
|
74
98
|
declare const palettes: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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"];
|
|
81
105
|
};
|
|
82
106
|
type SarmalPalette = keyof typeof palettes;
|
|
83
107
|
|
|
@@ -111,7 +135,7 @@ declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Poi
|
|
|
111
135
|
* ! Must contain at least 3 points.
|
|
112
136
|
* @param opts Optional overrides for the returned `CurveDef`.
|
|
113
137
|
* @param opts.name Display name for the curve. Defaults to `"drawn"`.
|
|
114
|
-
* @returns A `CurveDef` with `period: 2
|
|
138
|
+
* @returns A `CurveDef` with `period: 2π` and the spline evaluator as its `fn`.
|
|
115
139
|
* @throws If `points` has fewer than 3 entries.
|
|
116
140
|
*
|
|
117
141
|
* @example
|
|
@@ -127,9 +151,12 @@ declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Poi
|
|
|
127
151
|
* createSarmal(canvas, curve)
|
|
128
152
|
* ```
|
|
129
153
|
*/
|
|
130
|
-
declare function drawCurve(
|
|
154
|
+
declare function drawCurve(
|
|
155
|
+
points: Array<ControlPoint>,
|
|
156
|
+
opts?: {
|
|
131
157
|
name?: string;
|
|
132
|
-
}
|
|
158
|
+
},
|
|
159
|
+
): CurveDef;
|
|
133
160
|
|
|
134
161
|
/**
|
|
135
162
|
* Creates a sarmal animation on a canvas element
|
|
@@ -145,6 +172,31 @@ declare function drawCurve(points: Array<ControlPoint>, opts?: {
|
|
|
145
172
|
* controlled.pause() // Pause later
|
|
146
173
|
* ```
|
|
147
174
|
*/
|
|
148
|
-
declare function createSarmal(
|
|
175
|
+
declare function createSarmal(
|
|
176
|
+
canvas: HTMLCanvasElement,
|
|
177
|
+
curveDef: CurveDef,
|
|
178
|
+
options?: SarmalOptions,
|
|
179
|
+
): SarmalInstance;
|
|
149
180
|
|
|
150
|
-
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,12 +65,16 @@ 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
|
|
|
55
74
|
interface BoundaryResult {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
scale: number;
|
|
76
|
+
offsetX: number;
|
|
77
|
+
offsetY: number;
|
|
59
78
|
}
|
|
60
79
|
/**
|
|
61
80
|
* Computes how to map engine coordinates into a viewport of the given logical size.
|
|
@@ -66,18 +85,23 @@ interface BoundaryResult {
|
|
|
66
85
|
* `minPaddingPx` defaults to `FIT_PADDING_MIN` (4px) for pixel-space callers.
|
|
67
86
|
* Pass `0` when the logical space is itself a normalized viewBox (e.g. SVG export).
|
|
68
87
|
*/
|
|
69
|
-
declare function computeBoundaries(
|
|
88
|
+
declare function computeBoundaries(
|
|
89
|
+
pts: Point[],
|
|
90
|
+
logicalWidth: number,
|
|
91
|
+
logicalHeight: number,
|
|
92
|
+
minPaddingPx?: number,
|
|
93
|
+
): BoundaryResult | null;
|
|
70
94
|
/**
|
|
71
95
|
* Can be passed directly to `trailColor`,
|
|
72
96
|
* or can be mixed/sliced before passing as a prop.
|
|
73
97
|
*/
|
|
74
98
|
declare const palettes: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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"];
|
|
81
105
|
};
|
|
82
106
|
type SarmalPalette = keyof typeof palettes;
|
|
83
107
|
|
|
@@ -111,7 +135,7 @@ declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Poi
|
|
|
111
135
|
* ! Must contain at least 3 points.
|
|
112
136
|
* @param opts Optional overrides for the returned `CurveDef`.
|
|
113
137
|
* @param opts.name Display name for the curve. Defaults to `"drawn"`.
|
|
114
|
-
* @returns A `CurveDef` with `period: 2
|
|
138
|
+
* @returns A `CurveDef` with `period: 2π` and the spline evaluator as its `fn`.
|
|
115
139
|
* @throws If `points` has fewer than 3 entries.
|
|
116
140
|
*
|
|
117
141
|
* @example
|
|
@@ -127,9 +151,12 @@ declare function evaluateCatmullRom(points: Array<ControlPoint>, t: number): Poi
|
|
|
127
151
|
* createSarmal(canvas, curve)
|
|
128
152
|
* ```
|
|
129
153
|
*/
|
|
130
|
-
declare function drawCurve(
|
|
154
|
+
declare function drawCurve(
|
|
155
|
+
points: Array<ControlPoint>,
|
|
156
|
+
opts?: {
|
|
131
157
|
name?: string;
|
|
132
|
-
}
|
|
158
|
+
},
|
|
159
|
+
): CurveDef;
|
|
133
160
|
|
|
134
161
|
/**
|
|
135
162
|
* Creates a sarmal animation on a canvas element
|
|
@@ -145,6 +172,31 @@ declare function drawCurve(points: Array<ControlPoint>, opts?: {
|
|
|
145
172
|
* controlled.pause() // Pause later
|
|
146
173
|
* ```
|
|
147
174
|
*/
|
|
148
|
-
declare function createSarmal(
|
|
175
|
+
declare function createSarmal(
|
|
176
|
+
canvas: HTMLCanvasElement,
|
|
177
|
+
curveDef: CurveDef,
|
|
178
|
+
options?: SarmalOptions,
|
|
179
|
+
): SarmalInstance;
|
|
149
180
|
|
|
150
|
-
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
|
+
};
|