@sarmal/core 0.9.0 → 0.9.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 +206 -139
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.d.cts +1 -2
- package/dist/auto-init.d.ts +1 -2
- package/dist/auto-init.js +205 -138
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.cjs +26 -0
- package/dist/curves/artemis2.cjs.map +1 -0
- package/dist/curves/artemis2.d.cts +9 -0
- package/dist/curves/artemis2.d.ts +9 -0
- package/dist/curves/artemis2.js +24 -0
- package/dist/curves/artemis2.js.map +1 -0
- package/dist/curves/astroid.cjs +22 -0
- package/dist/curves/astroid.cjs.map +1 -0
- package/dist/curves/astroid.d.cts +9 -0
- package/dist/curves/astroid.d.ts +9 -0
- package/dist/curves/astroid.js +20 -0
- package/dist/curves/astroid.js.map +1 -0
- package/dist/curves/deltoid.cjs +20 -0
- package/dist/curves/deltoid.cjs.map +1 -0
- package/dist/curves/deltoid.d.cts +9 -0
- package/dist/curves/deltoid.d.ts +9 -0
- package/dist/curves/deltoid.js +18 -0
- package/dist/curves/deltoid.js.map +1 -0
- package/dist/curves/epicycloid3.cjs +20 -0
- package/dist/curves/epicycloid3.cjs.map +1 -0
- package/dist/curves/epicycloid3.d.cts +9 -0
- package/dist/curves/epicycloid3.d.ts +9 -0
- package/dist/curves/epicycloid3.js +18 -0
- package/dist/curves/epicycloid3.js.map +1 -0
- package/dist/curves/epitrochoid7.cjs +29 -0
- package/dist/curves/epitrochoid7.cjs.map +1 -0
- package/dist/curves/epitrochoid7.d.cts +9 -0
- package/dist/curves/epitrochoid7.d.ts +9 -0
- package/dist/curves/epitrochoid7.js +27 -0
- package/dist/curves/epitrochoid7.js.map +1 -0
- package/dist/curves/index.cjs +206 -0
- package/dist/curves/index.cjs.map +1 -0
- package/dist/curves/index.d.cts +19 -0
- package/dist/curves/index.d.ts +19 -0
- package/dist/curves/index.js +206 -0
- package/dist/curves/index.js.map +1 -0
- package/dist/curves/lame.cjs +24 -0
- package/dist/curves/lame.cjs.map +1 -0
- package/dist/curves/lame.d.cts +9 -0
- package/dist/curves/lame.d.ts +9 -0
- package/dist/curves/lame.js +22 -0
- package/dist/curves/lame.js.map +1 -0
- package/dist/curves/lissajous32.cjs +22 -0
- package/dist/curves/lissajous32.cjs.map +1 -0
- package/dist/curves/lissajous32.d.cts +9 -0
- package/dist/curves/lissajous32.d.ts +9 -0
- package/dist/curves/lissajous32.js +20 -0
- package/dist/curves/lissajous32.js.map +1 -0
- package/dist/curves/lissajous43.cjs +22 -0
- package/dist/curves/lissajous43.cjs.map +1 -0
- package/dist/curves/lissajous43.d.cts +9 -0
- package/dist/curves/lissajous43.d.ts +9 -0
- package/dist/curves/lissajous43.js +20 -0
- package/dist/curves/lissajous43.js.map +1 -0
- package/dist/curves/rose3.cjs +21 -0
- package/dist/curves/rose3.cjs.map +1 -0
- package/dist/curves/rose3.d.cts +9 -0
- package/dist/curves/rose3.d.ts +9 -0
- package/dist/curves/rose3.js +19 -0
- package/dist/curves/rose3.js.map +1 -0
- package/dist/curves/rose5.cjs +21 -0
- package/dist/curves/rose5.cjs.map +1 -0
- package/dist/curves/rose5.d.cts +9 -0
- package/dist/curves/rose5.d.ts +9 -0
- package/dist/curves/rose5.js +19 -0
- package/dist/curves/rose5.js.map +1 -0
- package/dist/index.cjs +208 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -233
- package/dist/index.d.ts +64 -233
- package/dist/index.js +215 -139
- package/dist/index.js.map +1 -1
- package/dist/types-DX8VfIVK.d.cts +226 -0
- package/dist/types-DX8VfIVK.d.ts +226 -0
- package/package.json +11 -1
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ function resolveCurve(curveDef) {
|
|
|
49
49
|
period: curveDef.period ?? TWO_PI,
|
|
50
50
|
speed: curveDef.speed ?? 1,
|
|
51
51
|
skeleton: curveDef.skeleton,
|
|
52
|
-
skeletonFn: curveDef.skeletonFn
|
|
52
|
+
skeletonFn: curveDef.skeletonFn,
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
function createEngine(curveDef, trailLength = 120) {
|
|
@@ -75,7 +75,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
75
75
|
actualTime += deltaTime;
|
|
76
76
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
77
77
|
const a = curve.fn(t, actualTime, {});
|
|
78
|
-
const tB = _morphStrategy === "normalized" ? t / curve.period * morphCurveB.period : t;
|
|
78
|
+
const tB = _morphStrategy === "normalized" ? (t / curve.period) * morphCurveB.period : t;
|
|
79
79
|
const b = morphCurveB.fn(tB, actualTime, {});
|
|
80
80
|
trail.push(a.x + (b.x - a.x) * _morphAlpha, a.y + (b.y - a.y) * _morphAlpha);
|
|
81
81
|
} else {
|
|
@@ -99,14 +99,14 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
99
99
|
trail.clear();
|
|
100
100
|
},
|
|
101
101
|
seek(newT, { clearTrail = false } = {}) {
|
|
102
|
-
t = (newT % curve.period + curve.period) % curve.period;
|
|
102
|
+
t = ((newT % curve.period) + curve.period) % curve.period;
|
|
103
103
|
if (clearTrail) {
|
|
104
104
|
trail.clear();
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
seekWithTrail(targetT, { wrap = false, step = curve.period / trailLength } = {}) {
|
|
108
108
|
const advance = curve.speed * step;
|
|
109
|
-
const target = (targetT % curve.period + curve.period) % curve.period;
|
|
109
|
+
const target = ((targetT % curve.period) + curve.period) % curve.period;
|
|
110
110
|
const targetTime = target / curve.speed;
|
|
111
111
|
t = target;
|
|
112
112
|
actualTime = targetTime;
|
|
@@ -132,13 +132,16 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
132
132
|
...frozenB,
|
|
133
133
|
fn: (sampleT, time, params) => {
|
|
134
134
|
const a = frozenA.fn(sampleT, time, params);
|
|
135
|
-
const tB =
|
|
135
|
+
const tB =
|
|
136
|
+
frozenStrategy === "normalized"
|
|
137
|
+
? (sampleT / frozenA.period) * frozenB.period
|
|
138
|
+
: sampleT;
|
|
136
139
|
const b = frozenB.fn(tB, time, params);
|
|
137
140
|
return {
|
|
138
141
|
x: a.x + (b.x - a.x) * frozenAlpha,
|
|
139
|
-
y: a.y + (b.y - a.y) * frozenAlpha
|
|
142
|
+
y: a.y + (b.y - a.y) * frozenAlpha,
|
|
140
143
|
};
|
|
141
|
-
}
|
|
144
|
+
},
|
|
142
145
|
};
|
|
143
146
|
}
|
|
144
147
|
_morphStrategy = strategy;
|
|
@@ -151,7 +154,7 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
151
154
|
completeMorph() {
|
|
152
155
|
if (morphCurveB !== null) {
|
|
153
156
|
if (_morphStrategy === "normalized" && curve.period !== morphCurveB.period) {
|
|
154
|
-
t = t / curve.period * morphCurveB.period;
|
|
157
|
+
t = (t / curve.period) * morphCurveB.period;
|
|
155
158
|
}
|
|
156
159
|
curve = morphCurveB;
|
|
157
160
|
}
|
|
@@ -163,23 +166,26 @@ function createEngine(curveDef, trailLength = 120) {
|
|
|
163
166
|
const points = new Array(steps);
|
|
164
167
|
if (morphCurveB !== null && _morphAlpha !== null) {
|
|
165
168
|
for (let i = 0; i < steps; i++) {
|
|
166
|
-
const sampleT = i / (steps - 1) * curve.period;
|
|
169
|
+
const sampleT = (i / (steps - 1)) * curve.period;
|
|
167
170
|
const a = sampleSkeleton(curve, sampleT);
|
|
168
|
-
const tB =
|
|
171
|
+
const tB =
|
|
172
|
+
_morphStrategy === "normalized"
|
|
173
|
+
? (sampleT / curve.period) * morphCurveB.period
|
|
174
|
+
: sampleT;
|
|
169
175
|
const b = sampleSkeleton(morphCurveB, tB);
|
|
170
176
|
points[i] = {
|
|
171
177
|
x: a.x + (b.x - a.x) * _morphAlpha,
|
|
172
|
-
y: a.y + (b.y - a.y) * _morphAlpha
|
|
178
|
+
y: a.y + (b.y - a.y) * _morphAlpha,
|
|
173
179
|
};
|
|
174
180
|
}
|
|
175
181
|
return points;
|
|
176
182
|
}
|
|
177
183
|
for (let i = 0; i < steps; i++) {
|
|
178
|
-
const sampleT = i / (steps - 1) * curve.period;
|
|
184
|
+
const sampleT = (i / (steps - 1)) * curve.period;
|
|
179
185
|
points[i] = sampleSkeleton(curve, sampleT);
|
|
180
186
|
}
|
|
181
187
|
return points;
|
|
182
|
-
}
|
|
188
|
+
},
|
|
183
189
|
};
|
|
184
190
|
}
|
|
185
191
|
|
|
@@ -199,7 +205,7 @@ var GRADIENT = {
|
|
|
199
205
|
ocean: ["#1e3a8a", "#06b6d4", "#22d3ee", "#e0f2fe"],
|
|
200
206
|
ice: ["#1e3a8a", "#67e8f9"],
|
|
201
207
|
fire: ["#7f1d1d", "#fbbf24"],
|
|
202
|
-
forest: ["#14532d", "#86efac"]
|
|
208
|
+
forest: ["#14532d", "#86efac"],
|
|
203
209
|
};
|
|
204
210
|
var PRESETS = {
|
|
205
211
|
bard: GRADIENT.bard,
|
|
@@ -207,16 +213,16 @@ var PRESETS = {
|
|
|
207
213
|
ocean: GRADIENT.ocean,
|
|
208
214
|
ice: GRADIENT.ice,
|
|
209
215
|
fire: GRADIENT.fire,
|
|
210
|
-
forest: GRADIENT.forest
|
|
216
|
+
forest: GRADIENT.forest,
|
|
211
217
|
};
|
|
212
218
|
function hexToRgb(hex) {
|
|
213
219
|
const n = parseInt(hex.slice(1), 16);
|
|
214
|
-
return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
|
|
220
|
+
return { r: n >> 16, g: (n >> 8) & 255, b: n & 255 };
|
|
215
221
|
}
|
|
216
222
|
var lerpRgb = (a, b, t) => ({
|
|
217
223
|
r: Math.round(a.r + (b.r - a.r) * t),
|
|
218
224
|
g: Math.round(a.g + (b.g - a.g) * t),
|
|
219
|
-
b: Math.round(a.b + (b.b - a.b) * t)
|
|
225
|
+
b: Math.round(a.b + (b.b - a.b) * t),
|
|
220
226
|
});
|
|
221
227
|
function getPaletteColor(palette, position, timeOffset = 0) {
|
|
222
228
|
if (palette.length === 0) return { r: 255, g: 255, b: 255 };
|
|
@@ -236,7 +242,7 @@ function resolvePalette(palette, trailStyle) {
|
|
|
236
242
|
}
|
|
237
243
|
function hexToRgbComponents(hex) {
|
|
238
244
|
const n = parseInt(hex.slice(1), 16);
|
|
239
|
-
return `${n >> 16},${n >> 8 & 255},${n & 255}`;
|
|
245
|
+
return `${n >> 16},${(n >> 8) & 255},${n & 255}`;
|
|
240
246
|
}
|
|
241
247
|
function computeTangent(trail, i) {
|
|
242
248
|
const count = trail.length;
|
|
@@ -281,7 +287,7 @@ function createRenderer(options) {
|
|
|
281
287
|
skeletonColor: options.skeletonColor ?? DEFAULT_SKELETON_COLOR,
|
|
282
288
|
trailColor: options.trailColor ?? "#ffffff",
|
|
283
289
|
headColor: options.headColor ?? "#ffffff",
|
|
284
|
-
headRadius: options.headRadius ?? DEFAULT_HEAD_RADIUS
|
|
290
|
+
headRadius: options.headRadius ?? DEFAULT_HEAD_RADIUS,
|
|
285
291
|
};
|
|
286
292
|
const trailStyle = options.trailStyle ?? "default";
|
|
287
293
|
const palette = resolvePalette(options.palette, trailStyle);
|
|
@@ -314,7 +320,10 @@ function createRenderer(options) {
|
|
|
314
320
|
function computeBoundaries(pts) {
|
|
315
321
|
if (pts.length === 0) return null;
|
|
316
322
|
const first = pts[0];
|
|
317
|
-
let minX = first.x,
|
|
323
|
+
let minX = first.x,
|
|
324
|
+
maxX = first.x,
|
|
325
|
+
minY = first.y,
|
|
326
|
+
maxY = first.y;
|
|
318
327
|
for (const p of pts) {
|
|
319
328
|
if (p.x < minX) minX = p.x;
|
|
320
329
|
if (p.x > maxX) maxX = p.x;
|
|
@@ -331,7 +340,7 @@ function createRenderer(options) {
|
|
|
331
340
|
return {
|
|
332
341
|
scale: s,
|
|
333
342
|
offsetX: (logicalWidth - boundsWidth) / 2 - minX * s,
|
|
334
|
-
offsetY: (logicalHeight - boundsHeight) / 2 - minY * s
|
|
343
|
+
offsetY: (logicalHeight - boundsHeight) / 2 - minY * s,
|
|
335
344
|
};
|
|
336
345
|
}
|
|
337
346
|
function calculateBoundaries() {
|
|
@@ -537,7 +546,7 @@ function createRenderer(options) {
|
|
|
537
546
|
return new Promise((resolve) => {
|
|
538
547
|
morphResolve = resolve;
|
|
539
548
|
});
|
|
540
|
-
}
|
|
549
|
+
},
|
|
541
550
|
};
|
|
542
551
|
}
|
|
543
552
|
|
|
@@ -560,7 +569,7 @@ function createSVGRenderer(options) {
|
|
|
560
569
|
trailColor: options.trailColor ?? "#ffffff",
|
|
561
570
|
headColor: options.headColor ?? "#ffffff",
|
|
562
571
|
headRadius: options.headRadius ?? 4,
|
|
563
|
-
ariaLabel: options.ariaLabel ?? "Loading"
|
|
572
|
+
ariaLabel: options.ariaLabel ?? "Loading",
|
|
564
573
|
};
|
|
565
574
|
const rect = container.getBoundingClientRect();
|
|
566
575
|
const width = rect.width || 200;
|
|
@@ -614,7 +623,10 @@ function createSVGRenderer(options) {
|
|
|
614
623
|
return;
|
|
615
624
|
}
|
|
616
625
|
const first = skeleton2[0];
|
|
617
|
-
let minX = first.x,
|
|
626
|
+
let minX = first.x,
|
|
627
|
+
maxX = first.x,
|
|
628
|
+
minY = first.y,
|
|
629
|
+
maxY = first.y;
|
|
618
630
|
for (const p of skeleton2) {
|
|
619
631
|
if (p.x < minX) {
|
|
620
632
|
minX = p.x;
|
|
@@ -713,7 +725,8 @@ function createSVGRenderer(options) {
|
|
|
713
725
|
}
|
|
714
726
|
let animationId = null;
|
|
715
727
|
let lastTime = 0;
|
|
716
|
-
const prefersReducedMotion =
|
|
728
|
+
const prefersReducedMotion =
|
|
729
|
+
typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
717
730
|
let morphResolve = null;
|
|
718
731
|
let morphDurationMs = DEFAULT_MORPH_DURATION_MS2;
|
|
719
732
|
let morphTarget = null;
|
|
@@ -723,7 +736,7 @@ function createSVGRenderer(options) {
|
|
|
723
736
|
const samples = Math.max(50, Math.round(period * 20));
|
|
724
737
|
const points = [];
|
|
725
738
|
for (let i = 0; i <= samples; i++) {
|
|
726
|
-
const t = i / samples * period;
|
|
739
|
+
const t = (i / samples) * period;
|
|
727
740
|
const p = target.fn(t, 0, {});
|
|
728
741
|
points.push(p);
|
|
729
742
|
}
|
|
@@ -751,13 +764,16 @@ function createSVGRenderer(options) {
|
|
|
751
764
|
skeletonPathA.setAttribute("visibility", "visible");
|
|
752
765
|
skeletonPathA.setAttribute(
|
|
753
766
|
"stroke-opacity",
|
|
754
|
-
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY2)
|
|
767
|
+
String((1 - morphAlpha) * DEFAULT_SKELETON_OPACITY2),
|
|
755
768
|
);
|
|
756
769
|
}
|
|
757
770
|
if (morphPathBBuilt) {
|
|
758
771
|
skeletonPathB.setAttribute("d", morphPathBBuilt);
|
|
759
772
|
skeletonPathB.setAttribute("visibility", "visible");
|
|
760
|
-
skeletonPathB.setAttribute(
|
|
773
|
+
skeletonPathB.setAttribute(
|
|
774
|
+
"stroke-opacity",
|
|
775
|
+
String(morphAlpha * DEFAULT_SKELETON_OPACITY2),
|
|
776
|
+
);
|
|
761
777
|
}
|
|
762
778
|
if (morphAlpha >= 1) {
|
|
763
779
|
engine.completeMorph();
|
|
@@ -849,7 +865,7 @@ function createSVGRenderer(options) {
|
|
|
849
865
|
return new Promise((resolve) => {
|
|
850
866
|
morphResolve = resolve;
|
|
851
867
|
});
|
|
852
|
-
}
|
|
868
|
+
},
|
|
853
869
|
};
|
|
854
870
|
}
|
|
855
871
|
function createSarmalSVG(container, curveDef, options) {
|
|
@@ -858,152 +874,195 @@ function createSarmalSVG(container, curveDef, options) {
|
|
|
858
874
|
return createSVGRenderer({ container, engine, ...rendererOpts });
|
|
859
875
|
}
|
|
860
876
|
|
|
861
|
-
// src/curves.ts
|
|
877
|
+
// src/curves/artemis2.ts
|
|
862
878
|
var TWO_PI2 = Math.PI * 2;
|
|
863
|
-
function
|
|
864
|
-
const a = 0.35,
|
|
865
|
-
|
|
879
|
+
function artemis2Fn(t, _time, _params) {
|
|
880
|
+
const a = 0.35,
|
|
881
|
+
b = 0.15,
|
|
882
|
+
ox = 0.175;
|
|
883
|
+
const s = Math.sin(t),
|
|
884
|
+
c = Math.cos(t);
|
|
866
885
|
const denom = 1 + s * s;
|
|
867
886
|
return {
|
|
868
|
-
x: c * (1 + a * c) / denom - ox,
|
|
869
|
-
y: s * c * (1 + b * c) / denom
|
|
887
|
+
x: (c * (1 + a * c)) / denom - ox,
|
|
888
|
+
y: (s * c * (1 + b * c)) / denom,
|
|
870
889
|
};
|
|
871
890
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
x: 7 * Math.cos(t) - d * Math.cos(7 * t),
|
|
883
|
-
y: 7 * Math.sin(t) - d * Math.sin(7 * t)
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
function astroid(t, _time, _params) {
|
|
891
|
+
var artemis2 = {
|
|
892
|
+
name: "Artemis II",
|
|
893
|
+
fn: artemis2Fn,
|
|
894
|
+
period: TWO_PI2,
|
|
895
|
+
speed: 0.7,
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
// src/curves/astroid.ts
|
|
899
|
+
var TWO_PI3 = Math.PI * 2;
|
|
900
|
+
function astroidFn(t, _time, _params) {
|
|
887
901
|
const c = Math.cos(t);
|
|
888
902
|
const s = Math.sin(t);
|
|
889
903
|
return {
|
|
890
904
|
x: c * c * c,
|
|
891
|
-
y: s * s * s
|
|
905
|
+
y: s * s * s,
|
|
892
906
|
};
|
|
893
907
|
}
|
|
894
|
-
|
|
908
|
+
var astroid = {
|
|
909
|
+
name: "Astroid",
|
|
910
|
+
fn: astroidFn,
|
|
911
|
+
period: TWO_PI3,
|
|
912
|
+
speed: 1.1,
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
// src/curves/deltoid.ts
|
|
916
|
+
var TWO_PI4 = Math.PI * 2;
|
|
917
|
+
function deltoidFn(t, _time, _params) {
|
|
895
918
|
return {
|
|
896
919
|
x: 2 * Math.cos(t) + Math.cos(2 * t),
|
|
897
|
-
y: 2 * Math.sin(t) - Math.sin(2 * t)
|
|
920
|
+
y: 2 * Math.sin(t) - Math.sin(2 * t),
|
|
898
921
|
};
|
|
899
922
|
}
|
|
900
|
-
|
|
901
|
-
|
|
923
|
+
var deltoid = {
|
|
924
|
+
name: "Deltoid",
|
|
925
|
+
fn: deltoidFn,
|
|
926
|
+
period: TWO_PI4,
|
|
927
|
+
speed: 0.9,
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
// src/curves/epicycloid3.ts
|
|
931
|
+
var TWO_PI5 = Math.PI * 2;
|
|
932
|
+
function epicycloid3Fn(t, _time, _params) {
|
|
902
933
|
return {
|
|
903
|
-
x:
|
|
904
|
-
y:
|
|
934
|
+
x: 4 * Math.cos(t) - Math.cos(4 * t),
|
|
935
|
+
y: 4 * Math.sin(t) - Math.sin(4 * t),
|
|
905
936
|
};
|
|
906
937
|
}
|
|
907
|
-
|
|
908
|
-
|
|
938
|
+
var epicycloid3 = {
|
|
939
|
+
name: "Epicycloid (n=3)",
|
|
940
|
+
fn: epicycloid3Fn,
|
|
941
|
+
period: TWO_PI5,
|
|
942
|
+
speed: 0.75,
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
// src/curves/epitrochoid7.ts
|
|
946
|
+
var TWO_PI6 = Math.PI * 2;
|
|
947
|
+
function epitrochoid7Fn(t, _time, _params) {
|
|
948
|
+
const d = 1 + 0.55 * Math.sin(t * 0.5);
|
|
909
949
|
return {
|
|
910
|
-
x:
|
|
911
|
-
y:
|
|
950
|
+
x: 7 * Math.cos(t) - d * Math.cos(7 * t),
|
|
951
|
+
y: 7 * Math.sin(t) - d * Math.sin(7 * t),
|
|
912
952
|
};
|
|
913
953
|
}
|
|
914
|
-
function
|
|
954
|
+
function epitrochoid7SkeletonFn(t) {
|
|
955
|
+
const d = 1.275;
|
|
956
|
+
return {
|
|
957
|
+
x: 7 * Math.cos(t) - d * Math.cos(7 * t),
|
|
958
|
+
y: 7 * Math.sin(t) - d * Math.sin(7 * t),
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
var epitrochoid7 = {
|
|
962
|
+
name: "Epitrochoid",
|
|
963
|
+
fn: epitrochoid7Fn,
|
|
964
|
+
period: TWO_PI6,
|
|
965
|
+
speed: 1.4,
|
|
966
|
+
skeletonFn: epitrochoid7SkeletonFn,
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
// src/curves/lissajous32.ts
|
|
970
|
+
var TWO_PI7 = Math.PI * 2;
|
|
971
|
+
function lissajous32Fn(t, time, _params) {
|
|
915
972
|
const phi = time * 0.45;
|
|
916
973
|
return {
|
|
917
974
|
x: Math.sin(3 * t + phi),
|
|
918
|
-
y: Math.sin(2 * t)
|
|
975
|
+
y: Math.sin(2 * t),
|
|
919
976
|
};
|
|
920
977
|
}
|
|
921
|
-
|
|
978
|
+
var lissajous32 = {
|
|
979
|
+
name: "Lissajous 3:2",
|
|
980
|
+
fn: lissajous32Fn,
|
|
981
|
+
period: TWO_PI7,
|
|
982
|
+
speed: 2,
|
|
983
|
+
skeleton: "live",
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
// src/curves/lissajous43.ts
|
|
987
|
+
var TWO_PI8 = Math.PI * 2;
|
|
988
|
+
function lissajous43Fn(t, time, _params) {
|
|
922
989
|
const phi = time * 0.38;
|
|
923
990
|
return {
|
|
924
991
|
x: Math.sin(4 * t + phi),
|
|
925
|
-
y: Math.sin(3 * t)
|
|
992
|
+
y: Math.sin(3 * t),
|
|
926
993
|
};
|
|
927
994
|
}
|
|
928
|
-
|
|
995
|
+
var lissajous43 = {
|
|
996
|
+
name: "Lissajous 4:3",
|
|
997
|
+
fn: lissajous43Fn,
|
|
998
|
+
period: TWO_PI8,
|
|
999
|
+
speed: 1.8,
|
|
1000
|
+
skeleton: "live",
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
// src/curves/lame.ts
|
|
1004
|
+
var TWO_PI9 = Math.PI * 2;
|
|
1005
|
+
function lameFn(t, time, _params) {
|
|
1006
|
+
const p = 1.75 + 1.25 * Math.sin(time * 0.48);
|
|
1007
|
+
const c = Math.cos(t),
|
|
1008
|
+
s = Math.sin(t);
|
|
929
1009
|
return {
|
|
930
|
-
x:
|
|
931
|
-
y:
|
|
1010
|
+
x: Math.sign(c) * Math.pow(Math.abs(c), p),
|
|
1011
|
+
y: Math.sign(s) * Math.pow(Math.abs(s), p),
|
|
932
1012
|
};
|
|
933
1013
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1014
|
+
var lame = {
|
|
1015
|
+
name: "Lam\xE9 Curve",
|
|
1016
|
+
fn: lameFn,
|
|
1017
|
+
period: TWO_PI9,
|
|
1018
|
+
speed: 1,
|
|
1019
|
+
skeleton: "live",
|
|
1020
|
+
};
|
|
1021
|
+
|
|
1022
|
+
// src/curves/rose3.ts
|
|
1023
|
+
var TWO_PI10 = Math.PI * 2;
|
|
1024
|
+
function rose3Fn(t, _time, _params) {
|
|
1025
|
+
const r = Math.cos(3 * t);
|
|
937
1026
|
return {
|
|
938
|
-
x:
|
|
939
|
-
y:
|
|
1027
|
+
x: r * Math.cos(t),
|
|
1028
|
+
y: r * Math.sin(t),
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
var rose3 = {
|
|
1032
|
+
name: "Rose (n=3)",
|
|
1033
|
+
fn: rose3Fn,
|
|
1034
|
+
period: TWO_PI10,
|
|
1035
|
+
speed: 1.15,
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// src/curves/rose5.ts
|
|
1039
|
+
var TWO_PI11 = Math.PI * 2;
|
|
1040
|
+
function rose5Fn(t, _time, _params) {
|
|
1041
|
+
const r = Math.cos(5 * t);
|
|
1042
|
+
return {
|
|
1043
|
+
x: r * Math.cos(t),
|
|
1044
|
+
y: r * Math.sin(t),
|
|
940
1045
|
};
|
|
941
1046
|
}
|
|
1047
|
+
var rose5 = {
|
|
1048
|
+
name: "Rose (n=5)",
|
|
1049
|
+
fn: rose5Fn,
|
|
1050
|
+
period: TWO_PI11,
|
|
1051
|
+
speed: 1,
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
// src/curves/index.ts
|
|
942
1055
|
var curves = {
|
|
943
|
-
artemis2
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
speed: 1.4,
|
|
954
|
-
skeletonFn: epitrochoid7Skeleton
|
|
955
|
-
},
|
|
956
|
-
astroid: {
|
|
957
|
-
name: "Astroid",
|
|
958
|
-
fn: astroid,
|
|
959
|
-
period: TWO_PI2,
|
|
960
|
-
speed: 1.1
|
|
961
|
-
},
|
|
962
|
-
deltoid: {
|
|
963
|
-
name: "Deltoid",
|
|
964
|
-
fn: deltoid,
|
|
965
|
-
period: TWO_PI2,
|
|
966
|
-
speed: 0.9
|
|
967
|
-
},
|
|
968
|
-
rose5: {
|
|
969
|
-
name: "Rose (n=5)",
|
|
970
|
-
fn: rose5,
|
|
971
|
-
period: TWO_PI2,
|
|
972
|
-
speed: 1
|
|
973
|
-
},
|
|
974
|
-
rose3: {
|
|
975
|
-
name: "Rose (n=3)",
|
|
976
|
-
fn: rose3,
|
|
977
|
-
period: TWO_PI2,
|
|
978
|
-
speed: 1.15
|
|
979
|
-
},
|
|
980
|
-
lissajous32: {
|
|
981
|
-
name: "Lissajous 3:2",
|
|
982
|
-
fn: lissajous32,
|
|
983
|
-
period: TWO_PI2,
|
|
984
|
-
speed: 2,
|
|
985
|
-
skeleton: "live"
|
|
986
|
-
},
|
|
987
|
-
lissajous43: {
|
|
988
|
-
name: "Lissajous 4:3",
|
|
989
|
-
fn: lissajous43,
|
|
990
|
-
period: TWO_PI2,
|
|
991
|
-
speed: 1.8,
|
|
992
|
-
skeleton: "live"
|
|
993
|
-
},
|
|
994
|
-
epicycloid3: {
|
|
995
|
-
name: "Epicycloid (n=3)",
|
|
996
|
-
fn: epicycloid3,
|
|
997
|
-
period: TWO_PI2,
|
|
998
|
-
speed: 0.75
|
|
999
|
-
},
|
|
1000
|
-
lame: {
|
|
1001
|
-
name: "Lam\xE9 Curve",
|
|
1002
|
-
fn: lame,
|
|
1003
|
-
period: TWO_PI2,
|
|
1004
|
-
speed: 1,
|
|
1005
|
-
skeleton: "live"
|
|
1006
|
-
}
|
|
1056
|
+
artemis2,
|
|
1057
|
+
epitrochoid7,
|
|
1058
|
+
astroid,
|
|
1059
|
+
deltoid,
|
|
1060
|
+
rose5,
|
|
1061
|
+
rose3,
|
|
1062
|
+
lissajous32,
|
|
1063
|
+
lissajous43,
|
|
1064
|
+
epicycloid3,
|
|
1065
|
+
lame,
|
|
1007
1066
|
};
|
|
1008
1067
|
|
|
1009
1068
|
// src/index.ts
|
|
@@ -1013,6 +1072,23 @@ function createSarmal(canvas, curveDef, options) {
|
|
|
1013
1072
|
return createRenderer({ canvas, engine, ...rendererOpts });
|
|
1014
1073
|
}
|
|
1015
1074
|
|
|
1016
|
-
export {
|
|
1075
|
+
export {
|
|
1076
|
+
artemis2,
|
|
1077
|
+
astroid,
|
|
1078
|
+
createEngine,
|
|
1079
|
+
createRenderer,
|
|
1080
|
+
createSVGRenderer,
|
|
1081
|
+
createSarmal,
|
|
1082
|
+
createSarmalSVG,
|
|
1083
|
+
curves,
|
|
1084
|
+
deltoid,
|
|
1085
|
+
epicycloid3,
|
|
1086
|
+
epitrochoid7,
|
|
1087
|
+
lame,
|
|
1088
|
+
lissajous32,
|
|
1089
|
+
lissajous43,
|
|
1090
|
+
rose3,
|
|
1091
|
+
rose5,
|
|
1092
|
+
};
|
|
1093
|
+
//# sourceMappingURL=index.js.map
|
|
1017
1094
|
//# sourceMappingURL=index.js.map
|
|
1018
|
-
//# sourceMappingURL=index.js.map
|