🐁 working on mouse projection

This commit is contained in:
Michael Straßburger 2016-11-10 18:43:35 +01:00
parent f9c16f2d6d
commit ef6ab82376

View File

@ -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