mirror of
https://github.com/rastapasta/mapscii.git
synced 2025-03-19 16:36:55 +01:00
🎨 supporting global background color via style definition
This commit is contained in:
parent
334032da59
commit
a7c8a4206b
@ -22,6 +22,8 @@ module.exports = class BrailleBuffer
|
||||
foregroundBuffer: null
|
||||
backgroundBuffer: null
|
||||
|
||||
globalBackground: null
|
||||
|
||||
termReset: "\x1B[39;49m"
|
||||
|
||||
constructor: (@width, @height) ->
|
||||
@ -34,6 +36,8 @@ module.exports = class BrailleBuffer
|
||||
@foregroundBuffer = []
|
||||
@backgroundBuffer = []
|
||||
|
||||
setGlobalBackground: (@globalBackground) ->
|
||||
|
||||
setBackground: (x, y, color) ->
|
||||
return unless 0 <= x < @width and 0 <= y < @height
|
||||
idx = @_project x, y
|
||||
@ -58,6 +62,7 @@ module.exports = class BrailleBuffer
|
||||
cb idx, mask
|
||||
|
||||
_termColor: (foreground, background) ->
|
||||
background = background or @globalBackground
|
||||
if foreground and background
|
||||
"\x1B[38;5;#{foreground};48;5;#{background}m"
|
||||
else if foreground
|
||||
|
@ -50,6 +50,9 @@ module.exports = class Canvas
|
||||
bresenham projected[i-1]..., projected[i]...,
|
||||
(x, y) => @buffer.setPixel x, y, color
|
||||
|
||||
setBackground: (color) ->
|
||||
@buffer.setGlobalBackground color
|
||||
|
||||
background: (x, y, color) ->
|
||||
point = @_project x, y
|
||||
@buffer.setBackground point[0], point[1], color
|
||||
|
@ -85,10 +85,9 @@ module.exports = class Renderer
|
||||
@labelBuffer.clear()
|
||||
|
||||
# TODO: better way for background color instead of setting filling FG?
|
||||
# if color = @styler.styleById['background']?.paint['background-color']
|
||||
# @canvas.strokeStyle = x256 utils.hex2rgb(color)...
|
||||
# @canvas.fillRect 0, 0, @width, @height
|
||||
# else
|
||||
if color = @styler.styleById['background']?.paint['background-color']
|
||||
@canvas.setBackground x256 utils.hex2rgb color
|
||||
|
||||
@canvas.clear()
|
||||
@canvas.reset()
|
||||
|
||||
|
@ -15,7 +15,7 @@ utils = require './utils'
|
||||
|
||||
module.exports = class Termap
|
||||
config:
|
||||
styleFile: __dirname+"/../styles/bright.json"
|
||||
styleFile: __dirname+"/../styles/basic.json"
|
||||
zoomStep: 0.4
|
||||
|
||||
width: null
|
||||
|
@ -1158,14 +1158,6 @@
|
||||
},
|
||||
"source-layer": "housenum_label"
|
||||
},
|
||||
{
|
||||
"type": "symbol",
|
||||
"id": "water_label",
|
||||
"paint": {
|
||||
"text-color": "#333"
|
||||
},
|
||||
"source-layer": "housenum_label"
|
||||
},
|
||||
{
|
||||
"type": "symbol",
|
||||
"id": "place_label_other",
|
||||
|
Loading…
Reference in New Issue
Block a user