🎨 convert braille idx to bitstring to allow ascii selection

This commit is contained in:
Michael Straßburger 2017-05-12 23:11:42 +02:00
parent 7edde3b30f
commit 724e605317

View File

@ -19,14 +19,14 @@ module.exports = class BrailleBuffer
brailleMap: [[0x1, 0x8],[0x2, 0x10],[0x4, 0x20],[0x40, 0x80]]
asciiMap:
# "": [2+32, 4+64]
# "": [1+2+4+8]
# "": [16+32+64+128]
#"¯": [1+16]
# "¯": [1+16]
"": [1+2+16+32]
"": [4+8+64+128]
"": [2+4+32+64]
"": [1+2+4+8]
"": [16+32+64+128]
# "": [1+4+32+128, 2+8+16+64]
"": [255]
#"": [1+4+32+128, 2+8+16+64]
pixelBuffer: null
charBuffer: null
@ -88,8 +88,10 @@ module.exports = class BrailleBuffer
masks.push mask: mask, char: char for mask in bits
for i in [1..255]
braille = (i&7) + ((i&56)<<1) + ((i&64)>>3) + (i&128)
@asciiToBraille[i] = masks.reduce(((best, mask) ->
covered = utils.population mask.mask&i
covered = utils.population(mask.mask&braille)
if not best or best.covered < covered
char: mask.char, covered: covered
else