kopia lustrzana https://github.com/rastapasta/mapscii
🎨 optimizing canvas size calculation
rodzic
3f01b85e81
commit
334032da59
2
main.js
2
main.js
|
@ -17,7 +17,7 @@ const Tile = require(__dirname+'/src/Tile')
|
|||
termap = new Termap();
|
||||
|
||||
// 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);
|
||||
termap.renderer.features = tile.layers
|
||||
termap._draw();
|
||||
|
|
|
@ -73,7 +73,7 @@ module.exports = class BrailleBuffer
|
|||
delimeter = "\n"
|
||||
|
||||
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]
|
||||
output.push currentColor = colorCode
|
||||
|
|
|
@ -19,7 +19,18 @@ module.exports = class Renderer
|
|||
labelMargin: 5
|
||||
|
||||
#"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:
|
||||
car: "🚗"
|
||||
|
@ -155,7 +166,7 @@ module.exports = class Renderer
|
|||
|
||||
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
|
||||
else if @config.layers[layer]?.cluster and @labelBuffer.writeIfPossible "X", x, point[1], 3
|
||||
write "◉"
|
||||
|
|
|
@ -65,8 +65,8 @@ module.exports = class Termap
|
|||
@zoom = Math.log(4096/@width)/Math.LN2
|
||||
|
||||
_resizeRenderer: (cb) ->
|
||||
@width = (process.stdout.columns-1) >> 1 << 2
|
||||
@height = process.stdout.rows * 4 - 8
|
||||
@width = process.stdout.columns >> 1 << 2
|
||||
@height = process.stdout.rows * 4
|
||||
|
||||
@renderer.setSize @width, @height
|
||||
|
||||
|
|
|
@ -1158,6 +1158,14 @@
|
|||
},
|
||||
"source-layer": "housenum_label"
|
||||
},
|
||||
{
|
||||
"type": "symbol",
|
||||
"id": "water_label",
|
||||
"paint": {
|
||||
"text-color": "#333"
|
||||
},
|
||||
"source-layer": "housenum_label"
|
||||
},
|
||||
{
|
||||
"type": "symbol",
|
||||
"id": "place_label_other",
|
||||
|
|
Plik binarny nie jest wyświetlany.
Ładowanie…
Reference in New Issue