asciify-engine 1.0.57 → 1.0.59

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 CHANGED
@@ -277,24 +277,25 @@ for (let _i = 0; _i < 256; _i++) {
277
277
  GRAY_LUT[_i] = `rgb(${_i},${_i},${_i})`;
278
278
  GREEN_LUT[_i] = `rgb(0,${_i},0)`;
279
279
  }
280
- function getCellColorStr(cell, colorMode, acR, acG, acB, isInverted = false) {
280
+ function getCellColorStr(cell, colorMode, acR, acG, acB, _isInverted = false) {
281
281
  switch (colorMode) {
282
282
  case "fullcolor":
283
283
  return `rgb(${cell.r},${cell.g},${cell.b})`;
284
284
  case "matrix":
285
285
  return GREEN_LUT[0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b | 0];
286
286
  case "accent": {
287
- const ab = (0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b) / 255;
287
+ const rawAb = (0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b) / 255;
288
+ const ab = _isInverted ? 1 - rawAb : rawAb;
288
289
  return `rgb(${acR * ab | 0},${acG * ab | 0},${acB * ab | 0})`;
289
290
  }
290
291
  default: {
291
292
  const gray = 0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b | 0;
292
- return GRAY_LUT[isInverted ? 255 - gray : gray];
293
+ return GRAY_LUT[gray];
293
294
  }
294
295
  }
295
296
  }
296
297
  var _colorRGB = [0, 0, 0];
297
- function getCellColorRGB(cell, colorMode, acR, acG, acB, isInverted = false) {
298
+ function getCellColorRGB(cell, colorMode, acR, acG, acB, _isInverted = false) {
298
299
  switch (colorMode) {
299
300
  case "fullcolor":
300
301
  _colorRGB[0] = cell.r;
@@ -309,15 +310,15 @@ function getCellColorRGB(cell, colorMode, acR, acG, acB, isInverted = false) {
309
310
  break;
310
311
  }
311
312
  case "accent": {
312
- const ab = (0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b) / 255;
313
+ const rawAb = (0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b) / 255;
314
+ const ab = _isInverted ? 1 - rawAb : rawAb;
313
315
  _colorRGB[0] = acR * ab | 0;
314
316
  _colorRGB[1] = acG * ab | 0;
315
317
  _colorRGB[2] = acB * ab | 0;
316
318
  break;
317
319
  }
318
320
  default: {
319
- let gray = 0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b | 0;
320
- if (isInverted) gray = 255 - gray;
321
+ const gray = 0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b | 0;
321
322
  _colorRGB[0] = gray;
322
323
  _colorRGB[1] = gray;
323
324
  _colorRGB[2] = gray;
@@ -908,7 +909,8 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
908
909
  }
909
910
  }
910
911
  if (!hasTransparency) {
911
- ctx.fillStyle = "#0a0a0a";
912
+ const isInvertedBg = resolveInvert(options.invert);
913
+ ctx.fillStyle = isInvertedBg ? "#faf9f7" : "#0a0a0a";
912
914
  ctx.fillRect(0, 0, canvasWidth, canvasHeight);
913
915
  }
914
916
  const cellW = canvasWidth / cols;