From f0da18890f8bd9c7039a16b9d1db00c9d18775a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 11 Sep 2017 23:38:43 +0200 Subject: [PATCH] Workaround for the see-through gaps bug --- js/term_screen.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/term_screen.js b/js/term_screen.js index 66394b0..b332307 100644 --- a/js/term_screen.js +++ b/js/term_screen.js @@ -1146,6 +1146,8 @@ window.TermScreen = class TermScreen { this.screenAttrs = new Array(screenLength).fill(' ') } + let bgcount = new Array(256).fill(0) + let strArray = !undef(Array.from) ? Array.from(str) : str.split('') const MASK_LINE_ATTR = 0xC8 @@ -1167,6 +1169,7 @@ window.TermScreen = class TermScreen { else this.blinkingCellCount-- } + bgcount[bg]++ this.screen[cell] = lastChar this.screenFG[cell] = fg this.screenBG[cell] = bg @@ -1223,6 +1226,18 @@ window.TermScreen = class TermScreen { if (this.window.debug) console.log(`Blinky cells = ${this.blinkingCellCount}`) + // work-around for the grid gaps bug + // will mask the glitch if most of the screen uses the same background + let mostCommonBg = 0 + let mcbIndex = 0 + for (let i = 255; i >= 0; i--) { + if (bgcount[i] > mostCommonBg) { + mostCommonBg = bgcount[i] + mcbIndex = i + } + } + this.canvas.style.backgroundColor = this.getColor(mcbIndex) + this.scheduleDraw('load', 16) this.emit('load') }