mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 23:53:08 +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]]
|
brailleMap: [[0x1, 0x8],[0x2, 0x10],[0x4, 0x20],[0x40, 0x80]]
|
||||||
asciiMap:
|
asciiMap:
|
||||||
# "▬": [2+32, 4+64]
|
# "▬": [2+32, 4+64]
|
||||||
# "▌": [1+2+4+8]
|
# "¯": [1+16]
|
||||||
# "▐": [16+32+64+128]
|
|
||||||
#"¯": [1+16]
|
|
||||||
"▀": [1+2+16+32]
|
"▀": [1+2+16+32]
|
||||||
"▄": [4+8+64+128]
|
"▄": [4+8+64+128]
|
||||||
"■": [2+4+32+64]
|
"■": [2+4+32+64]
|
||||||
|
"▌": [1+2+4+8]
|
||||||
|
"▐": [16+32+64+128]
|
||||||
|
# "▓": [1+4+32+128, 2+8+16+64]
|
||||||
"█": [255]
|
"█": [255]
|
||||||
#"▓": [1+4+32+128, 2+8+16+64]
|
|
||||||
|
|
||||||
pixelBuffer: null
|
pixelBuffer: null
|
||||||
charBuffer: null
|
charBuffer: null
|
||||||
@ -88,8 +88,10 @@ module.exports = class BrailleBuffer
|
|||||||
masks.push mask: mask, char: char for mask in bits
|
masks.push mask: mask, char: char for mask in bits
|
||||||
|
|
||||||
for i in [1..255]
|
for i in [1..255]
|
||||||
|
braille = (i&7) + ((i&56)<<1) + ((i&64)>>3) + (i&128)
|
||||||
|
|
||||||
@asciiToBraille[i] = masks.reduce(((best, mask) ->
|
@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
|
if not best or best.covered < covered
|
||||||
char: mask.char, covered: covered
|
char: mask.char, covered: covered
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user