@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.
- package/dist/auto-init.cjs +84 -89
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.d.cts +2 -1
- package/dist/auto-init.d.ts +2 -1
- package/dist/auto-init.js +83 -88
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.cjs +7 -10
- package/dist/curves/artemis2.d.cts +1 -1
- package/dist/curves/artemis2.d.ts +1 -1
- package/dist/curves/artemis2.js +6 -9
- 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 +28 -32
- package/dist/curves/index.d.cts +21 -21
- package/dist/curves/index.d.ts +21 -21
- package/dist/curves/index.js +28 -44
- package/dist/curves/lame.cjs +5 -6
- package/dist/curves/lame.d.cts +1 -1
- package/dist/curves/lame.d.ts +1 -1
- package/dist/curves/lame.js +4 -5
- 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/index.cjs +98 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -58
- package/dist/index.d.ts +23 -58
- package/dist/index.js +98 -107
- package/dist/index.js.map +1 -1
- package/dist/types-BQosOzlf.d.cts +276 -0
- package/dist/types-BQosOzlf.d.ts +276 -0
- package/package.json +1 -1
- package/dist/types-BW0bpL1Z.d.cts +0 -290
- package/dist/types-BW0bpL1Z.d.ts +0 -290
package/dist/auto-init.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,13 +63,13 @@ 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);
|
|
@@ -110,7 +110,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
110
110
|
actualTime += deltaTime;
|
|
111
111
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
112
112
|
const a = curve.fn(t, actualTime, EMPTY_PARAMS);
|
|
113
|
-
const tB = _morphStrategy === "normalized" ?
|
|
113
|
+
const tB = _morphStrategy === "normalized" ? t / curve.period * morphCurveB.period : t;
|
|
114
114
|
const b = morphCurveB.fn(tB, actualTime, EMPTY_PARAMS);
|
|
115
115
|
trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
|
|
116
116
|
} else {
|
|
@@ -134,14 +134,14 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
134
134
|
trail.clear();
|
|
135
135
|
},
|
|
136
136
|
jump(newT, { clearTrail = false } = {}) {
|
|
137
|
-
t = (
|
|
137
|
+
t = (newT % curve.period + curve.period) % curve.period;
|
|
138
138
|
if (clearTrail) {
|
|
139
139
|
trail.clear();
|
|
140
140
|
}
|
|
141
141
|
},
|
|
142
142
|
seek(targetT, { wrap = false, step = curve.period / trailLength } = {}) {
|
|
143
143
|
const advance = curve.speed * step;
|
|
144
|
-
const target = (
|
|
144
|
+
const target = (targetT % curve.period + curve.period) % curve.period;
|
|
145
145
|
const targetTime = target / curve.speed;
|
|
146
146
|
t = target;
|
|
147
147
|
actualTime = targetTime;
|
|
@@ -150,7 +150,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
150
150
|
const count = wrap ? trailLength : Math.min(trailLength, pointsFromStart);
|
|
151
151
|
for (let i = count - 1; i >= 0; i--) {
|
|
152
152
|
const sampleT = target - i * advance;
|
|
153
|
-
const wrappedT = (
|
|
153
|
+
const wrappedT = (sampleT % curve.period + curve.period) % curve.period;
|
|
154
154
|
const time = targetTime - i * step;
|
|
155
155
|
const point = curve.fn(wrappedT, time, EMPTY_PARAMS);
|
|
156
156
|
trail.push(point.x, point.y);
|
|
@@ -167,16 +167,13 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
167
167
|
...frozenB,
|
|
168
168
|
fn: (sampleT, time, params) => {
|
|
169
169
|
const a = frozenA.fn(sampleT, time, params);
|
|
170
|
-
const tB =
|
|
171
|
-
frozenStrategy === "normalized"
|
|
172
|
-
? (sampleT / frozenA.period) * frozenB.period
|
|
173
|
-
: sampleT;
|
|
170
|
+
const tB = frozenStrategy === "normalized" ? sampleT / frozenA.period * frozenB.period : sampleT;
|
|
174
171
|
const b = frozenB.fn(tB, time, params);
|
|
175
172
|
return {
|
|
176
173
|
x: a.x + (b.x - a.x) * frozenAlpha,
|
|
177
|
-
y: a.y + (b.y - a.y) * frozenAlpha
|
|
174
|
+
y: a.y + (b.y - a.y) * frozenAlpha
|
|
178
175
|
};
|
|
179
|
-
}
|
|
176
|
+
}
|
|
180
177
|
};
|
|
181
178
|
}
|
|
182
179
|
_morphStrategy = strategy;
|
|
@@ -189,7 +186,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
189
186
|
completeMorph() {
|
|
190
187
|
if (morphCurveB !== null) {
|
|
191
188
|
if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
|
|
192
|
-
t =
|
|
189
|
+
t = t / curve.period * morphCurveB.period;
|
|
193
190
|
}
|
|
194
191
|
curve = morphCurveB;
|
|
195
192
|
}
|
|
@@ -201,22 +198,19 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
201
198
|
const points = new Array(steps);
|
|
202
199
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
203
200
|
for (let i = 0; i < steps; i++) {
|
|
204
|
-
const sampleT =
|
|
201
|
+
const sampleT = i / (steps - 1) * curve.period;
|
|
205
202
|
const a = sampleSkeleton(curve, sampleT);
|
|
206
|
-
const tB =
|
|
207
|
-
_morphStrategy === "normalized"
|
|
208
|
-
? (sampleT / curve.period) * morphCurveB.period
|
|
209
|
-
: sampleT;
|
|
203
|
+
const tB = _morphStrategy === "normalized" ? sampleT / curve.period * morphCurveB.period : sampleT;
|
|
210
204
|
const b = sampleSkeleton(morphCurveB, tB);
|
|
211
205
|
points[i] = {
|
|
212
206
|
x: a.x + (b.x - a.x) * _morphAlpha,
|
|
213
|
-
y: a.y + (b.y - a.y) * _morphAlpha
|
|
207
|
+
y: a.y + (b.y - a.y) * _morphAlpha
|
|
214
208
|
};
|
|
215
209
|
}
|
|
216
210
|
return points;
|
|
217
211
|
}
|
|
218
212
|
for (let i = 0; i < steps; i++) {
|
|
219
|
-
const sampleT =
|
|
213
|
+
const sampleT = i / (steps - 1) * curve.period;
|
|
220
214
|
points[i] = sampleSkeleton(curve, sampleT);
|
|
221
215
|
}
|
|
222
216
|
return points;
|
|
@@ -258,7 +252,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
258
252
|
_speedTransition.reject(new Error("Speed transition cancelled"));
|
|
259
253
|
_speedTransition = null;
|
|
260
254
|
}
|
|
261
|
-
}
|
|
255
|
+
}
|
|
262
256
|
};
|
|
263
257
|
}
|
|
264
258
|
|
|
@@ -321,16 +315,13 @@ function computeTrailQuad(trail, i, trailCount, toX, toY) {
|
|
|
321
315
|
r1x: nx - n1.x * w1,
|
|
322
316
|
r1y: ny - n1.y * w1,
|
|
323
317
|
opacity,
|
|
324
|
-
progress
|
|
318
|
+
progress
|
|
325
319
|
};
|
|
326
320
|
}
|
|
327
321
|
function computeBoundaries(pts, logicalWidth, logicalHeight) {
|
|
328
322
|
if (pts.length === 0) return null;
|
|
329
323
|
const first = pts[0];
|
|
330
|
-
let minX = first.x,
|
|
331
|
-
maxX = first.x,
|
|
332
|
-
minY = first.y,
|
|
333
|
-
maxY = first.y;
|
|
324
|
+
let minX = first.x, maxX = first.x, minY = first.y, maxY = first.y;
|
|
334
325
|
for (const p of pts) {
|
|
335
326
|
if (p.x < minX) {
|
|
336
327
|
minX = p.x;
|
|
@@ -349,7 +340,7 @@ function computeBoundaries(pts, logicalWidth, logicalHeight) {
|
|
|
349
340
|
const h = maxY - minY;
|
|
350
341
|
if (w === 0 && h === 0) {
|
|
351
342
|
throw new Error(
|
|
352
|
-
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
343
|
+
"[sarmal] Degenerate curve: all skeleton points are identical. Check that your curve fn returns distinct points for different values of t."
|
|
353
344
|
);
|
|
354
345
|
}
|
|
355
346
|
const scaleXProportional = logicalWidth / (w * (1 + FIT_PADDING * 2));
|
|
@@ -360,12 +351,12 @@ function computeBoundaries(pts, logicalWidth, logicalHeight) {
|
|
|
360
351
|
scaleXProportional,
|
|
361
352
|
scaleYProportional,
|
|
362
353
|
scaleXMinPadding,
|
|
363
|
-
scaleYMinPadding
|
|
354
|
+
scaleYMinPadding
|
|
364
355
|
);
|
|
365
356
|
return {
|
|
366
357
|
scale,
|
|
367
358
|
offsetX: (logicalWidth - w * scale) / 2 - minX * scale,
|
|
368
|
-
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
359
|
+
offsetY: (logicalHeight - h * scale) / 2 - minY * scale
|
|
369
360
|
};
|
|
370
361
|
}
|
|
371
362
|
function enginePassthroughs(engine) {
|
|
@@ -375,19 +366,16 @@ function enginePassthroughs(engine) {
|
|
|
375
366
|
setSpeed: engine.setSpeed,
|
|
376
367
|
getSpeed: engine.getSpeed,
|
|
377
368
|
resetSpeed: engine.resetSpeed,
|
|
378
|
-
setSpeedOver: engine.setSpeedOver
|
|
369
|
+
setSpeedOver: engine.setSpeedOver
|
|
379
370
|
};
|
|
380
371
|
}
|
|
381
|
-
|
|
382
|
-
// src/renderer.ts
|
|
383
|
-
var DEFAULT_SKELETON_COLOR = "#ffffff";
|
|
384
372
|
var GRADIENT = {
|
|
385
373
|
bard: ["#a855f7", "#3b82f6", "#14b8a6", "#ec4899"],
|
|
386
374
|
sunset: ["#f97316", "#dc2626", "#9333ea", "#f472b6"],
|
|
387
375
|
ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"],
|
|
388
376
|
ice: ["#1e3a8a", "#67e8f9"],
|
|
389
377
|
fire: ["#7f1d1d", "#fbbf24"],
|
|
390
|
-
forest: ["#14532d", "#86efac"]
|
|
378
|
+
forest: ["#14532d", "#86efac"]
|
|
391
379
|
};
|
|
392
380
|
var PRESETS = {
|
|
393
381
|
bard: GRADIENT.bard,
|
|
@@ -395,20 +383,24 @@ var PRESETS = {
|
|
|
395
383
|
ocean: GRADIENT.ocean,
|
|
396
384
|
ice: GRADIENT.ice,
|
|
397
385
|
fire: GRADIENT.fire,
|
|
398
|
-
forest: GRADIENT.forest
|
|
386
|
+
forest: GRADIENT.forest
|
|
399
387
|
};
|
|
400
388
|
function hexToRgb(hex) {
|
|
401
389
|
const n = parseInt(hex.slice(1), 16);
|
|
402
|
-
return { r: n >> 16, g:
|
|
390
|
+
return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
|
|
403
391
|
}
|
|
404
392
|
var lerpRgb = (a, b, t) => ({
|
|
405
393
|
r: Math.round(a.r + (b.r - a.r) * t),
|
|
406
394
|
g: Math.round(a.g + (b.g - a.g) * t),
|
|
407
|
-
b: Math.round(a.b + (b.b - a.b) * t)
|
|
395
|
+
b: Math.round(a.b + (b.b - a.b) * t)
|
|
408
396
|
});
|
|
409
397
|
function getPaletteColor(palette, position, timeOffset = 0) {
|
|
410
|
-
if (palette.length === 0)
|
|
411
|
-
|
|
398
|
+
if (palette.length === 0) {
|
|
399
|
+
return { r: 255, g: 255, b: 255 };
|
|
400
|
+
}
|
|
401
|
+
if (palette.length === 1) {
|
|
402
|
+
return hexToRgb(palette[0]);
|
|
403
|
+
}
|
|
412
404
|
const cyclePos = (position + timeOffset) % 1;
|
|
413
405
|
const scaled = cyclePos * palette.length;
|
|
414
406
|
const idx = Math.floor(scaled);
|
|
@@ -418,13 +410,20 @@ function getPaletteColor(palette, position, timeOffset = 0) {
|
|
|
418
410
|
return lerpRgb(c1, c2, t);
|
|
419
411
|
}
|
|
420
412
|
function resolvePalette(palette, trailStyle) {
|
|
421
|
-
if (Array.isArray(palette))
|
|
422
|
-
|
|
413
|
+
if (Array.isArray(palette)) {
|
|
414
|
+
return palette;
|
|
415
|
+
}
|
|
416
|
+
if (palette && palette in PRESETS) {
|
|
417
|
+
return PRESETS[palette];
|
|
418
|
+
}
|
|
423
419
|
return trailStyle === "gradient-animated" ? GRADIENT.bard : GRADIENT.ice;
|
|
424
420
|
}
|
|
421
|
+
|
|
422
|
+
// src/renderer.ts
|
|
423
|
+
var DEFAULT_SKELETON_COLOR = "#ffffff";
|
|
425
424
|
function hexToRgbComponents(hex) {
|
|
426
425
|
const n = parseInt(hex.slice(1), 16);
|
|
427
|
-
return `${n >> 16},${
|
|
426
|
+
return `${n >> 16},${n >> 8 & 255},${n & 255}`;
|
|
428
427
|
}
|
|
429
428
|
function applyDprSizing(target, logicalWidth, logicalHeight, dpr) {
|
|
430
429
|
target.style.width = `${logicalWidth}px`;
|
|
@@ -452,7 +451,7 @@ function createRenderer(options) {
|
|
|
452
451
|
const opts = {
|
|
453
452
|
skeletonColor: options.skeletonColor ?? DEFAULT_SKELETON_COLOR,
|
|
454
453
|
trailColor,
|
|
455
|
-
headColor: options.headColor ?? defaultHeadColor()
|
|
454
|
+
headColor: options.headColor ?? defaultHeadColor()
|
|
456
455
|
};
|
|
457
456
|
const trailRgb = hexToRgbComponents(opts.trailColor);
|
|
458
457
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
@@ -553,7 +552,7 @@ function createRenderer(options) {
|
|
|
553
552
|
i,
|
|
554
553
|
trailCount,
|
|
555
554
|
toX,
|
|
556
|
-
toY
|
|
555
|
+
toY
|
|
557
556
|
);
|
|
558
557
|
if (trailStyle === "default") {
|
|
559
558
|
ctx.fillStyle = `rgba(${trailRgb},${opacity})`;
|
|
@@ -577,8 +576,7 @@ function createRenderer(options) {
|
|
|
577
576
|
}
|
|
578
577
|
const x = head.x * scale + offsetX;
|
|
579
578
|
const y = head.y * scale + offsetY;
|
|
580
|
-
const r =
|
|
581
|
-
options.headRadius ?? Math.max(2, 3 * Math.sqrt(Math.min(logicalWidth, logicalHeight) / 160));
|
|
579
|
+
const r = options.headRadius ?? Math.max(2, 3 * Math.sqrt(Math.min(logicalWidth, logicalHeight) / 160));
|
|
582
580
|
ctx.fillStyle = opts.headColor;
|
|
583
581
|
ctx.beginPath();
|
|
584
582
|
ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
@@ -679,7 +677,7 @@ function createRenderer(options) {
|
|
|
679
677
|
return new Promise((resolve) => {
|
|
680
678
|
morphResolve = resolve;
|
|
681
679
|
});
|
|
682
|
-
}
|
|
680
|
+
}
|
|
683
681
|
};
|
|
684
682
|
if (shouldAutoStart) {
|
|
685
683
|
instance.play();
|
|
@@ -690,22 +688,19 @@ function createRenderer(options) {
|
|
|
690
688
|
// src/curves/artemis2.ts
|
|
691
689
|
var TWO_PI2 = Math.PI * 2;
|
|
692
690
|
function artemis2Fn(t, _time, _params) {
|
|
693
|
-
const a = 0.35,
|
|
694
|
-
|
|
695
|
-
ox = 0.175;
|
|
696
|
-
const s = Math.sin(t),
|
|
697
|
-
c = Math.cos(t);
|
|
691
|
+
const a = 0.35, b = 0.15, ox = 0.175;
|
|
692
|
+
const s = Math.sin(t), c = Math.cos(t);
|
|
698
693
|
const denom = 1 + s * s;
|
|
699
694
|
return {
|
|
700
|
-
x:
|
|
701
|
-
y:
|
|
695
|
+
x: c * (1 + a * c) / denom - ox,
|
|
696
|
+
y: s * c * (1 + b * c) / denom
|
|
702
697
|
};
|
|
703
698
|
}
|
|
704
699
|
var artemis2 = {
|
|
705
700
|
name: "Artemis II",
|
|
706
701
|
fn: artemis2Fn,
|
|
707
702
|
period: TWO_PI2,
|
|
708
|
-
speed: 0.7
|
|
703
|
+
speed: 0.7
|
|
709
704
|
};
|
|
710
705
|
|
|
711
706
|
// src/curves/astroid.ts
|
|
@@ -715,14 +710,14 @@ function astroidFn(t, _time, _params) {
|
|
|
715
710
|
const s = Math.sin(t);
|
|
716
711
|
return {
|
|
717
712
|
x: c * c * c,
|
|
718
|
-
y: s * s * s
|
|
713
|
+
y: s * s * s
|
|
719
714
|
};
|
|
720
715
|
}
|
|
721
716
|
var astroid = {
|
|
722
717
|
name: "Astroid",
|
|
723
718
|
fn: astroidFn,
|
|
724
719
|
period: TWO_PI3,
|
|
725
|
-
speed: 1.1
|
|
720
|
+
speed: 1.1
|
|
726
721
|
};
|
|
727
722
|
|
|
728
723
|
// src/curves/deltoid.ts
|
|
@@ -730,14 +725,14 @@ var TWO_PI4 = Math.PI * 2;
|
|
|
730
725
|
function deltoidFn(t, _time, _params) {
|
|
731
726
|
return {
|
|
732
727
|
x: 2 * Math.cos(t) + Math.cos(2 * t),
|
|
733
|
-
y: 2 * Math.sin(t) - Math.sin(2 * t)
|
|
728
|
+
y: 2 * Math.sin(t) - Math.sin(2 * t)
|
|
734
729
|
};
|
|
735
730
|
}
|
|
736
731
|
var deltoid = {
|
|
737
732
|
name: "Deltoid",
|
|
738
733
|
fn: deltoidFn,
|
|
739
734
|
period: TWO_PI4,
|
|
740
|
-
speed: 0.9
|
|
735
|
+
speed: 0.9
|
|
741
736
|
};
|
|
742
737
|
|
|
743
738
|
// src/curves/epicycloid3.ts
|
|
@@ -745,14 +740,14 @@ var TWO_PI5 = Math.PI * 2;
|
|
|
745
740
|
function epicycloid3Fn(t, _time, _params) {
|
|
746
741
|
return {
|
|
747
742
|
x: 4 * Math.cos(t) - Math.cos(4 * t),
|
|
748
|
-
y: 4 * Math.sin(t) - Math.sin(4 * t)
|
|
743
|
+
y: 4 * Math.sin(t) - Math.sin(4 * t)
|
|
749
744
|
};
|
|
750
745
|
}
|
|
751
746
|
var epicycloid3 = {
|
|
752
747
|
name: "Epicycloid (n=3)",
|
|
753
748
|
fn: epicycloid3Fn,
|
|
754
749
|
period: TWO_PI5,
|
|
755
|
-
speed: 0.75
|
|
750
|
+
speed: 0.75
|
|
756
751
|
};
|
|
757
752
|
|
|
758
753
|
// src/curves/epitrochoid7.ts
|
|
@@ -761,14 +756,14 @@ function epitrochoid7Fn(t, _time, _params) {
|
|
|
761
756
|
const d = 1 + 0.55 * Math.sin(t * 0.5);
|
|
762
757
|
return {
|
|
763
758
|
x: 7 * Math.cos(t) - d * Math.cos(7 * t),
|
|
764
|
-
y: 7 * Math.sin(t) - d * Math.sin(7 * t)
|
|
759
|
+
y: 7 * Math.sin(t) - d * Math.sin(7 * t)
|
|
765
760
|
};
|
|
766
761
|
}
|
|
767
762
|
function epitrochoid7SkeletonFn(t) {
|
|
768
763
|
const d = 1.275;
|
|
769
764
|
return {
|
|
770
765
|
x: 7 * Math.cos(t) - d * Math.cos(7 * t),
|
|
771
|
-
y: 7 * Math.sin(t) - d * Math.sin(7 * t)
|
|
766
|
+
y: 7 * Math.sin(t) - d * Math.sin(7 * t)
|
|
772
767
|
};
|
|
773
768
|
}
|
|
774
769
|
var epitrochoid7 = {
|
|
@@ -776,7 +771,7 @@ var epitrochoid7 = {
|
|
|
776
771
|
fn: epitrochoid7Fn,
|
|
777
772
|
period: TWO_PI6,
|
|
778
773
|
speed: 1.4,
|
|
779
|
-
skeletonFn: epitrochoid7SkeletonFn
|
|
774
|
+
skeletonFn: epitrochoid7SkeletonFn
|
|
780
775
|
};
|
|
781
776
|
|
|
782
777
|
// src/curves/lissajous32.ts
|
|
@@ -785,7 +780,7 @@ function lissajous32Fn(t, time, _params) {
|
|
|
785
780
|
const phi = time * 0.45;
|
|
786
781
|
return {
|
|
787
782
|
x: Math.sin(3 * t + phi),
|
|
788
|
-
y: Math.sin(2 * t)
|
|
783
|
+
y: Math.sin(2 * t)
|
|
789
784
|
};
|
|
790
785
|
}
|
|
791
786
|
var lissajous32 = {
|
|
@@ -793,7 +788,7 @@ var lissajous32 = {
|
|
|
793
788
|
fn: lissajous32Fn,
|
|
794
789
|
period: TWO_PI7,
|
|
795
790
|
speed: 2,
|
|
796
|
-
skeleton: "live"
|
|
791
|
+
skeleton: "live"
|
|
797
792
|
};
|
|
798
793
|
|
|
799
794
|
// src/curves/lissajous43.ts
|
|
@@ -802,7 +797,7 @@ function lissajous43Fn(t, time, _params) {
|
|
|
802
797
|
const phi = time * 0.38;
|
|
803
798
|
return {
|
|
804
799
|
x: Math.sin(4 * t + phi),
|
|
805
|
-
y: Math.sin(3 * t)
|
|
800
|
+
y: Math.sin(3 * t)
|
|
806
801
|
};
|
|
807
802
|
}
|
|
808
803
|
var lissajous43 = {
|
|
@@ -810,18 +805,17 @@ var lissajous43 = {
|
|
|
810
805
|
fn: lissajous43Fn,
|
|
811
806
|
period: TWO_PI8,
|
|
812
807
|
speed: 1.8,
|
|
813
|
-
skeleton: "live"
|
|
808
|
+
skeleton: "live"
|
|
814
809
|
};
|
|
815
810
|
|
|
816
811
|
// src/curves/lame.ts
|
|
817
812
|
var TWO_PI9 = Math.PI * 2;
|
|
818
813
|
function lameFn(t, time, _params) {
|
|
819
814
|
const p = 1.75 + 1.25 * Math.sin(time * 0.48);
|
|
820
|
-
const c = Math.cos(t),
|
|
821
|
-
s = Math.sin(t);
|
|
815
|
+
const c = Math.cos(t), s = Math.sin(t);
|
|
822
816
|
return {
|
|
823
817
|
x: Math.sign(c) * Math.pow(Math.abs(c), p),
|
|
824
|
-
y: Math.sign(s) * Math.pow(Math.abs(s), p)
|
|
818
|
+
y: Math.sign(s) * Math.pow(Math.abs(s), p)
|
|
825
819
|
};
|
|
826
820
|
}
|
|
827
821
|
var lame = {
|
|
@@ -829,7 +823,7 @@ var lame = {
|
|
|
829
823
|
fn: lameFn,
|
|
830
824
|
period: TWO_PI9,
|
|
831
825
|
speed: 1,
|
|
832
|
-
skeleton: "live"
|
|
826
|
+
skeleton: "live"
|
|
833
827
|
};
|
|
834
828
|
|
|
835
829
|
// src/curves/rose3.ts
|
|
@@ -838,14 +832,14 @@ function rose3Fn(t, _time, _params) {
|
|
|
838
832
|
const r = Math.cos(3 * t);
|
|
839
833
|
return {
|
|
840
834
|
x: r * Math.cos(t),
|
|
841
|
-
y: r * Math.sin(t)
|
|
835
|
+
y: r * Math.sin(t)
|
|
842
836
|
};
|
|
843
837
|
}
|
|
844
838
|
var rose3 = {
|
|
845
839
|
name: "Rose (n=3)",
|
|
846
840
|
fn: rose3Fn,
|
|
847
841
|
period: TWO_PI10,
|
|
848
|
-
speed: 1.15
|
|
842
|
+
speed: 1.15
|
|
849
843
|
};
|
|
850
844
|
|
|
851
845
|
// src/curves/rose5.ts
|
|
@@ -854,14 +848,14 @@ function rose5Fn(t, _time, _params) {
|
|
|
854
848
|
const r = Math.cos(5 * t);
|
|
855
849
|
return {
|
|
856
850
|
x: r * Math.cos(t),
|
|
857
|
-
y: r * Math.sin(t)
|
|
851
|
+
y: r * Math.sin(t)
|
|
858
852
|
};
|
|
859
853
|
}
|
|
860
854
|
var rose5 = {
|
|
861
855
|
name: "Rose (n=5)",
|
|
862
856
|
fn: rose5Fn,
|
|
863
857
|
period: TWO_PI11,
|
|
864
|
-
speed: 1
|
|
858
|
+
speed: 1
|
|
865
859
|
};
|
|
866
860
|
|
|
867
861
|
// src/curves/index.ts
|
|
@@ -875,7 +869,7 @@ var curves = {
|
|
|
875
869
|
lissajous32,
|
|
876
870
|
lissajous43,
|
|
877
871
|
epicycloid3,
|
|
878
|
-
lame
|
|
872
|
+
lame
|
|
879
873
|
};
|
|
880
874
|
|
|
881
875
|
// src/index.ts
|
|
@@ -892,7 +886,8 @@ function parsePalette(value) {
|
|
|
892
886
|
if (Array.isArray(parsed)) {
|
|
893
887
|
return parsed;
|
|
894
888
|
}
|
|
895
|
-
} catch {
|
|
889
|
+
} catch {
|
|
890
|
+
}
|
|
896
891
|
return value;
|
|
897
892
|
}
|
|
898
893
|
function init() {
|
|
@@ -907,15 +902,15 @@ function init() {
|
|
|
907
902
|
return console.error(`[sarmal] "${curveName}" is not a valid curve name`);
|
|
908
903
|
}
|
|
909
904
|
createSarmal(canvas, curveDef, {
|
|
910
|
-
...
|
|
911
|
-
...
|
|
912
|
-
...
|
|
913
|
-
...
|
|
914
|
-
...
|
|
915
|
-
...
|
|
916
|
-
trailStyle: canvas.dataset.trailStyle
|
|
917
|
-
}
|
|
918
|
-
...
|
|
905
|
+
...canvas.dataset.trailColor && { trailColor: canvas.dataset.trailColor },
|
|
906
|
+
...canvas.dataset.skeletonColor && { skeletonColor: canvas.dataset.skeletonColor },
|
|
907
|
+
...canvas.dataset.headColor && { headColor: canvas.dataset.headColor },
|
|
908
|
+
...canvas.dataset.headRadius && { headRadius: parseFloat(canvas.dataset.headRadius) },
|
|
909
|
+
...canvas.dataset.trailLength && { trailLength: parseInt(canvas.dataset.trailLength, 10) },
|
|
910
|
+
...canvas.dataset.trailStyle && {
|
|
911
|
+
trailStyle: canvas.dataset.trailStyle
|
|
912
|
+
},
|
|
913
|
+
...canvas.dataset.palette && { palette: parsePalette(canvas.dataset.palette) }
|
|
919
914
|
});
|
|
920
915
|
});
|
|
921
916
|
}
|
|
@@ -927,4 +922,4 @@ if (document.readyState === "loading") {
|
|
|
927
922
|
requestAnimationFrame(init);
|
|
928
923
|
}
|
|
929
924
|
//# sourceMappingURL=auto-init.cjs.map
|
|
930
|
-
//# sourceMappingURL=auto-init.cjs.map
|
|
925
|
+
//# sourceMappingURL=auto-init.cjs.map
|