diff options
Diffstat (limited to 'assets/javascripts/rectangles/map/draw.js')
| -rw-r--r-- | assets/javascripts/rectangles/map/draw.js | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/assets/javascripts/rectangles/map/draw.js b/assets/javascripts/rectangles/map/draw.js index e15b083..518c160 100644 --- a/assets/javascripts/rectangles/map/draw.js +++ b/assets/javascripts/rectangles/map/draw.js @@ -8,23 +8,20 @@ map.draw = new function(){ map.draw.clear_canvas() map.draw.ruler() -// ctx.scale( map.zoom, map.zoom ) -// ctx.translate( map.center.a + map.bounds.a/2, map.center.b + map.bounds.b/2 ) -// ctx.scale( -1, 1 ) - - ctx.translate( map.center.a, map.center.b ) - ctx.translate( +map.bounds.a/2, +map.bounds.b/2 ) + ctx.translate( map.bounds.a * 1/2, map.bounds.b * 1/2) ctx.scale( map.zoom, map.zoom ) + ctx.translate( map.center.a, map.center.b) ctx.scale( -1, 1 ) map.draw.regions(clipper.regions) map.draw.mouse(map.ui.mouse.cursor) + map.draw.coords() scene && map.draw.camera(scene.camera) ctx.restore() } - base.clear_canvas = function (){ + base.clear_canvas = function(){ ctx.fillStyle = "rgba(255,255,255,0.99)" ctx.clearRect(0,0,w,h) ctx.fillRect(0,0,w,h) @@ -91,6 +88,20 @@ map.draw = new function(){ ctx.restore() } + base.coords = function(){ + ctx.fillStyle = "#888"; + dot_at(0,0) + ctx.fillStyle = "#bbb"; + dot_at(100,0) + dot_at(0,100) + ctx.fillStyle = "#ddd"; + dot_at(200,0) + dot_at(0,200) + ctx.fillStyle = "#eee"; + dot_at(300,0) + dot_at(0,300) + } + // function line (x,y,a,b,translation){ @@ -123,4 +134,17 @@ map.draw = new function(){ function stroke_rect (r){ line(r.x.a, r.y.a, r.x.b, r.y.b, r.translation) } + + function dot_at (x,z){ + ctx.save() + ctx.translate(x,z) + + var radius = 3 / map.zoom + + ctx.beginPath(); + ctx.arc(0, 0, radius, 0, 2*Math.PI, false); + ctx.fill(); + + ctx.restore() + } }
\ No newline at end of file |
