I've have recently figured out how to click on a javascript canvas, but there is a problem when I try to scale the image with CSS, it just doesn't work. This is what I learned to do for the canvas clicking stuff:
window.onload = function(){
c = document.getElementById("C");
g = c.getContext("2d");
c.addEventListener("mousemove", mouseUpdate);
}
function mouseUpdate(event){
mouseX = event.pageX - c.offsetLeft;
mouseY = event.pageY - c.offsetTop;
}
This code works but the second I add CSS to scale the canvas...
#C{
width:80%;
height:80%;
}
The the mouse is miss aligned again. The canvas is set to be 1920x1080, and scaled down by 80%. Does anyone know already how to fix this problem, because I haven't found anyone else with the same problem that has issues with CSS...