asciify-engine 1.0.61 → 1.0.63

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
@@ -284,9 +284,7 @@ function getCellColorStr(cell, colorMode, acR, acG, acB, _isInverted = false) {
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 rawAb = (0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b) / 255;
288
- const ab = _isInverted ? 1 - rawAb : rawAb;
289
- return `rgb(${acR * ab | 0},${acG * ab | 0},${acB * ab | 0})`;
287
+ return `rgb(${acR},${acG},${acB})`;
290
288
  }
291
289
  default: {
292
290
  const gray = 0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b | 0;
@@ -310,11 +308,9 @@ function getCellColorRGB(cell, colorMode, acR, acG, acB, _isInverted = false) {
310
308
  break;
311
309
  }
312
310
  case "accent": {
313
- const rawAb = (0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b) / 255;
314
- const ab = _isInverted ? 1 - rawAb : rawAb;
315
- _colorRGB[0] = acR * ab | 0;
316
- _colorRGB[1] = acG * ab | 0;
317
- _colorRGB[2] = acB * ab | 0;
311
+ _colorRGB[0] = acR;
312
+ _colorRGB[1] = acG;
313
+ _colorRGB[2] = acB;
318
314
  break;
319
315
  }
320
316
  default: {
@@ -771,6 +767,7 @@ function imageToAsciiFrame(source, options, targetWidth, targetHeight) {
771
767
  }
772
768
  const frame = [];
773
769
  const invertVal = resolveInvert(options.invert);
770
+ const effectiveCharset = ckEnabled ? options.charset.replace(/ /g, "") || options.charset : options.charset;
774
771
  for (let y = 0; y < rows; y++) {
775
772
  const row = [];
776
773
  for (let x = 0; x < cols; x++) {
@@ -800,7 +797,7 @@ function imageToAsciiFrame(source, options, targetWidth, targetHeight) {
800
797
  const lum = options.normalize ? (rawLum - normMin) / normRange * 255 : rawLum;
801
798
  const adjustedLum = adjustLuminance(lum, options.brightness, options.contrast);
802
799
  const ditheredLum = applyDither(adjustedLum, x, y, options.ditherStrength);
803
- const char = options.customText ? customTextToChar(ditheredLum, options.customText, x, y, cols, invertVal) : luminanceToChar(ditheredLum, options.charset, invertVal);
800
+ const char = options.customText ? customTextToChar(ditheredLum, options.customText, x, y, cols, invertVal) : luminanceToChar(ditheredLum, effectiveCharset, invertVal);
804
801
  row.push({ char, r, g, b, a, lum: ditheredLum });
805
802
  }
806
803
  frame.push(row);