asciify-engine 1.0.52 → 1.0.53
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/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -622,6 +622,14 @@ function resolveInvert(invert) {
|
|
|
622
622
|
if (invert !== "auto") return invert;
|
|
623
623
|
return typeof window !== "undefined" && !window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
624
624
|
}
|
|
625
|
+
function resolveAccentHex(accentColor) {
|
|
626
|
+
const v = accentColor || "auto";
|
|
627
|
+
if (v === "auto") {
|
|
628
|
+
const isDark = typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
629
|
+
return isDark ? "faf9f7" : "0d0d0d";
|
|
630
|
+
}
|
|
631
|
+
return v.replace("#", "");
|
|
632
|
+
}
|
|
625
633
|
function imageToAsciiFrame(source, options, targetWidth, targetHeight) {
|
|
626
634
|
const srcWidth = source instanceof HTMLVideoElement ? source.videoWidth : source.width;
|
|
627
635
|
const srcHeight = source instanceof HTMLVideoElement ? source.videoHeight : source.height;
|
|
@@ -786,7 +794,7 @@ async function gifToAsciiFrames(buffer, options, targetWidth, targetHeight, onPr
|
|
|
786
794
|
function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, time = 0, hoverPos) {
|
|
787
795
|
if (options.animationStyle === "waveField") {
|
|
788
796
|
const mouseNorm = hoverPos ? { x: hoverPos.x, y: hoverPos.y } : { x: 0.5, y: 0.5 };
|
|
789
|
-
const acHexWF = (options.accentColor
|
|
797
|
+
const acHexWF = options.accentColor ? resolveAccentHex(options.accentColor) : "d4ff00";
|
|
790
798
|
renderWaveBackground(ctx, canvasWidth, canvasHeight, time, mouseNorm, {
|
|
791
799
|
accentColor: `#${acHexWF}`,
|
|
792
800
|
accentThreshold: 0.52,
|
|
@@ -831,7 +839,7 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
|
|
|
831
839
|
const hcR = parseInt(hc.slice(1, 3), 16) || 255;
|
|
832
840
|
const hcG = parseInt(hc.slice(3, 5), 16) || 255;
|
|
833
841
|
const hcB = parseInt(hc.slice(5, 7), 16) || 255;
|
|
834
|
-
const acHex = (options.accentColor
|
|
842
|
+
const acHex = resolveAccentHex(options.accentColor);
|
|
835
843
|
const acR = parseInt(acHex.substring(0, 2), 16) || 255;
|
|
836
844
|
const acG = parseInt(acHex.substring(2, 4), 16) || 255;
|
|
837
845
|
const acB = parseInt(acHex.substring(4, 6), 16) || 255;
|