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