mirror of
https://github.com/rastapasta/mapscii.git
synced 2025-06-20 09:47:41 +02:00
🎨 optimizing canvas size calculation
This commit is contained in:
parent
3f01b85e81
commit
334032da59
2
main.js
2
main.js
@ -17,7 +17,7 @@ const Tile = require(__dirname+'/src/Tile')
|
|||||||
termap = new Termap();
|
termap = new Termap();
|
||||||
|
|
||||||
// TODO: abstracing this class, create loader class
|
// TODO: abstracing this class, create loader class
|
||||||
data = fs.readFileSync(__dirname+"/tiles/regensburg.pbf.gz");
|
data = fs.readFileSync(__dirname+"/tiles/germany.pbf.gz");
|
||||||
tile = new Tile(data);
|
tile = new Tile(data);
|
||||||
termap.renderer.features = tile.layers
|
termap.renderer.features = tile.layers
|
||||||
termap._draw();
|
termap._draw();
|
||||||
|
@ -73,7 +73,7 @@ module.exports = class BrailleBuffer
|
|||||||
delimeter = "\n"
|
delimeter = "\n"
|
||||||
|
|
||||||
for idx in [0...@pixelBuffer.length]
|
for idx in [0...@pixelBuffer.length]
|
||||||
output.push delimeter unless idx % (@width/2)
|
output.push delimeter if idx and (idx % (@width/2)) is 0
|
||||||
|
|
||||||
if currentColor isnt colorCode = @_termColor @foregroundBuffer[idx], @backgroundBuffer[idx]
|
if currentColor isnt colorCode = @_termColor @foregroundBuffer[idx], @backgroundBuffer[idx]
|
||||||
output.push currentColor = colorCode
|
output.push currentColor = colorCode
|
||||||
|
@ -19,7 +19,18 @@ module.exports = class Renderer
|
|||||||
labelMargin: 5
|
labelMargin: 5
|
||||||
|
|
||||||
#"poi_label", "water",
|
#"poi_label", "water",
|
||||||
drawOrder: ["water", "admin", "building", "road", "place_label", "poi_label", "housenum_label"]
|
drawOrder: [
|
||||||
|
"water"
|
||||||
|
"water_label"
|
||||||
|
"admin"
|
||||||
|
"building"
|
||||||
|
"road"
|
||||||
|
"place_label"
|
||||||
|
"poi_label"
|
||||||
|
"housenum_label"
|
||||||
|
"country_label"
|
||||||
|
"state_label"
|
||||||
|
]
|
||||||
|
|
||||||
icons:
|
icons:
|
||||||
car: "🚗"
|
car: "🚗"
|
||||||
@ -155,7 +166,7 @@ module.exports = class Renderer
|
|||||||
|
|
||||||
write = (text) => @canvas.text text, x, point[1], colorCode, false
|
write = (text) => @canvas.text text, x, point[1], colorCode, false
|
||||||
|
|
||||||
if @labelBuffer.writeIfPossible text, x, point[1],
|
if @labelBuffer.writeIfPossible text, x, point[1], margin
|
||||||
write text
|
write text
|
||||||
else if @config.layers[layer]?.cluster and @labelBuffer.writeIfPossible "X", x, point[1], 3
|
else if @config.layers[layer]?.cluster and @labelBuffer.writeIfPossible "X", x, point[1], 3
|
||||||
write "◉"
|
write "◉"
|
||||||
|
@ -65,8 +65,8 @@ module.exports = class Termap
|
|||||||
@zoom = Math.log(4096/@width)/Math.LN2
|
@zoom = Math.log(4096/@width)/Math.LN2
|
||||||
|
|
||||||
_resizeRenderer: (cb) ->
|
_resizeRenderer: (cb) ->
|
||||||
@width = (process.stdout.columns-1) >> 1 << 2
|
@width = process.stdout.columns >> 1 << 2
|
||||||
@height = process.stdout.rows * 4 - 8
|
@height = process.stdout.rows * 4
|
||||||
|
|
||||||
@renderer.setSize @width, @height
|
@renderer.setSize @width, @height
|
||||||
|
|
||||||
|
@ -1158,6 +1158,14 @@
|
|||||||
},
|
},
|
||||||
"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",
|
||||||
|
BIN
tiles/germany.pbf.gz
Normal file
BIN
tiles/germany.pbf.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user