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