mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-25 01:23:58 +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
|
* [ ] setCenter
|
||||||
* [ ] setZoom
|
* [ ] setZoom
|
||||||
* [x] accurate mouse drag&drop
|
* [x] accurate mouse drag&drop
|
||||||
|
* [x] handle console resize
|
||||||
|
|
||||||
## Wishlist
|
## Wishlist
|
||||||
* node-gyp binding to [libdrawille](https://github.com/Huulivoide/libdrawille) for speed refactor possibilities + filled polygons
|
* 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
|
keypress process.stdin
|
||||||
|
|
||||||
width = Math.floor((process.stdout.columns-1)/2)*2*2;
|
width = null
|
||||||
height = Math.ceil(process.stdout.rows/4)*4*4;
|
height = null
|
||||||
|
|
||||||
drawOrder = ["admin", "water", "landuse", "building", "road"]
|
drawOrder = ["admin", "water", "landuse", "building", "road"]
|
||||||
layers =
|
layers =
|
||||||
@ -19,7 +19,13 @@ layers =
|
|||||||
admin: "red"
|
admin: "red"
|
||||||
building: 8
|
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 = {}
|
features = {}
|
||||||
data = fs.readFileSync __dirname+"/tiles/regensburg.pbf.gz"
|
data = fs.readFileSync __dirname+"/tiles/regensburg.pbf.gz"
|
||||||
@ -42,7 +48,10 @@ size = 4
|
|||||||
flush = ->
|
flush = ->
|
||||||
process.stdout.write canvas._canvas.frame()
|
process.stdout.write canvas._canvas.frame()
|
||||||
|
|
||||||
|
drawing = false
|
||||||
draw = ->
|
draw = ->
|
||||||
|
return if drawing
|
||||||
|
drawing = true
|
||||||
canvas.clearRect(0, 0, width, height)
|
canvas.clearRect(0, 0, width, height)
|
||||||
|
|
||||||
canvas.save()
|
canvas.save()
|
||||||
@ -69,7 +78,12 @@ draw = ->
|
|||||||
|
|
||||||
canvas.restore()
|
canvas.restore()
|
||||||
flush()
|
flush()
|
||||||
|
process.stdout.write getStatus()
|
||||||
|
|
||||||
|
drawing = false
|
||||||
|
|
||||||
|
getStatus = ->
|
||||||
|
"view: [#{view.toString()}] scale: [#{size}] columns: [#{process.stdout.columns}]"
|
||||||
|
|
||||||
moving = null
|
moving = null
|
||||||
process.stdin.on 'mousepress', (info) ->
|
process.stdin.on 'mousepress', (info) ->
|
||||||
@ -110,5 +124,9 @@ process.stdin.on 'keypress', (ch, key) ->
|
|||||||
|
|
||||||
draw() if result
|
draw() if result
|
||||||
|
|
||||||
|
process.stdout.on 'resize', ->
|
||||||
|
init()
|
||||||
|
draw()
|
||||||
|
|
||||||
process.stdin.setRawMode(true)
|
process.stdin.setRawMode(true)
|
||||||
process.stdin.resume()
|
process.stdin.resume()
|
||||||
|
Loading…
Reference in New Issue
Block a user