diff --git a/js/macros/edit.js b/js/macros/edit.js index fade46ae1..ee6e5a924 100644 --- a/js/macros/edit.js +++ b/js/macros/edit.js @@ -96,20 +96,24 @@ BitmapEditor.prototype.addEventHandlers = function() { },false); }; -BitmapEditor.prototype.strokeStart = function(x,y) { +BitmapEditor.prototype.adjustCoordinates = function(x,y) { var canvas = this.macroNode.content[0].domNode, - canvasRect = canvas.getBoundingClientRect(); + canvasRect = canvas.getBoundingClientRect(), + scale = canvas.width/canvasRect.width; + return {x: (x - canvasRect.left) * scale, y: (y - canvasRect.top) * scale}; +}; + +BitmapEditor.prototype.strokeStart = function(x,y) { // Start off a new stroke - this.stroke = [{x: x - canvasRect.left, y: y - canvasRect.top}]; + this.stroke = [this.adjustCoordinates(x,y)]; }; BitmapEditor.prototype.strokeMove = function(x,y) { var canvas = this.macroNode.content[0].domNode, - canvasRect = canvas.getBoundingClientRect(), ctx = canvas.getContext("2d"), t; // Add the new position to the end of the stroke - this.stroke.push({x: x - canvasRect.left, y: y - canvasRect.top}); + this.stroke.push(this.adjustCoordinates(x,y)); // Redraw the previous image ctx.drawImage(this.currCanvas,0,0); // Render the stroke @@ -121,9 +125,9 @@ BitmapEditor.prototype.strokeMove = function(x,y) { for(t=1; t