Moved setCanvasOffset to layer

This commit is contained in:
unsettledgames
2020-07-21 22:30:46 +02:00
parent 466eb0580c
commit 81cc4c8900
5 changed files with 28 additions and 54 deletions

View File

@ -16,24 +16,4 @@ function getCursorPosition(e) {
y -= canvas.offsetTop;
return [x,y];
}
//get cursor position relative to canvas
function getCursorPositionRelative(e, layer) {
var x;
var y;
if (e.pageX != undefined && e.pageY != undefined) {
x = e.pageX;
y = e.pageY;
}
else {
x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
x -= layer.canvas.offsetLeft;
y -= layer.canvas.offsetTop;
return [x,y];
}
}