Workaround for the see-through gaps bug

cpsdqs/unified-input
Ondřej Hruška 7 years ago
parent 2b93cedd3f
commit f0da18890f
  1. 15
      js/term_screen.js

@ -1146,6 +1146,8 @@ window.TermScreen = class TermScreen {
this.screenAttrs = new Array(screenLength).fill(' ') this.screenAttrs = new Array(screenLength).fill(' ')
} }
let bgcount = new Array(256).fill(0)
let strArray = !undef(Array.from) ? Array.from(str) : str.split('') let strArray = !undef(Array.from) ? Array.from(str) : str.split('')
const MASK_LINE_ATTR = 0xC8 const MASK_LINE_ATTR = 0xC8
@ -1167,6 +1169,7 @@ window.TermScreen = class TermScreen {
else this.blinkingCellCount-- else this.blinkingCellCount--
} }
bgcount[bg]++
this.screen[cell] = lastChar this.screen[cell] = lastChar
this.screenFG[cell] = fg this.screenFG[cell] = fg
this.screenBG[cell] = bg this.screenBG[cell] = bg
@ -1223,6 +1226,18 @@ window.TermScreen = class TermScreen {
if (this.window.debug) console.log(`Blinky cells = ${this.blinkingCellCount}`) 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.scheduleDraw('load', 16)
this.emit('load') this.emit('load')
} }

Loading…
Cancel
Save