@sarmal/core 0.25.1 → 0.26.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.
- package/dist/auto-init.cjs +170 -206
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.js +169 -205
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.cjs +14 -20
- 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 +13 -19
- package/dist/curves/artemis2.js.map +1 -1
- package/dist/curves/astroid.cjs +7 -7
- package/dist/curves/astroid.cjs.map +1 -1
- package/dist/curves/astroid.d.cts +1 -1
- package/dist/curves/astroid.d.ts +1 -1
- package/dist/curves/astroid.js +6 -6
- package/dist/curves/astroid.js.map +1 -1
- package/dist/curves/deltoid.cjs +6 -6
- package/dist/curves/deltoid.cjs.map +1 -1
- package/dist/curves/deltoid.d.cts +1 -1
- package/dist/curves/deltoid.d.ts +1 -1
- package/dist/curves/deltoid.js +5 -5
- package/dist/curves/deltoid.js.map +1 -1
- package/dist/curves/epicycloid3.cjs +6 -6
- package/dist/curves/epicycloid3.cjs.map +1 -1
- package/dist/curves/epicycloid3.d.cts +1 -1
- package/dist/curves/epicycloid3.d.ts +1 -1
- package/dist/curves/epicycloid3.js +5 -5
- package/dist/curves/epicycloid3.js.map +1 -1
- package/dist/curves/epitrochoid7.cjs +10 -10
- package/dist/curves/epitrochoid7.cjs.map +1 -1
- package/dist/curves/epitrochoid7.d.cts +1 -1
- package/dist/curves/epitrochoid7.d.ts +1 -1
- package/dist/curves/epitrochoid7.js +9 -9
- package/dist/curves/epitrochoid7.js.map +1 -1
- package/dist/curves/index.cjs +81 -97
- 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 +81 -113
- package/dist/curves/index.js.map +1 -1
- package/dist/curves/lame.cjs +7 -8
- package/dist/curves/lame.cjs.map +1 -1
- package/dist/curves/lame.d.cts +1 -1
- package/dist/curves/lame.d.ts +1 -1
- package/dist/curves/lame.js +6 -7
- package/dist/curves/lame.js.map +1 -1
- package/dist/curves/lissajous32.cjs +7 -7
- package/dist/curves/lissajous32.cjs.map +1 -1
- package/dist/curves/lissajous32.d.cts +1 -1
- package/dist/curves/lissajous32.d.ts +1 -1
- package/dist/curves/lissajous32.js +6 -6
- package/dist/curves/lissajous32.js.map +1 -1
- package/dist/curves/lissajous43.cjs +7 -7
- package/dist/curves/lissajous43.cjs.map +1 -1
- package/dist/curves/lissajous43.d.cts +1 -1
- package/dist/curves/lissajous43.d.ts +1 -1
- package/dist/curves/lissajous43.js +6 -6
- package/dist/curves/lissajous43.js.map +1 -1
- package/dist/curves/rose3.cjs +7 -7
- package/dist/curves/rose3.cjs.map +1 -1
- package/dist/curves/rose3.d.cts +1 -1
- package/dist/curves/rose3.d.ts +1 -1
- package/dist/curves/rose3.js +6 -6
- package/dist/curves/rose3.js.map +1 -1
- package/dist/curves/rose5.cjs +7 -7
- package/dist/curves/rose5.cjs.map +1 -1
- package/dist/curves/rose5.d.cts +1 -1
- package/dist/curves/rose5.d.ts +1 -1
- package/dist/curves/rose5.js +6 -6
- package/dist/curves/rose5.js.map +1 -1
- package/dist/curves/rose52.cjs +7 -7
- package/dist/curves/rose52.cjs.map +1 -1
- package/dist/curves/rose52.d.cts +1 -1
- package/dist/curves/rose52.d.ts +1 -1
- package/dist/curves/rose52.js +6 -6
- package/dist/curves/rose52.js.map +1 -1
- package/dist/curves/star.cjs +7 -10
- package/dist/curves/star.cjs.map +1 -1
- package/dist/curves/star.d.cts +1 -1
- package/dist/curves/star.d.ts +1 -1
- package/dist/curves/star.js +6 -9
- package/dist/curves/star.js.map +1 -1
- package/dist/curves/star4.cjs +7 -10
- package/dist/curves/star4.cjs.map +1 -1
- package/dist/curves/star4.d.cts +2 -2
- package/dist/curves/star4.d.ts +2 -2
- package/dist/curves/star4.js +6 -9
- package/dist/curves/star4.js.map +1 -1
- package/dist/curves/star7.cjs +7 -10
- package/dist/curves/star7.cjs.map +1 -1
- package/dist/curves/star7.d.cts +2 -2
- package/dist/curves/star7.d.ts +2 -2
- package/dist/curves/star7.js +6 -9
- package/dist/curves/star7.js.map +1 -1
- package/dist/index.cjs +158 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -95
- package/dist/index.d.ts +43 -95
- package/dist/index.js +158 -213
- package/dist/index.js.map +1 -1
- package/dist/types-zbxUgcmZ.d.cts +325 -0
- package/dist/types-zbxUgcmZ.d.ts +325 -0
- package/package.json +1 -1
- package/dist/types-Z9i1_AQZ.d.cts +0 -339
- package/dist/types-Z9i1_AQZ.d.ts +0 -339
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/engine.ts
|
|
4
4
|
var TWO_PI = Math.PI * 2;
|
|
@@ -63,32 +63,32 @@ 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);
|
|
76
76
|
const trail = new CircularBuffer(trailLength);
|
|
77
|
-
let
|
|
77
|
+
let phase = 0;
|
|
78
78
|
let actualTime = 0;
|
|
79
79
|
let userSpeedOverride = null;
|
|
80
80
|
let morphCurveB = null;
|
|
81
81
|
let _morphAlpha = null;
|
|
82
82
|
let _morphStrategy = "normalized";
|
|
83
83
|
let _speedTransition = null;
|
|
84
|
-
function sampleSkeleton(c,
|
|
84
|
+
function sampleSkeleton(c, samplePhase) {
|
|
85
85
|
if (c.skeletonFn) {
|
|
86
|
-
return c.skeletonFn(
|
|
86
|
+
return c.skeletonFn(samplePhase);
|
|
87
87
|
}
|
|
88
88
|
if (c.skeleton === "live") {
|
|
89
|
-
return c.fn(
|
|
89
|
+
return c.fn(samplePhase, actualTime, EMPTY_PARAMS);
|
|
90
90
|
}
|
|
91
|
-
return c.fn(
|
|
91
|
+
return c.fn(samplePhase, 0, EMPTY_PARAMS);
|
|
92
92
|
}
|
|
93
93
|
return {
|
|
94
94
|
tick(deltaTime) {
|
|
@@ -106,15 +106,15 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
106
106
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
107
107
|
effectiveSpeed = lerp(effectiveSpeed, morphCurveB.speed, _morphAlpha);
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
phase = (phase + effectiveSpeed * deltaTime) % curve.period;
|
|
110
110
|
actualTime += deltaTime;
|
|
111
111
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
112
|
-
const a = curve.fn(
|
|
113
|
-
const
|
|
114
|
-
const b = morphCurveB.fn(
|
|
112
|
+
const a = curve.fn(phase, actualTime, EMPTY_PARAMS);
|
|
113
|
+
const phaseB = _morphStrategy === "normalized" ? phase / curve.period * morphCurveB.period : phase;
|
|
114
|
+
const b = morphCurveB.fn(phaseB, actualTime, EMPTY_PARAMS);
|
|
115
115
|
trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
|
|
116
116
|
} else {
|
|
117
|
-
const point = curve.fn(
|
|
117
|
+
const point = curve.fn(phase, actualTime, EMPTY_PARAMS);
|
|
118
118
|
trail.push(point.x, point.y);
|
|
119
119
|
}
|
|
120
120
|
return trail.toArray();
|
|
@@ -132,30 +132,30 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
132
132
|
return _morphAlpha;
|
|
133
133
|
},
|
|
134
134
|
reset() {
|
|
135
|
-
|
|
135
|
+
phase = 0;
|
|
136
136
|
actualTime = 0;
|
|
137
137
|
trail.clear();
|
|
138
138
|
},
|
|
139
|
-
jump(
|
|
140
|
-
|
|
139
|
+
jump(newPhase, { clearTrail = false } = {}) {
|
|
140
|
+
phase = (newPhase % curve.period + curve.period) % curve.period;
|
|
141
141
|
if (clearTrail) {
|
|
142
142
|
trail.clear();
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
|
-
seek(
|
|
145
|
+
seek(targetPhase, { wrap = false, step = curve.period / trailLength } = {}) {
|
|
146
146
|
const advance = curve.speed * step;
|
|
147
|
-
const target = (
|
|
147
|
+
const target = (targetPhase % curve.period + curve.period) % curve.period;
|
|
148
148
|
const targetTime = target / curve.speed;
|
|
149
|
-
|
|
149
|
+
phase = target;
|
|
150
150
|
actualTime = targetTime;
|
|
151
151
|
trail.clear();
|
|
152
152
|
const pointsFromStart = Math.floor(target / advance) + 1;
|
|
153
153
|
const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
|
|
154
154
|
for (let i = count - 1; i >= 0; i--) {
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const point = curve.fn(
|
|
155
|
+
const samplePhase = target - i * advance;
|
|
156
|
+
const wrappedPhase = (samplePhase % curve.period + curve.period) % curve.period;
|
|
157
|
+
const elapsed = targetTime - i * step;
|
|
158
|
+
const point = curve.fn(wrappedPhase, elapsed, EMPTY_PARAMS);
|
|
159
159
|
trail.push(point.x, point.y);
|
|
160
160
|
}
|
|
161
161
|
},
|
|
@@ -168,18 +168,15 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
168
168
|
const frozenStrategy = _morphStrategy;
|
|
169
169
|
curve = {
|
|
170
170
|
...frozenB,
|
|
171
|
-
fn: (
|
|
172
|
-
const a = frozenA.fn(
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
? (sampleT / frozenA.period) * frozenB.period
|
|
176
|
-
: sampleT;
|
|
177
|
-
const b = frozenB.fn(tB, time, params);
|
|
171
|
+
fn: (samplePhase, elapsed, params) => {
|
|
172
|
+
const a = frozenA.fn(samplePhase, elapsed, params);
|
|
173
|
+
const phaseB = frozenStrategy === "normalized" ? samplePhase / frozenA.period * frozenB.period : samplePhase;
|
|
174
|
+
const b = frozenB.fn(phaseB, elapsed, params);
|
|
178
175
|
return {
|
|
179
176
|
x: a.x + (b.x - a.x) * frozenAlpha,
|
|
180
|
-
y: a.y + (b.y - a.y) * frozenAlpha
|
|
177
|
+
y: a.y + (b.y - a.y) * frozenAlpha
|
|
181
178
|
};
|
|
182
|
-
}
|
|
179
|
+
}
|
|
183
180
|
};
|
|
184
181
|
}
|
|
185
182
|
_morphStrategy = strategy;
|
|
@@ -192,7 +189,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
192
189
|
completeMorph() {
|
|
193
190
|
if (morphCurveB !== null) {
|
|
194
191
|
if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
|
|
195
|
-
|
|
192
|
+
phase = phase / curve.period * morphCurveB.period;
|
|
196
193
|
}
|
|
197
194
|
curve = morphCurveB;
|
|
198
195
|
}
|
|
@@ -204,23 +201,20 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
204
201
|
const points2 = new Array(steps);
|
|
205
202
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
206
203
|
for (let i = 0; i < steps; i++) {
|
|
207
|
-
const
|
|
208
|
-
const a = sampleSkeleton(curve,
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
? (sampleT / curve.period) * morphCurveB.period
|
|
212
|
-
: sampleT;
|
|
213
|
-
const b = sampleSkeleton(morphCurveB, tB);
|
|
204
|
+
const samplePhase = i / (steps - 1) * curve.period;
|
|
205
|
+
const a = sampleSkeleton(curve, samplePhase);
|
|
206
|
+
const phaseB = _morphStrategy === "normalized" ? samplePhase / curve.period * morphCurveB.period : samplePhase;
|
|
207
|
+
const b = sampleSkeleton(morphCurveB, phaseB);
|
|
214
208
|
points2[i] = {
|
|
215
209
|
x: a.x + (b.x - a.x) * _morphAlpha,
|
|
216
|
-
y: a.y + (b.y - a.y) * _morphAlpha
|
|
210
|
+
y: a.y + (b.y - a.y) * _morphAlpha
|
|
217
211
|
};
|
|
218
212
|
}
|
|
219
213
|
return points2;
|
|
220
214
|
}
|
|
221
215
|
for (let i = 0; i < steps; i++) {
|
|
222
|
-
const
|
|
223
|
-
points2[i] = sampleSkeleton(curve,
|
|
216
|
+
const samplePhase = i / (steps - 1) * curve.period;
|
|
217
|
+
points2[i] = sampleSkeleton(curve, samplePhase);
|
|
224
218
|
}
|
|
225
219
|
return points2;
|
|
226
220
|
},
|
|
@@ -261,7 +255,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
261
255
|
_speedTransition.reject(new Error("Speed transition cancelled"));
|
|
262
256
|
_speedTransition = null;
|
|
263
257
|
}
|
|
264
|
-
}
|
|
258
|
+
}
|
|
265
259
|
};
|
|
266
260
|
}
|
|
267
261
|
|
|
@@ -300,15 +294,7 @@ function computeNormal(trail, i) {
|
|
|
300
294
|
const tangent = computeTangent(trail, i);
|
|
301
295
|
return { x: -tangent.y, y: tangent.x };
|
|
302
296
|
}
|
|
303
|
-
function computeTrailQuad(
|
|
304
|
-
trail,
|
|
305
|
-
i,
|
|
306
|
-
trailCount,
|
|
307
|
-
toX,
|
|
308
|
-
toY,
|
|
309
|
-
minWidth = TRAIL_MIN_WIDTH,
|
|
310
|
-
maxWidth = TRAIL_MAX_WIDTH,
|
|
311
|
-
) {
|
|
297
|
+
function computeTrailQuad(trail, i, trailCount, toX, toY, minWidth = TRAIL_MIN_WIDTH, maxWidth = TRAIL_MAX_WIDTH) {
|
|
312
298
|
const progress = i / (trailCount - 1);
|
|
313
299
|
const nextProgress = (i + 1) / (trailCount - 1);
|
|
314
300
|
const opacity = Math.pow(progress, TRAIL_FADE_CURVE) * TRAIL_MAX_OPACITY;
|
|
@@ -332,16 +318,13 @@ function computeTrailQuad(
|
|
|
332
318
|
r1x: nx - n1.x * w1,
|
|
333
319
|
r1y: ny - n1.y * w1,
|
|
334
320
|
opacity,
|
|
335
|
-
progress
|
|
321
|
+
progress
|
|
336
322
|
};
|
|
337
323
|
}
|
|
338
324
|
function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_PADDING_MIN) {
|
|
339
325
|
if (pts.length === 0) return null;
|
|
340
326
|
const first = pts[0];
|
|
341
|
-
let minX = first.x,
|
|
342
|
-
maxX = first.x,
|
|
343
|
-
minY = first.y,
|
|
344
|
-
maxY = first.y;
|
|
327
|
+
let minX = first.x, maxX = first.x, minY = first.y, maxY = first.y;
|
|
345
328
|
for (const p of pts) {
|
|
346
329
|
if (p.x < minX) {
|
|
347
330
|
minX = p.x;
|
|
@@ -360,7 +343,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
360
343
|
const h = maxY - minY;
|
|
361
344
|
if (w === 0 && h === 0) {
|
|
362
345
|
throw new Error(
|
|
363
|
-
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
346
|
+
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
364
347
|
);
|
|
365
348
|
}
|
|
366
349
|
const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
|
|
@@ -371,12 +354,12 @@ function computeBoundaries(pts, logicalWidth, logicalHeight, minPaddingPx = FIT_
|
|
|
371
354
|
scaleXProportional,
|
|
372
355
|
scaleYProportional,
|
|
373
356
|
scaleXMinPadding,
|
|
374
|
-
scaleYMinPadding
|
|
357
|
+
scaleYMinPadding
|
|
375
358
|
);
|
|
376
359
|
return {
|
|
377
360
|
scale,
|
|
378
361
|
offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
|
|
379
|
-
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
362
|
+
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
380
363
|
};
|
|
381
364
|
}
|
|
382
365
|
function enginePassthroughs(engine) {
|
|
@@ -387,7 +370,7 @@ function enginePassthroughs(engine) {
|
|
|
387
370
|
getSpeed: engine.getSpeed,
|
|
388
371
|
resetSpeed: engine.resetSpeed,
|
|
389
372
|
setSpeedOver: engine.setSpeedOver,
|
|
390
|
-
getSarmalSkeleton: engine.getSarmalSkeleton
|
|
373
|
+
getSarmalSkeleton: engine.getSarmalSkeleton
|
|
391
374
|
};
|
|
392
375
|
}
|
|
393
376
|
var palettes = {
|
|
@@ -396,16 +379,16 @@ var palettes = {
|
|
|
396
379
|
ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"],
|
|
397
380
|
ice: ["#1e3a8a", "#67e8f9"],
|
|
398
381
|
fire: ["#7f1d1d", "#fbbf24"],
|
|
399
|
-
forest: ["#14532d", "#86efac"]
|
|
382
|
+
forest: ["#14532d", "#86efac"]
|
|
400
383
|
};
|
|
401
384
|
function hexToRgb(hex) {
|
|
402
385
|
const n = parseInt(hex.slice(1), 16);
|
|
403
|
-
return { r: n >> 16, g:
|
|
386
|
+
return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
|
|
404
387
|
}
|
|
405
388
|
var lerpRgb = (a, b, t) => ({
|
|
406
389
|
r: Math.round(a.r + (b.r - a.r) * t),
|
|
407
390
|
g: Math.round(a.g + (b.g - a.g) * t),
|
|
408
|
-
b: Math.round(a.b + (b.b - a.b) * t)
|
|
391
|
+
b: Math.round(a.b + (b.b - a.b) * t)
|
|
409
392
|
});
|
|
410
393
|
function getPaletteColor(palette, position, timeOffset = 0) {
|
|
411
394
|
if (palette.length === 0) {
|
|
@@ -414,7 +397,7 @@ function getPaletteColor(palette, position, timeOffset = 0) {
|
|
|
414
397
|
if (palette.length === 1) {
|
|
415
398
|
return hexToRgb(palette[0]);
|
|
416
399
|
}
|
|
417
|
-
const cyclePos = ((
|
|
400
|
+
const cyclePos = ((position + timeOffset) % 1 + 1) % 1;
|
|
418
401
|
const scaled = cyclePos * palette.length;
|
|
419
402
|
const idx = Math.floor(scaled);
|
|
420
403
|
const t = scaled - idx;
|
|
@@ -429,7 +412,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
|
429
412
|
"headColor",
|
|
430
413
|
"skeletonColor",
|
|
431
414
|
"trailStyle",
|
|
432
|
-
"headRadius"
|
|
415
|
+
"headRadius"
|
|
433
416
|
]);
|
|
434
417
|
function validateRenderOptions(partial) {
|
|
435
418
|
for (const key of Object.keys(partial)) {
|
|
@@ -457,7 +440,7 @@ function assertTrailColor(value) {
|
|
|
457
440
|
if (typeof value === "string") {
|
|
458
441
|
if (!HEX_COLOR_RE.test(value)) {
|
|
459
442
|
throw new TypeError(
|
|
460
|
-
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"
|
|
443
|
+
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string, got "${value}"`
|
|
461
444
|
);
|
|
462
445
|
}
|
|
463
446
|
return;
|
|
@@ -465,21 +448,21 @@ function assertTrailColor(value) {
|
|
|
465
448
|
if (Array.isArray(value)) {
|
|
466
449
|
if (value.length < 2) {
|
|
467
450
|
throw new RangeError(
|
|
468
|
-
`[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}
|
|
451
|
+
`[sarmal] setRenderOptions: trailColor array must have at least 2 entries, got ${value.length}`
|
|
469
452
|
);
|
|
470
453
|
}
|
|
471
454
|
for (let i = 0; i < value.length; i++) {
|
|
472
455
|
const entry = value[i];
|
|
473
456
|
if (typeof entry !== "string" || !HEX_COLOR_RE.test(entry)) {
|
|
474
457
|
throw new TypeError(
|
|
475
|
-
`[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}
|
|
458
|
+
`[sarmal] setRenderOptions: trailColor[${i}] must be a 6-digit hex string, got ${JSON.stringify(entry)}`
|
|
476
459
|
);
|
|
477
460
|
}
|
|
478
461
|
}
|
|
479
462
|
return;
|
|
480
463
|
}
|
|
481
464
|
throw new TypeError(
|
|
482
|
-
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}
|
|
465
|
+
`[sarmal] setRenderOptions: trailColor must be a 6-digit hex string or an array of hex strings, got ${JSON.stringify(value)}`
|
|
483
466
|
);
|
|
484
467
|
}
|
|
485
468
|
function assertHeadColor(value) {
|
|
@@ -488,7 +471,7 @@ function assertHeadColor(value) {
|
|
|
488
471
|
}
|
|
489
472
|
if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
|
|
490
473
|
throw new TypeError(
|
|
491
|
-
`[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}
|
|
474
|
+
`[sarmal] setRenderOptions: headColor must be a 6-digit hex string or null, got ${JSON.stringify(value)}`
|
|
492
475
|
);
|
|
493
476
|
}
|
|
494
477
|
}
|
|
@@ -498,26 +481,26 @@ function assertSkeletonColor(value) {
|
|
|
498
481
|
}
|
|
499
482
|
if (typeof value !== "string" || !HEX_COLOR_RE.test(value)) {
|
|
500
483
|
throw new TypeError(
|
|
501
|
-
`[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}
|
|
484
|
+
`[sarmal] setRenderOptions: skeletonColor must be a 6-digit hex string or "transparent", got ${JSON.stringify(value)}`
|
|
502
485
|
);
|
|
503
486
|
}
|
|
504
487
|
}
|
|
505
488
|
function assertTrailStyle(value) {
|
|
506
489
|
if (!TRAIL_STYLES.includes(value)) {
|
|
507
490
|
throw new RangeError(
|
|
508
|
-
`[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}
|
|
491
|
+
`[sarmal] setRenderOptions: trailStyle must be one of "default", "gradient-static", "gradient-animated", got ${JSON.stringify(value)}`
|
|
509
492
|
);
|
|
510
493
|
}
|
|
511
494
|
}
|
|
512
495
|
function assertHeadRadius(value) {
|
|
513
496
|
if (typeof value !== "number") {
|
|
514
497
|
throw new TypeError(
|
|
515
|
-
`[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}
|
|
498
|
+
`[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`
|
|
516
499
|
);
|
|
517
500
|
}
|
|
518
501
|
if (!Number.isFinite(value) || value <= 0) {
|
|
519
502
|
throw new TypeError(
|
|
520
|
-
`[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}
|
|
503
|
+
`[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`
|
|
521
504
|
);
|
|
522
505
|
}
|
|
523
506
|
}
|
|
@@ -539,13 +522,13 @@ function resolveHeadColor(trailColor, trailStyle) {
|
|
|
539
522
|
function warnIfTrailColorMismatch(trailColor, trailStyle) {
|
|
540
523
|
if (trailStyle === "default" && Array.isArray(trailColor)) {
|
|
541
524
|
console.warn(
|
|
542
|
-
'[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.'
|
|
525
|
+
'[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.'
|
|
543
526
|
);
|
|
544
527
|
return;
|
|
545
528
|
}
|
|
546
529
|
if (trailStyle !== "default" && typeof trailColor === "string") {
|
|
547
530
|
console.warn(
|
|
548
|
-
`[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
|
|
531
|
+
`[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.`
|
|
549
532
|
);
|
|
550
533
|
}
|
|
551
534
|
}
|
|
@@ -555,7 +538,7 @@ var getHeadDotRadius = (w, h) => Math.max(1, 3 * Math.sqrt(Math.min(w, h) / 160)
|
|
|
555
538
|
var WHITE_HEX = "#ffffff";
|
|
556
539
|
function hexToRgbComponents(hex) {
|
|
557
540
|
const n = parseInt(hex.slice(1), 16);
|
|
558
|
-
return `${n >> 16},${
|
|
541
|
+
return `${n >> 16},${n >> 8 & 255},${n & 255}`;
|
|
559
542
|
}
|
|
560
543
|
function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
|
|
561
544
|
target.style.width = `${logicalWidth}px`;
|
|
@@ -682,7 +665,7 @@ function createRenderer(options) {
|
|
|
682
665
|
i,
|
|
683
666
|
trailCount,
|
|
684
667
|
toX,
|
|
685
|
-
toY
|
|
668
|
+
toY
|
|
686
669
|
);
|
|
687
670
|
if (trailStyle === "default") {
|
|
688
671
|
ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
|
|
@@ -762,8 +745,8 @@ function createRenderer(options) {
|
|
|
762
745
|
if (!engine.isLiveSkeleton) {
|
|
763
746
|
buildSkeletonCanvas();
|
|
764
747
|
}
|
|
765
|
-
if (options.
|
|
766
|
-
engine.seek(options.
|
|
748
|
+
if (options.initialPhase !== void 0) {
|
|
749
|
+
engine.seek(options.initialPhase);
|
|
767
750
|
}
|
|
768
751
|
renderFrame(0);
|
|
769
752
|
const shouldAutoStart = options.autoStart !== false;
|
|
@@ -847,7 +830,7 @@ function createRenderer(options) {
|
|
|
847
830
|
if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
|
|
848
831
|
warnIfTrailColorMismatch(trailColor, trailStyle);
|
|
849
832
|
}
|
|
850
|
-
}
|
|
833
|
+
}
|
|
851
834
|
};
|
|
852
835
|
const pauseOnHidden = options.pauseOnHidden !== false;
|
|
853
836
|
function handleVisibilityChange() {
|
|
@@ -897,8 +880,8 @@ function sampleCurveSkeleton(curveDef) {
|
|
|
897
880
|
const samples = Math.ceil(period * 50);
|
|
898
881
|
const pts = Array.from({ length: samples });
|
|
899
882
|
for (let i = 0; i < samples; i++) {
|
|
900
|
-
const
|
|
901
|
-
pts[i] = curveDef.skeletonFn ? curveDef.skeletonFn(
|
|
883
|
+
const phase = i / (samples - 1) * period;
|
|
884
|
+
pts[i] = curveDef.skeletonFn ? curveDef.skeletonFn(phase) : curveDef.fn(phase, 0, EMPTY_PARAMS2);
|
|
902
885
|
}
|
|
903
886
|
return pts;
|
|
904
887
|
}
|
|
@@ -910,7 +893,7 @@ function createSVGRenderer(options) {
|
|
|
910
893
|
const poolSize = engine.trailLength;
|
|
911
894
|
if (poolSize > HIGH_TRAIL_LENGTH_THRESHOLD) {
|
|
912
895
|
console.warn(
|
|
913
|
-
`[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails
|
|
896
|
+
`[sarmal] High trailLength in SVG renderer (${poolSize}). Consider using the canvas renderer for long trails.`
|
|
914
897
|
);
|
|
915
898
|
}
|
|
916
899
|
let trailStyle = options.trailStyle ?? "default";
|
|
@@ -929,9 +912,9 @@ function createSVGRenderer(options) {
|
|
|
929
912
|
return rect.width && rect.height ? Math.min(rect.width, rect.height) : 200;
|
|
930
913
|
}
|
|
931
914
|
const containerPx = getContainerPixelSize();
|
|
932
|
-
const svgTrailMinWidth =
|
|
933
|
-
const svgTrailMaxWidth =
|
|
934
|
-
const svgSkeletonStrokeWidth = String(
|
|
915
|
+
const svgTrailMinWidth = TRAIL_MIN_WIDTH * viewSize / containerPx;
|
|
916
|
+
const svgTrailMaxWidth = TRAIL_MAX_WIDTH * viewSize / containerPx;
|
|
917
|
+
const svgSkeletonStrokeWidth = String(SKELETON_STROKE_WIDTH_PX * viewSize / containerPx);
|
|
935
918
|
headRadius = options.headRadius ?? SVG_DEFAULT_HEAD_RADIUS;
|
|
936
919
|
container.setAttribute("viewBox", `0 0 ${viewSize} ${viewSize}`);
|
|
937
920
|
container.setAttribute("role", "img");
|
|
@@ -1019,7 +1002,7 @@ function createSVGRenderer(options) {
|
|
|
1019
1002
|
px,
|
|
1020
1003
|
py,
|
|
1021
1004
|
svgTrailMinWidth,
|
|
1022
|
-
svgTrailMaxWidth
|
|
1005
|
+
svgTrailMaxWidth
|
|
1023
1006
|
);
|
|
1024
1007
|
const d = `M${l0x.toFixed(2)} ${l0y.toFixed(2)} L${l1x.toFixed(2)} ${l1y.toFixed(2)} L${r1x.toFixed(2)} ${r1y.toFixed(2)} L${r0x.toFixed(2)} ${r0y.toFixed(2)} Z`;
|
|
1025
1008
|
trailPaths[i].setAttribute("d", d);
|
|
@@ -1047,8 +1030,7 @@ function createSVGRenderer(options) {
|
|
|
1047
1030
|
let animationId = null;
|
|
1048
1031
|
let lastTime = 0;
|
|
1049
1032
|
let pausedByVisibility = false;
|
|
1050
|
-
const prefersReducedMotion =
|
|
1051
|
-
typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1033
|
+
const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1052
1034
|
let morphResolve = null;
|
|
1053
1035
|
let morphReject = null;
|
|
1054
1036
|
let morphDurationMs = DEFAULT_MORPH_DURATION_MS;
|
|
@@ -1066,7 +1048,7 @@ function createSVGRenderer(options) {
|
|
|
1066
1048
|
skeletonPathA.setAttribute("visibility", "visible");
|
|
1067
1049
|
skeletonPathA.setAttribute(
|
|
1068
1050
|
"stroke-opacity",
|
|
1069
|
-
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY)
|
|
1051
|
+
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY)
|
|
1070
1052
|
);
|
|
1071
1053
|
}
|
|
1072
1054
|
if (morphPathBBuilt) {
|
|
@@ -1109,8 +1091,8 @@ function createSVGRenderer(options) {
|
|
|
1109
1091
|
animationId = requestAnimationFrame(loop);
|
|
1110
1092
|
}
|
|
1111
1093
|
}
|
|
1112
|
-
if (options.
|
|
1113
|
-
engine.seek(options.
|
|
1094
|
+
if (options.initialPhase !== void 0) {
|
|
1095
|
+
engine.seek(options.initialPhase);
|
|
1114
1096
|
}
|
|
1115
1097
|
renderFrame(0);
|
|
1116
1098
|
const shouldAutoStart = options.autoStart !== false;
|
|
@@ -1220,7 +1202,7 @@ function createSVGRenderer(options) {
|
|
|
1220
1202
|
if (partial.trailColor !== void 0 || partial.trailStyle !== void 0) {
|
|
1221
1203
|
warnIfTrailColorMismatch(trailColor, trailStyle);
|
|
1222
1204
|
}
|
|
1223
|
-
}
|
|
1205
|
+
}
|
|
1224
1206
|
};
|
|
1225
1207
|
const pauseOnHidden = options.pauseOnHidden !== false;
|
|
1226
1208
|
function handleVisibilityChange() {
|
|
@@ -1258,15 +1240,9 @@ var PERIOD = 2 * Math.PI;
|
|
|
1258
1240
|
function catmullRom1D(p0, p1, p2, p3, u) {
|
|
1259
1241
|
const u2 = u * u;
|
|
1260
1242
|
const u3 = u2 * u;
|
|
1261
|
-
return (
|
|
1262
|
-
0.5 *
|
|
1263
|
-
(2 * p1 +
|
|
1264
|
-
(-p0 + p2) * u +
|
|
1265
|
-
(2 * p0 - 5 * p1 + 4 * p2 - p3) * u2 +
|
|
1266
|
-
(-p0 + 3 * p1 - 3 * p2 + p3) * u3)
|
|
1267
|
-
);
|
|
1243
|
+
return 0.5 * (2 * p1 + (-p0 + p2) * u + (2 * p0 - 5 * p1 + 4 * p2 - p3) * u2 + (-p0 + 3 * p1 - 3 * p2 + p3) * u3);
|
|
1268
1244
|
}
|
|
1269
|
-
function evaluateCatmullRom(points2,
|
|
1245
|
+
function evaluateCatmullRom(points2, phase) {
|
|
1270
1246
|
const N = points2.length;
|
|
1271
1247
|
if (N === 0) {
|
|
1272
1248
|
return { x: 0, y: 0 };
|
|
@@ -1274,13 +1250,13 @@ function evaluateCatmullRom(points2, t) {
|
|
|
1274
1250
|
if (N === 1) {
|
|
1275
1251
|
return { x: points2[0][0], y: points2[0][1] };
|
|
1276
1252
|
}
|
|
1277
|
-
|
|
1253
|
+
phase = (phase % PERIOD + PERIOD) % PERIOD;
|
|
1278
1254
|
const segmentSize = PERIOD / N;
|
|
1279
|
-
let i = Math.floor(
|
|
1255
|
+
let i = Math.floor(phase / segmentSize);
|
|
1280
1256
|
if (i >= N) {
|
|
1281
1257
|
i = N - 1;
|
|
1282
1258
|
}
|
|
1283
|
-
let u = (
|
|
1259
|
+
let u = (phase - i * segmentSize) / segmentSize;
|
|
1284
1260
|
u = Math.max(0, Math.min(1, u));
|
|
1285
1261
|
const p0 = points2[(i - 1 + N) % N];
|
|
1286
1262
|
const p1 = points2[i];
|
|
@@ -1288,7 +1264,7 @@ function evaluateCatmullRom(points2, t) {
|
|
|
1288
1264
|
const p3 = points2[(i + 2) % N];
|
|
1289
1265
|
return {
|
|
1290
1266
|
x: catmullRom1D(p0[0], p1[0], p2[0], p3[0], u),
|
|
1291
|
-
y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u)
|
|
1267
|
+
y: catmullRom1D(p0[1], p1[1], p2[1], p3[1], u)
|
|
1292
1268
|
};
|
|
1293
1269
|
}
|
|
1294
1270
|
function drawCurve(points2, opts) {
|
|
@@ -1298,20 +1274,20 @@ function drawCurve(points2, opts) {
|
|
|
1298
1274
|
const first = points2[0];
|
|
1299
1275
|
if (points2.every((p) => p[0] === first[0] && p[1] === first[1])) {
|
|
1300
1276
|
console.warn(
|
|
1301
|
-
"[sarmal].drawCurve: all control points are identical. The curve will be a single point."
|
|
1277
|
+
"[sarmal].drawCurve: all control points are identical. The curve will be a single point."
|
|
1302
1278
|
);
|
|
1303
1279
|
}
|
|
1304
1280
|
const maxAbs = points2.reduce((m, p) => Math.max(m, Math.abs(p[0]), Math.abs(p[1])), 0);
|
|
1305
1281
|
if (maxAbs > 2) {
|
|
1306
1282
|
console.warn(
|
|
1307
|
-
`[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1]
|
|
1283
|
+
`[sarmal].drawCurve: control points extend to \xB1${maxAbs.toFixed(1)}, which may render off-screen. Coordinates should be in [-1, 1].`
|
|
1308
1284
|
);
|
|
1309
1285
|
}
|
|
1310
1286
|
const pts = points2.map(([x, y]) => [x, y]);
|
|
1311
1287
|
return {
|
|
1312
1288
|
name: opts?.name ?? "drawn",
|
|
1313
|
-
fn: (
|
|
1314
|
-
period: PERIOD
|
|
1289
|
+
fn: (phase) => evaluateCatmullRom(pts, phase),
|
|
1290
|
+
period: PERIOD
|
|
1315
1291
|
};
|
|
1316
1292
|
}
|
|
1317
1293
|
|
|
@@ -1337,74 +1313,74 @@ var points = [
|
|
|
1337
1313
|
[-0.69, -0.84],
|
|
1338
1314
|
[-0.87, -0.66],
|
|
1339
1315
|
[-0.9, -0.47],
|
|
1340
|
-
[-0.76, -0.35]
|
|
1316
|
+
[-0.76, -0.35]
|
|
1341
1317
|
];
|
|
1342
1318
|
var artemis2 = {
|
|
1343
1319
|
...drawCurve(points, { name: "Artemis II" }),
|
|
1344
|
-
speed: 0.7
|
|
1320
|
+
speed: 0.7
|
|
1345
1321
|
};
|
|
1346
1322
|
|
|
1347
1323
|
// src/curves/astroid.ts
|
|
1348
1324
|
var TWO_PI2 = Math.PI * 2;
|
|
1349
|
-
function astroidFn(
|
|
1350
|
-
const c = Math.cos(
|
|
1351
|
-
const s = Math.sin(
|
|
1325
|
+
function astroidFn(phase, _elapsed, _params) {
|
|
1326
|
+
const c = Math.cos(phase);
|
|
1327
|
+
const s = Math.sin(phase);
|
|
1352
1328
|
return {
|
|
1353
1329
|
x: c * c * c,
|
|
1354
|
-
y: s * s * s
|
|
1330
|
+
y: s * s * s
|
|
1355
1331
|
};
|
|
1356
1332
|
}
|
|
1357
1333
|
var astroid = {
|
|
1358
1334
|
name: "Astroid",
|
|
1359
1335
|
fn: astroidFn,
|
|
1360
1336
|
period: TWO_PI2,
|
|
1361
|
-
speed: 1.1
|
|
1337
|
+
speed: 1.1
|
|
1362
1338
|
};
|
|
1363
1339
|
|
|
1364
1340
|
// src/curves/deltoid.ts
|
|
1365
1341
|
var TWO_PI3 = Math.PI * 2;
|
|
1366
|
-
function deltoidFn(
|
|
1342
|
+
function deltoidFn(phase, _elapsed, _params) {
|
|
1367
1343
|
return {
|
|
1368
|
-
x: 2 * Math.cos(
|
|
1369
|
-
y: 2 * Math.sin(
|
|
1344
|
+
x: 2 * Math.cos(phase) + Math.cos(2 * phase),
|
|
1345
|
+
y: 2 * Math.sin(phase) - Math.sin(2 * phase)
|
|
1370
1346
|
};
|
|
1371
1347
|
}
|
|
1372
1348
|
var deltoid = {
|
|
1373
1349
|
name: "Deltoid",
|
|
1374
1350
|
fn: deltoidFn,
|
|
1375
1351
|
period: TWO_PI3,
|
|
1376
|
-
speed: 0.9
|
|
1352
|
+
speed: 0.9
|
|
1377
1353
|
};
|
|
1378
1354
|
|
|
1379
1355
|
// src/curves/epicycloid3.ts
|
|
1380
1356
|
var TWO_PI4 = Math.PI * 2;
|
|
1381
|
-
function epicycloid3Fn(
|
|
1357
|
+
function epicycloid3Fn(phase, _elapsed, _params) {
|
|
1382
1358
|
return {
|
|
1383
|
-
x: 4 * Math.cos(
|
|
1384
|
-
y: 4 * Math.sin(
|
|
1359
|
+
x: 4 * Math.cos(phase) - Math.cos(4 * phase),
|
|
1360
|
+
y: 4 * Math.sin(phase) - Math.sin(4 * phase)
|
|
1385
1361
|
};
|
|
1386
1362
|
}
|
|
1387
1363
|
var epicycloid3 = {
|
|
1388
1364
|
name: "Epicycloid (n=3)",
|
|
1389
1365
|
fn: epicycloid3Fn,
|
|
1390
1366
|
period: TWO_PI4,
|
|
1391
|
-
speed: 0.75
|
|
1367
|
+
speed: 0.75
|
|
1392
1368
|
};
|
|
1393
1369
|
|
|
1394
1370
|
// src/curves/epitrochoid7.ts
|
|
1395
1371
|
var TWO_PI5 = Math.PI * 2;
|
|
1396
|
-
function epitrochoid7Fn(
|
|
1397
|
-
const d = 1 + 0.55 * Math.sin(
|
|
1372
|
+
function epitrochoid7Fn(phase, _elapsed, _params) {
|
|
1373
|
+
const d = 1 + 0.55 * Math.sin(phase * 0.5);
|
|
1398
1374
|
return {
|
|
1399
|
-
x: 7 * Math.cos(
|
|
1400
|
-
y: 7 * Math.sin(
|
|
1375
|
+
x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
|
|
1376
|
+
y: 7 * Math.sin(phase) - d * Math.sin(7 * phase)
|
|
1401
1377
|
};
|
|
1402
1378
|
}
|
|
1403
|
-
function epitrochoid7SkeletonFn(
|
|
1379
|
+
function epitrochoid7SkeletonFn(phase) {
|
|
1404
1380
|
const d = 1.275;
|
|
1405
1381
|
return {
|
|
1406
|
-
x: 7 * Math.cos(
|
|
1407
|
-
y: 7 * Math.sin(
|
|
1382
|
+
x: 7 * Math.cos(phase) - d * Math.cos(7 * phase),
|
|
1383
|
+
y: 7 * Math.sin(phase) - d * Math.sin(7 * phase)
|
|
1408
1384
|
};
|
|
1409
1385
|
}
|
|
1410
1386
|
var epitrochoid7 = {
|
|
@@ -1412,16 +1388,16 @@ var epitrochoid7 = {
|
|
|
1412
1388
|
fn: epitrochoid7Fn,
|
|
1413
1389
|
period: TWO_PI5,
|
|
1414
1390
|
speed: 1.4,
|
|
1415
|
-
skeletonFn: epitrochoid7SkeletonFn
|
|
1391
|
+
skeletonFn: epitrochoid7SkeletonFn
|
|
1416
1392
|
};
|
|
1417
1393
|
|
|
1418
1394
|
// src/curves/lissajous32.ts
|
|
1419
1395
|
var TWO_PI6 = Math.PI * 2;
|
|
1420
|
-
function lissajous32Fn(
|
|
1421
|
-
const phi =
|
|
1396
|
+
function lissajous32Fn(phase, elapsed, _params) {
|
|
1397
|
+
const phi = elapsed * 0.45;
|
|
1422
1398
|
return {
|
|
1423
|
-
x: Math.sin(3 *
|
|
1424
|
-
y: Math.sin(2 *
|
|
1399
|
+
x: Math.sin(3 * phase + phi),
|
|
1400
|
+
y: Math.sin(2 * phase)
|
|
1425
1401
|
};
|
|
1426
1402
|
}
|
|
1427
1403
|
var lissajous32 = {
|
|
@@ -1429,16 +1405,16 @@ var lissajous32 = {
|
|
|
1429
1405
|
fn: lissajous32Fn,
|
|
1430
1406
|
period: TWO_PI6,
|
|
1431
1407
|
speed: 2,
|
|
1432
|
-
skeleton: "live"
|
|
1408
|
+
skeleton: "live"
|
|
1433
1409
|
};
|
|
1434
1410
|
|
|
1435
1411
|
// src/curves/lissajous43.ts
|
|
1436
1412
|
var TWO_PI7 = Math.PI * 2;
|
|
1437
|
-
function lissajous43Fn(
|
|
1438
|
-
const phi =
|
|
1413
|
+
function lissajous43Fn(phase, elapsed, _params) {
|
|
1414
|
+
const phi = elapsed * 0.38;
|
|
1439
1415
|
return {
|
|
1440
|
-
x: Math.sin(4 *
|
|
1441
|
-
y: Math.sin(3 *
|
|
1416
|
+
x: Math.sin(4 * phase + phi),
|
|
1417
|
+
y: Math.sin(3 * phase)
|
|
1442
1418
|
};
|
|
1443
1419
|
}
|
|
1444
1420
|
var lissajous43 = {
|
|
@@ -1446,18 +1422,17 @@ var lissajous43 = {
|
|
|
1446
1422
|
fn: lissajous43Fn,
|
|
1447
1423
|
period: TWO_PI7,
|
|
1448
1424
|
speed: 1.8,
|
|
1449
|
-
skeleton: "live"
|
|
1425
|
+
skeleton: "live"
|
|
1450
1426
|
};
|
|
1451
1427
|
|
|
1452
1428
|
// src/curves/lame.ts
|
|
1453
1429
|
var TWO_PI8 = Math.PI * 2;
|
|
1454
|
-
function lameFn(
|
|
1455
|
-
const p = 1.75 + 1.25 * Math.sin(
|
|
1456
|
-
const c = Math.cos(
|
|
1457
|
-
s = Math.sin(t);
|
|
1430
|
+
function lameFn(phase, elapsed, _params) {
|
|
1431
|
+
const p = 1.75 + 1.25 * Math.sin(elapsed * 0.48);
|
|
1432
|
+
const c = Math.cos(phase), s = Math.sin(phase);
|
|
1458
1433
|
return {
|
|
1459
1434
|
x: Math.sign(c) * Math.pow(Math.abs(c), p),
|
|
1460
|
-
y: Math.sign(s) * Math.pow(Math.abs(s), p)
|
|
1435
|
+
y: Math.sign(s) * Math.pow(Math.abs(s), p)
|
|
1461
1436
|
};
|
|
1462
1437
|
}
|
|
1463
1438
|
var lame = {
|
|
@@ -1465,112 +1440,103 @@ var lame = {
|
|
|
1465
1440
|
fn: lameFn,
|
|
1466
1441
|
period: TWO_PI8,
|
|
1467
1442
|
speed: 1,
|
|
1468
|
-
skeleton: "live"
|
|
1443
|
+
skeleton: "live"
|
|
1469
1444
|
};
|
|
1470
1445
|
|
|
1471
1446
|
// src/curves/rose3.ts
|
|
1472
1447
|
var TWO_PI9 = Math.PI * 2;
|
|
1473
|
-
function rose3Fn(
|
|
1474
|
-
const r = Math.cos(3 *
|
|
1448
|
+
function rose3Fn(phase, _elapsed, _params) {
|
|
1449
|
+
const r = Math.cos(3 * phase);
|
|
1475
1450
|
return {
|
|
1476
|
-
x: r * Math.cos(
|
|
1477
|
-
y: r * Math.sin(
|
|
1451
|
+
x: r * Math.cos(phase),
|
|
1452
|
+
y: r * Math.sin(phase)
|
|
1478
1453
|
};
|
|
1479
1454
|
}
|
|
1480
1455
|
var rose3 = {
|
|
1481
1456
|
name: "Rose (n=3)",
|
|
1482
1457
|
fn: rose3Fn,
|
|
1483
1458
|
period: TWO_PI9,
|
|
1484
|
-
speed: 1.15
|
|
1459
|
+
speed: 1.15
|
|
1485
1460
|
};
|
|
1486
1461
|
|
|
1487
1462
|
// src/curves/rose5.ts
|
|
1488
1463
|
var TWO_PI10 = Math.PI * 2;
|
|
1489
|
-
function rose5Fn(
|
|
1490
|
-
const r = Math.cos(5 *
|
|
1464
|
+
function rose5Fn(phase, _elapsed, _params) {
|
|
1465
|
+
const r = Math.cos(5 * phase);
|
|
1491
1466
|
return {
|
|
1492
|
-
x: r * Math.cos(
|
|
1493
|
-
y: r * Math.sin(
|
|
1467
|
+
x: r * Math.cos(phase),
|
|
1468
|
+
y: r * Math.sin(phase)
|
|
1494
1469
|
};
|
|
1495
1470
|
}
|
|
1496
1471
|
var rose5 = {
|
|
1497
1472
|
name: "Rose (n=5)",
|
|
1498
1473
|
fn: rose5Fn,
|
|
1499
1474
|
period: TWO_PI10,
|
|
1500
|
-
speed: 1
|
|
1475
|
+
speed: 1
|
|
1501
1476
|
};
|
|
1502
1477
|
|
|
1503
1478
|
// src/curves/rose52.ts
|
|
1504
1479
|
var FOUR_PI = Math.PI * 4;
|
|
1505
|
-
function rose52Fn(
|
|
1506
|
-
const r = Math.cos(
|
|
1480
|
+
function rose52Fn(phase, _elapsed, _params) {
|
|
1481
|
+
const r = Math.cos(5 / 2 * phase);
|
|
1507
1482
|
return {
|
|
1508
|
-
x: r * Math.cos(
|
|
1509
|
-
y: r * Math.sin(
|
|
1483
|
+
x: r * Math.cos(phase),
|
|
1484
|
+
y: r * Math.sin(phase)
|
|
1510
1485
|
};
|
|
1511
1486
|
}
|
|
1512
1487
|
var rose52 = {
|
|
1513
1488
|
name: "Rose (n=5/2)",
|
|
1514
1489
|
fn: rose52Fn,
|
|
1515
1490
|
period: FOUR_PI,
|
|
1516
|
-
speed: 0.8
|
|
1491
|
+
speed: 0.8
|
|
1517
1492
|
};
|
|
1518
1493
|
|
|
1519
1494
|
// src/curves/star.ts
|
|
1520
1495
|
var TWO_PI11 = Math.PI * 2;
|
|
1521
|
-
function starFn(
|
|
1522
|
-
const r =
|
|
1523
|
-
Math.abs(Math.cos((5 / 2) * t)) +
|
|
1524
|
-
0.35 * Math.abs(Math.cos((15 / 2) * t)) +
|
|
1525
|
-
0.15 * Math.abs(Math.cos((25 / 2) * t));
|
|
1496
|
+
function starFn(phase, _elapsed, _params) {
|
|
1497
|
+
const r = Math.abs(Math.cos(5 / 2 * phase)) + 0.35 * Math.abs(Math.cos(15 / 2 * phase)) + 0.15 * Math.abs(Math.cos(25 / 2 * phase));
|
|
1526
1498
|
return {
|
|
1527
|
-
x: r * Math.cos(
|
|
1528
|
-
y: r * Math.sin(
|
|
1499
|
+
x: r * Math.cos(phase),
|
|
1500
|
+
y: r * Math.sin(phase)
|
|
1529
1501
|
};
|
|
1530
1502
|
}
|
|
1531
1503
|
var star = {
|
|
1532
1504
|
name: "Star",
|
|
1533
1505
|
fn: starFn,
|
|
1534
1506
|
period: TWO_PI11,
|
|
1535
|
-
speed: 1
|
|
1507
|
+
speed: 1
|
|
1536
1508
|
};
|
|
1537
1509
|
|
|
1538
1510
|
// src/curves/star4.ts
|
|
1539
1511
|
var TWO_PI12 = Math.PI * 2;
|
|
1540
|
-
function star4Fn(
|
|
1541
|
-
const r =
|
|
1542
|
-
Math.abs(Math.cos(2 * t)) +
|
|
1543
|
-
0.35 * Math.abs(Math.cos(6 * t)) +
|
|
1544
|
-
0.15 * Math.abs(Math.cos(10 * t));
|
|
1512
|
+
function star4Fn(phase, _elapsed, _params) {
|
|
1513
|
+
const r = Math.abs(Math.cos(2 * phase)) + 0.35 * Math.abs(Math.cos(6 * phase)) + 0.15 * Math.abs(Math.cos(10 * phase));
|
|
1545
1514
|
return {
|
|
1546
|
-
x: r * Math.cos(
|
|
1547
|
-
y: r * Math.sin(
|
|
1515
|
+
x: r * Math.cos(phase),
|
|
1516
|
+
y: r * Math.sin(phase)
|
|
1548
1517
|
};
|
|
1549
1518
|
}
|
|
1550
1519
|
var star4 = {
|
|
1551
1520
|
name: "Star (4-arm)",
|
|
1552
1521
|
fn: star4Fn,
|
|
1553
1522
|
period: TWO_PI12,
|
|
1554
|
-
speed: 1
|
|
1523
|
+
speed: 1
|
|
1555
1524
|
};
|
|
1556
1525
|
|
|
1557
1526
|
// src/curves/star7.ts
|
|
1558
1527
|
var TWO_PI13 = Math.PI * 2;
|
|
1559
|
-
function star7Fn(
|
|
1560
|
-
const r =
|
|
1561
|
-
Math.abs(Math.cos((7 / 2) * t)) +
|
|
1562
|
-
0.35 * Math.abs(Math.cos((21 / 2) * t)) +
|
|
1563
|
-
0.15 * Math.abs(Math.cos((35 / 2) * t));
|
|
1528
|
+
function star7Fn(phase, _elapsed, _params) {
|
|
1529
|
+
const r = Math.abs(Math.cos(7 / 2 * phase)) + 0.35 * Math.abs(Math.cos(21 / 2 * phase)) + 0.15 * Math.abs(Math.cos(35 / 2 * phase));
|
|
1564
1530
|
return {
|
|
1565
|
-
x: r * Math.cos(
|
|
1566
|
-
y: r * Math.sin(
|
|
1531
|
+
x: r * Math.cos(phase),
|
|
1532
|
+
y: r * Math.sin(phase)
|
|
1567
1533
|
};
|
|
1568
1534
|
}
|
|
1569
1535
|
var star7 = {
|
|
1570
1536
|
name: "Star (7-arm)",
|
|
1571
1537
|
fn: star7Fn,
|
|
1572
1538
|
period: TWO_PI13,
|
|
1573
|
-
speed: 1
|
|
1539
|
+
speed: 1
|
|
1574
1540
|
};
|
|
1575
1541
|
|
|
1576
1542
|
// src/curves/index.ts
|
|
@@ -1588,7 +1554,7 @@ var curves = {
|
|
|
1588
1554
|
lissajous32,
|
|
1589
1555
|
lissajous43,
|
|
1590
1556
|
epicycloid3,
|
|
1591
|
-
lame
|
|
1557
|
+
lame
|
|
1592
1558
|
};
|
|
1593
1559
|
|
|
1594
1560
|
// src/index.ts
|
|
@@ -1619,4 +1585,4 @@ exports.palettes = palettes;
|
|
|
1619
1585
|
exports.rose3 = rose3;
|
|
1620
1586
|
exports.rose5 = rose5;
|
|
1621
1587
|
//# sourceMappingURL=index.cjs.map
|
|
1622
|
-
//# sourceMappingURL=index.cjs.map
|
|
1588
|
+
//# sourceMappingURL=index.cjs.map
|