↪️ implemting Canvas.rotate and prototype degree control (k & l)

This commit is contained in:
Michael Straßburger 2016-09-29 20:35:22 +02:00
parent 0e481bf5c9
commit bdfcae4fa0
3 changed files with 15 additions and 7 deletions

View File

@ -37,6 +37,9 @@ module.exports = class Canvas
translate: (x, y) ->
mat2d.translate @matrix, @matrix, vec2.fromValues(x, y)
rotate: (angle) ->
mat2d.rotate @matrix, @matrix, angle/180*Math.PI
clear: ->
@buffer.clear()

View File

@ -76,7 +76,7 @@ module.exports = class Renderer
setSize: (@width, @height) ->
@canvas = new Canvas @width, @height
draw: (@view, @zoom) ->
draw: (@view, @zoom, @degree) ->
return if @isDrawing
@isDrawing = true
@lastDrawAt = Date.now()

View File

@ -26,6 +26,7 @@ module.exports = class Termap
mousePosition: [0, 0]
mouseDragging: false
degree: 0
center:
lat: 0
lng: 0
@ -110,23 +111,27 @@ module.exports = class Termap
when "z" then @zoomBy @config.zoomStep
when "a" then @zoomBy -@config.zoomStep
when "k" then @degree += 15
when "l" then @degree -= 15
when "left" then @view[0] += 5
when "right" then @view[0] -= 5
when "up" then @view[1]+= 5
when "down" then @view[1]-= 5
else
false
null
if draw
if draw isnt null
@_draw()
# else
# # display debug info for unhandled keys
# @notify JSON.stringify key
else
# display debug info for unhandled keys
@renderer.notify JSON.stringify key
_draw: ->
@renderer.draw @view, @zoom
@renderer.draw @view, @zoom, @degree
@renderer.notify @_getFooter()
_getTiles: ->