From 7edde3b30fcb3cbe1d81943e98fdf40688f19f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Stra=C3=9Fburger?= Date: Fri, 12 May 2017 19:58:39 +0200 Subject: [PATCH] :art: moving poiMarker to config, improving asciiMap --- src/BrailleBuffer.coffee | 20 ++++++++++---------- src/Renderer.coffee | 7 +++---- src/config.coffee | 4 +++- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/BrailleBuffer.coffee b/src/BrailleBuffer.coffee index 5b49ae0..870cbca 100644 --- a/src/BrailleBuffer.coffee +++ b/src/BrailleBuffer.coffee @@ -18,14 +18,15 @@ utils = require './utils' module.exports = class BrailleBuffer brailleMap: [[0x1, 0x8],[0x2, 0x10],[0x4, 0x20],[0x40, 0x80]] asciiMap: - #"▬": [2+32, 4+64] + # "▬": [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] - #"▓": [1+4+32+128, 2+8+16+64] "█": [255] + #"▓": [1+4+32+128, 2+8+16+64] pixelBuffer: null charBuffer: null @@ -86,15 +87,14 @@ module.exports = class BrailleBuffer continue unless bits instanceof Array masks.push mask: mask, char: char for mask in bits - reducer = (best, mask) -> - covered = utils.population(mask.mask&i) - return if not best or best.covered < covered - char: mask.char, covered: covered - else - best - for i in [1..255] - @asciiToBraille[i] = masks.reduce(reducer, undefined).char + @asciiToBraille[i] = masks.reduce(((best, mask) -> + covered = utils.population mask.mask&i + if not best or best.covered < covered + char: mask.char, covered: covered + else + best + ), undefined).char _termColor: (foreground, background) -> background = background or @globalBackground diff --git a/src/Renderer.coffee b/src/Renderer.coffee index 209ed83..bb58bde 100644 --- a/src/Renderer.coffee +++ b/src/Renderer.coffee @@ -175,9 +175,8 @@ module.exports = class Renderer @canvas.polygon points, feature.color when "symbol" - genericSymbol = null text = feature.label or - genericSymbol = "◉" + genericSymbol = config.poiMarker return false if @_seen[text] and not genericSymbol @@ -192,8 +191,8 @@ module.exports = class Renderer break else if config.layers[feature.layer]?.cluster and - @labelBuffer.writeIfPossible "◉", point.x, point.y, feature, 3 - @canvas.text "◉", point.x, point.y, feature.color + @labelBuffer.writeIfPossible config.poiMarker, point.x, point.y, feature, 3 + @canvas.text config.poiMarker, point.x, point.y, feature.color placed = true break diff --git a/src/config.coffee b/src/config.coffee index 2856379..9267745 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -36,4 +36,6 @@ module.exports = headless: false - delimeter: "\n\r" \ No newline at end of file + delimeter: "\n\r" + + poiMarker: "◉" \ No newline at end of file