mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-22 08:03:07 +01:00
🐁 working on mouse projection
This commit is contained in:
parent
f9c16f2d6d
commit
ef6ab82376
@ -15,7 +15,6 @@ utils = require './utils'
|
|||||||
config = require './config'
|
config = require './config'
|
||||||
|
|
||||||
module.exports = class Termap
|
module.exports = class Termap
|
||||||
|
|
||||||
width: null
|
width: null
|
||||||
height: null
|
height: null
|
||||||
canvas: null
|
canvas: null
|
||||||
@ -113,8 +112,9 @@ module.exports = class Termap
|
|||||||
@_draw()
|
@_draw()
|
||||||
|
|
||||||
_onMouseMove: (event) ->
|
_onMouseMove: (event) ->
|
||||||
# only continue if x/y are valid
|
projected =
|
||||||
return unless event.x <= config.output.columns and event.y <= config.output.rows
|
x: event.x * 2
|
||||||
|
y: event.y * 4
|
||||||
|
|
||||||
# start dragging
|
# start dragging
|
||||||
if event.button is "left"
|
if event.button is "left"
|
||||||
@ -130,7 +130,7 @@ module.exports = class Termap
|
|||||||
@mouseDragging = x: event.x, y: event.y
|
@mouseDragging = x: event.x, y: event.y
|
||||||
|
|
||||||
# update internal mouse tracker
|
# update internal mouse tracker
|
||||||
@mousePosition = x: event.x, y: event.y
|
@mousePosition = projected
|
||||||
@notify @_getFooter()
|
@notify @_getFooter()
|
||||||
|
|
||||||
_onKey: (key) ->
|
_onKey: (key) ->
|
||||||
@ -181,7 +181,7 @@ module.exports = class Termap
|
|||||||
|
|
||||||
"center: #{utils.digits @center.lat, 3}, #{utils.digits @center.lon, 3} "+
|
"center: #{utils.digits @center.lat, 3}, #{utils.digits @center.lon, 3} "+
|
||||||
"zoom: #{utils.digits @zoom, 2} "+
|
"zoom: #{utils.digits @zoom, 2} "+
|
||||||
"mouse: #{@mousePosition.x*2-@width/2} #{@mousePosition.y} "
|
"mouse: #{@mousePosition.x-@width/2} #{@mousePosition.y-@height/2} "
|
||||||
|
|
||||||
notify: (text) ->
|
notify: (text) ->
|
||||||
@_write "\r\x1B[K"+text unless config.headless
|
@_write "\r\x1B[K"+text unless config.headless
|
||||||
|
Loading…
Reference in New Issue
Block a user