Update BrailleBuffer.js with 😃

This commit is contained in:
deadlord082 2024-10-07 14:20:16 +02:00
parent 4fe9a60a0c
commit 39343a7c8e

View File

@ -15,7 +15,7 @@
const stringWidth = require('string-width'); const stringWidth = require('string-width');
const config = require('./config'); const config = require('./config');
const utils = require('./utils'); const utils = require('./utils');
//😃😃😃😃😃😃😃😃😃😃😃😃😃😃
const asciiMap = { const asciiMap = {
// '▬': [2+32, 4+64], // '▬': [2+32, 4+64],
// '¯': [1+16], // '¯': [1+16],
@ -28,7 +28,7 @@ const asciiMap = {
'█': [255], '█': [255],
}; };
const termReset = '\x1B[39;49m'; const termReset = '\x1B[39;49m';
//😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃
class BrailleBuffer { class BrailleBuffer {
constructor(width, height) { constructor(width, height) {
this.brailleMap = [[0x1, 0x8],[0x2, 0x10],[0x4, 0x20],[0x40, 0x80]]; this.brailleMap = [[0x1, 0x8],[0x2, 0x10],[0x4, 0x20],[0x40, 0x80]];
@ -84,7 +84,7 @@ class BrailleBuffer {
this.pixelBuffer[idx] &= ~mask; this.pixelBuffer[idx] &= ~mask;
}); });
} }
//😃😃😃😃😃😃😃😃😃😃😃
_project(x, y) { _project(x, y) {
return (x>>1) + (this.width>>1)*(y>>2); return (x>>1) + (this.width>>1)*(y>>2);
} }
@ -112,7 +112,7 @@ class BrailleBuffer {
}); });
} }
} }
//😃😃😃😃😃😃😃😃😃😃😃
//TODO Optimize this part //TODO Optimize this part
var i, k; var i, k;
const results = []; const results = [];
@ -145,7 +145,7 @@ class BrailleBuffer {
return termReset; return termReset;
} }
} }
//😃😃😃😃😃😃😃😃😃😃😃
frame() { frame() {
const output = []; const output = [];
let currentColor = null; let currentColor = null;
@ -189,7 +189,7 @@ class BrailleBuffer {
output.push(termReset+config.delimeter); output.push(termReset+config.delimeter);
return output.join(''); return output.join('');
} }
//😃😃😃😃😃😃😃😃😃😃😃
setChar(char, x, y, color) { setChar(char, x, y, color) {
if (0 <= x && x < this.width && 0 <= y && y < this.height) { if (0 <= x && x < this.width && 0 <= y && y < this.height) {
const idx = this._project(x, y); const idx = this._project(x, y);
@ -207,5 +207,5 @@ class BrailleBuffer {
} }
} }
} }
//😃😃😃😃😃😃😃😃😃😃😃
module.exports = BrailleBuffer; module.exports = BrailleBuffer;