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