🎨 moving poiMarker to config, improving asciiMap

This commit is contained in:
Michael Straßburger 2017-05-12 19:58:39 +02:00
parent 7e255edc53
commit 7edde3b30f
3 changed files with 16 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -36,4 +36,6 @@ module.exports =
headless: false
delimeter: "\n\r"
delimeter: "\n\r"
poiMarker: ""