diff options
Diffstat (limited to 'assets/javascripts/rectangles/map')
| -rw-r--r-- | assets/javascripts/rectangles/map/_map.js | 3 | ||||
| -rw-r--r-- | assets/javascripts/rectangles/map/ui.js | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/assets/javascripts/rectangles/map/_map.js b/assets/javascripts/rectangles/map/_map.js index 833df7a..b0d0b60 100644 --- a/assets/javascripts/rectangles/map/_map.js +++ b/assets/javascripts/rectangles/map/_map.js @@ -8,6 +8,8 @@ var map = new function(){ base.bounds = new vec2(500,500) base.center = new vec2(0,0) + base.zoom = 1/2 + var canvas = document.createElement("canvas") var ctx = window.ctx = canvas.getContext("2d") var w = window.w = canvas.width = 500 @@ -19,6 +21,7 @@ var map = new function(){ map.draw.clear_canvas() map.draw.ruler() + ctx.scale( base.zoom, base.zoom ) ctx.translate( map.center.a + map.bounds.a/2, map.center.b + map.bounds.b/2 ) ctx.scale( -1, 1 ) diff --git a/assets/javascripts/rectangles/map/ui.js b/assets/javascripts/rectangles/map/ui.js index cc9a560..9faebea 100644 --- a/assets/javascripts/rectangles/map/ui.js +++ b/assets/javascripts/rectangles/map/ui.js @@ -24,8 +24,8 @@ map.ui = new function(){ // function down (e, cursor){ - cursor.x.add( map.center.a + map.bounds.a/2 ) - cursor.y.add( -map.center.b - map.bounds.b/2 ) + cursor.x.div(map.zoom).add( map.center.a + map.bounds.a/2 ) + cursor.y.div(map.zoom).add( -map.center.b - map.bounds.b/2 ) var intersects = clipper.rooms.filter(function(r){ return r.focused = r.rect.contains(cursor.x.a, cursor.y.a) @@ -44,14 +44,13 @@ map.ui = new function(){ } function move (e, cursor) { - cursor.x.add( map.center.a + map.bounds.a/2 ) - cursor.y.add( -map.center.b - map.bounds.b/2 ) - z=true + cursor.x.div(map.zoom).add( map.center.a + map.bounds.a/2 ) + cursor.y.div(map.zoom).add( -map.center.b - map.bounds.b/2 ) } function drag (e, cursor) { - cursor.x.b += map.center.a + map.bounds.a/2 - cursor.y.b += -map.center.b - map.bounds.b/2 + cursor.x.b = (cursor.x.b / map.zoom) + map.center.a + map.bounds.a/2 + cursor.y.b = (cursor.y.b / map.zoom) - map.center.b - map.bounds.b/2 if (base.dragging) { base.dragging.rect.translation.a = cursor.x.magnitude() |
