From 29b69a9e83fb0f4f9d98fa772a07fb504c6472c8 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Fri, 8 Aug 2014 12:18:05 +0100 Subject: [PATCH] Fixes #195: debug feature now works with rotation. --- src/drawer.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/drawer.js b/src/drawer.js index ebdf9c77..a01751b8 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -1140,12 +1140,24 @@ function drawDebugInfo( drawer, tile, count, i ){ drawer.context.font = 'small-caps bold 13px ariel'; drawer.context.strokeStyle = drawer.debugGridColor; drawer.context.fillStyle = drawer.debugGridColor; + + offsetForRotation( tile, drawer.canvas, drawer.context, drawer.viewport.degrees ); + drawer.context.strokeRect( tile.position.x, tile.position.y, tile.size.x, tile.size.y ); + + var tileCenterX = tile.position.x + (tile.size.x / 2); + var tileCenterY = tile.position.y + (tile.size.y / 2); + + // Rotate the text the right way around. + drawer.context.translate( tileCenterX, tileCenterY ); + drawer.context.rotate( Math.PI / 180 * -drawer.viewport.degrees ); + drawer.context.translate( -tileCenterX, -tileCenterY ); + if( tile.x === 0 && tile.y === 0 ){ drawer.context.fillText( "Zoom: " + drawer.viewport.getZoom(), @@ -1188,6 +1200,7 @@ function drawDebugInfo( drawer, tile, count, i ){ tile.position.x + 10, tile.position.y + 70 ); + restoreRotationChanges( tile, drawer.canvas, drawer.context ); drawer.context.restore(); } }