From 724e605317169f4ee4ab302c8dcb36c52c3d8e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Stra=C3=9Fburger?= Date: Fri, 12 May 2017 23:11:42 +0200 Subject: [PATCH] :art: convert braille idx to bitstring to allow ascii selection --- src/BrailleBuffer.coffee | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/BrailleBuffer.coffee b/src/BrailleBuffer.coffee index 870cbca..643cb0e 100644 --- a/src/BrailleBuffer.coffee +++ b/src/BrailleBuffer.coffee @@ -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