asciify-engine 1.0.51 → 1.0.52
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 +12 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -214,7 +214,7 @@ for (let _i = 0; _i < 256; _i++) {
|
|
|
214
214
|
GRAY_LUT[_i] = `rgb(${_i},${_i},${_i})`;
|
|
215
215
|
GREEN_LUT[_i] = `rgb(0,${_i},0)`;
|
|
216
216
|
}
|
|
217
|
-
function getCellColorStr(cell, colorMode, acR, acG, acB) {
|
|
217
|
+
function getCellColorStr(cell, colorMode, acR, acG, acB, isInverted = false) {
|
|
218
218
|
switch (colorMode) {
|
|
219
219
|
case "fullcolor":
|
|
220
220
|
return `rgb(${cell.r},${cell.g},${cell.b})`;
|
|
@@ -224,12 +224,14 @@ function getCellColorStr(cell, colorMode, acR, acG, acB) {
|
|
|
224
224
|
const ab = (0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b) / 255;
|
|
225
225
|
return `rgb(${acR * ab | 0},${acG * ab | 0},${acB * ab | 0})`;
|
|
226
226
|
}
|
|
227
|
-
default:
|
|
228
|
-
|
|
227
|
+
default: {
|
|
228
|
+
const gray = 0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b | 0;
|
|
229
|
+
return GRAY_LUT[isInverted ? 255 - gray : gray];
|
|
230
|
+
}
|
|
229
231
|
}
|
|
230
232
|
}
|
|
231
233
|
var _colorRGB = [0, 0, 0];
|
|
232
|
-
function getCellColorRGB(cell, colorMode, acR, acG, acB) {
|
|
234
|
+
function getCellColorRGB(cell, colorMode, acR, acG, acB, isInverted = false) {
|
|
233
235
|
switch (colorMode) {
|
|
234
236
|
case "fullcolor":
|
|
235
237
|
_colorRGB[0] = cell.r;
|
|
@@ -251,7 +253,8 @@ function getCellColorRGB(cell, colorMode, acR, acG, acB) {
|
|
|
251
253
|
break;
|
|
252
254
|
}
|
|
253
255
|
default: {
|
|
254
|
-
|
|
256
|
+
let gray = 0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b | 0;
|
|
257
|
+
if (isInverted) gray = 255 - gray;
|
|
255
258
|
_colorRGB[0] = gray;
|
|
256
259
|
_colorRGB[1] = gray;
|
|
257
260
|
_colorRGB[2] = gray;
|
|
@@ -899,13 +902,13 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
|
|
|
899
902
|
const py = y * cellH + cellH * 0.5 + hoverOffY;
|
|
900
903
|
let color;
|
|
901
904
|
if (hoverBlend > 0) {
|
|
902
|
-
const rgb = getCellColorRGB(cell, colorMode, acR, acG, acB);
|
|
905
|
+
const rgb = getCellColorRGB(cell, colorMode, acR, acG, acB, isInverted);
|
|
903
906
|
const cr = Math.min(255, rgb[0] + (hcR - rgb[0]) * hoverBlend | 0);
|
|
904
907
|
const cg = Math.min(255, rgb[1] + (hcG - rgb[1]) * hoverBlend | 0);
|
|
905
908
|
const cb = Math.min(255, rgb[2] + (hcB - rgb[2]) * hoverBlend | 0);
|
|
906
909
|
color = `rgb(${cr},${cg},${cb})`;
|
|
907
910
|
} else {
|
|
908
|
-
color = getCellColorStr(cell, colorMode, acR, acG, acB);
|
|
911
|
+
color = getCellColorStr(cell, colorMode, acR, acG, acB, isInverted);
|
|
909
912
|
}
|
|
910
913
|
const alpha = Math.min(1, cell.a * 0.00392156863 * animMul * (1 + hoverGlow));
|
|
911
914
|
if (alpha !== lastAlpha) {
|
|
@@ -981,13 +984,13 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
|
|
|
981
984
|
const py = y * cellH + cellH * 0.5 + hoverOffY;
|
|
982
985
|
let color;
|
|
983
986
|
if (hoverBlend > 0) {
|
|
984
|
-
const rgb = getCellColorRGB(cell, colorMode, acR, acG, acB);
|
|
987
|
+
const rgb = getCellColorRGB(cell, colorMode, acR, acG, acB, isInverted);
|
|
985
988
|
const cr = Math.min(255, rgb[0] + (hcR - rgb[0]) * hoverBlend | 0);
|
|
986
989
|
const cg = Math.min(255, rgb[1] + (hcG - rgb[1]) * hoverBlend | 0);
|
|
987
990
|
const cb = Math.min(255, rgb[2] + (hcB - rgb[2]) * hoverBlend | 0);
|
|
988
991
|
color = `rgb(${cr},${cg},${cb})`;
|
|
989
992
|
} else {
|
|
990
|
-
color = getCellColorStr(cell, colorMode, acR, acG, acB);
|
|
993
|
+
color = getCellColorStr(cell, colorMode, acR, acG, acB, isInverted);
|
|
991
994
|
}
|
|
992
995
|
if (useFastRect) {
|
|
993
996
|
const weight = charWeights[cell.char] ?? 0.5;
|