mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 23:53:08 +01:00
✅ handling console resize, adding mvp status bar
This commit is contained in:
parent
44192bbbd0
commit
b790a4d76a
@ -14,6 +14,7 @@ Discover the world in your console - render vector tile maps from any source!
|
||||
* [ ] setCenter
|
||||
* [ ] setZoom
|
||||
* [x] accurate mouse drag&drop
|
||||
* [x] handle console resize
|
||||
|
||||
## Wishlist
|
||||
* node-gyp binding to [libdrawille](https://github.com/Huulivoide/libdrawille) for speed refactor possibilities + filled polygons
|
||||
|
@ -8,8 +8,8 @@ mouse = require('term-mouse')()
|
||||
|
||||
keypress process.stdin
|
||||
|
||||
width = Math.floor((process.stdout.columns-1)/2)*2*2;
|
||||
height = Math.ceil(process.stdout.rows/4)*4*4;
|
||||
width = null
|
||||
height = null
|
||||
|
||||
drawOrder = ["admin", "water", "landuse", "building", "road"]
|
||||
layers =
|
||||
@ -19,7 +19,13 @@ layers =
|
||||
admin: "red"
|
||||
building: 8
|
||||
|
||||
canvas = new Canvas width, height
|
||||
canvas = null
|
||||
|
||||
init = ->
|
||||
width = Math.floor((process.stdout.columns-1)/2)*2*2
|
||||
height = Math.ceil(process.stdout.rows/4)*4*4
|
||||
canvas = new Canvas width, height
|
||||
init()
|
||||
|
||||
features = {}
|
||||
data = fs.readFileSync __dirname+"/tiles/regensburg.pbf.gz"
|
||||
@ -42,7 +48,10 @@ size = 4
|
||||
flush = ->
|
||||
process.stdout.write canvas._canvas.frame()
|
||||
|
||||
drawing = false
|
||||
draw = ->
|
||||
return if drawing
|
||||
drawing = true
|
||||
canvas.clearRect(0, 0, width, height)
|
||||
|
||||
canvas.save()
|
||||
@ -69,7 +78,12 @@ draw = ->
|
||||
|
||||
canvas.restore()
|
||||
flush()
|
||||
process.stdout.write getStatus()
|
||||
|
||||
drawing = false
|
||||
|
||||
getStatus = ->
|
||||
"view: [#{view.toString()}] scale: [#{size}] columns: [#{process.stdout.columns}]"
|
||||
|
||||
moving = null
|
||||
process.stdin.on 'mousepress', (info) ->
|
||||
@ -110,5 +124,9 @@ process.stdin.on 'keypress', (ch, key) ->
|
||||
|
||||
draw() if result
|
||||
|
||||
process.stdout.on 'resize', ->
|
||||
init()
|
||||
draw()
|
||||
|
||||
process.stdin.setRawMode(true)
|
||||
process.stdin.resume()
|
||||
|
Loading…
Reference in New Issue
Block a user