@sarmal/core 0.28.1 → 0.29.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/README.md +1 -1
- package/dist/auto-init.cjs +45 -6
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.js +45 -6
- package/dist/auto-init.js.map +1 -1
- package/dist/cli.js +50 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +45 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -6
- package/dist/index.js.map +1 -1
- package/dist/terminal.cjs +52 -11
- package/dist/terminal.cjs.map +1 -1
- package/dist/terminal.d.cts +2 -1
- package/dist/terminal.d.ts +2 -1
- package/dist/terminal.js +52 -12
- package/dist/terminal.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
The animations can be used anywhere you want. Use it for loading spinners, progress indicators, or to indicate that your very special AI model is _thinking_, up to you.
|
|
16
16
|
|
|
17
|
-
In web applications
|
|
17
|
+
In web applications or directly in your terminal (`npx @sarmal/core`).
|
|
18
18
|
|
|
19
19
|
- **Canvas & SVG renderers**: choose one or the other, but why not both?
|
|
20
20
|
- **standard curves**: default cliche curves any LLM can generate in seconds, from classic spirals to custom parametric paths
|
package/dist/auto-init.cjs
CHANGED
|
@@ -377,11 +377,50 @@ function hexToRgb(hex) {
|
|
|
377
377
|
const n = parseInt(hex.slice(1), 16);
|
|
378
378
|
return { r: n >> 16, g: n >> 8 & 255, b: n & 255 };
|
|
379
379
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
380
|
+
function srgbByteToLinear(c) {
|
|
381
|
+
const n = c / 255;
|
|
382
|
+
return n <= 0.04045 ? n / 12.92 : Math.pow((n + 0.055) / 1.055, 2.4);
|
|
383
|
+
}
|
|
384
|
+
function linearToSrgbByte(c) {
|
|
385
|
+
const v = Math.max(0, Math.min(1, c));
|
|
386
|
+
return Math.round((v <= 31308e-7 ? 12.92 * v : 1.055 * Math.pow(v, 1 / 2.4) - 0.055) * 255);
|
|
387
|
+
}
|
|
388
|
+
function rgbToOklab({ r, g, b }) {
|
|
389
|
+
const rl = srgbByteToLinear(r), gl = srgbByteToLinear(g), bl = srgbByteToLinear(b);
|
|
390
|
+
const l = Math.cbrt(0.4122214708 * rl + 0.5363325363 * gl + 0.0514459929 * bl);
|
|
391
|
+
const m = Math.cbrt(0.2119034982 * rl + 0.6806995451 * gl + 0.1073969566 * bl);
|
|
392
|
+
const s = Math.cbrt(0.0883024619 * rl + 0.2817188376 * gl + 0.6299787005 * bl);
|
|
393
|
+
return {
|
|
394
|
+
L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
395
|
+
a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
396
|
+
b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function oklabToRgb({ L, a, b }) {
|
|
400
|
+
const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
|
|
401
|
+
const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
|
|
402
|
+
const s_ = L - 0.0894841775 * a - 1.29145603 * b;
|
|
403
|
+
const l = l_ * l_ * l_, m = m_ * m_ * m_, s = s_ * s_ * s_;
|
|
404
|
+
return {
|
|
405
|
+
r: linearToSrgbByte(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
|
|
406
|
+
g: linearToSrgbByte(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
|
|
407
|
+
b: linearToSrgbByte(-0.0041960863 * l - 0.7034186147 * m + 1.6076099202 * s)
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
var lerpOklab = (a, b, t) => {
|
|
411
|
+
if (t <= 0) {
|
|
412
|
+
return a;
|
|
413
|
+
}
|
|
414
|
+
if (t >= 1) {
|
|
415
|
+
return b;
|
|
416
|
+
}
|
|
417
|
+
const la = rgbToOklab(a), lb = rgbToOklab(b);
|
|
418
|
+
return oklabToRgb({
|
|
419
|
+
L: la.L + (lb.L - la.L) * t,
|
|
420
|
+
a: la.a + (lb.a - la.a) * t,
|
|
421
|
+
b: la.b + (lb.b - la.b) * t
|
|
422
|
+
});
|
|
423
|
+
};
|
|
385
424
|
function getPaletteColor(palette, position, timeOffset = 0) {
|
|
386
425
|
if (palette.length === 0) {
|
|
387
426
|
return { r: 255, g: 255, b: 255 };
|
|
@@ -395,7 +434,7 @@ function getPaletteColor(palette, position, timeOffset = 0) {
|
|
|
395
434
|
const t = scaled - idx;
|
|
396
435
|
const c1 = hexToRgb(palette[idx % palette.length]);
|
|
397
436
|
const c2 = hexToRgb(palette[(idx + 1) % palette.length]);
|
|
398
|
-
return
|
|
437
|
+
return lerpOklab(c1, c2, t);
|
|
399
438
|
}
|
|
400
439
|
var HEX_COLOR_RE = /^#[0-9a-fA-F]{6}$/;
|
|
401
440
|
var TRAIL_STYLES = ["default", "gradient-static", "gradient-animated"];
|