I'm working on canvas drawing by mouse event.
I wanted to set body tag zoom size around 80% by using
document.body.style.zoom = '80%';
But when I used this code:
The positions of X, Y are wrong.
Here's the code.
function canvasX(clientX) {
var bound = canvas.getBoundingClientRect();
return (clientX - bound.left) * (canvas.width / bound.width);
}
function canvasY(clientY) {
var bound = canvas.getBoundingClientRect();
return (clientY - bound.top) * (canvas.height / bound.height);
}
tried to give layerX, layerY as a parameter but worked bad.
Positions are setted more left(-) and top(-).
It would be great if you help me out to apply zoom size on mouse position.