mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-25 01:23:58 +01:00
🎨 convert braille idx to bitstring to allow ascii selection
This commit is contained in:
parent
7edde3b30f
commit
724e605317
@ -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+2+16+32]
|
||||
"▄": [4+8+64+128]
|
||||
"■": [2+4+32+64]
|
||||
"█": [255]
|
||||
"▌": [1+2+4+8]
|
||||
"▐": [16+32+64+128]
|
||||
# "▓": [1+4+32+128, 2+8+16+64]
|
||||
"█": [255]
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user