canvas actual height,width is bigger than style height, width.
<canvas id="canvas" class="page" width="1190" height="1683" style="height: 841.68px; width: 595.44px;"></canvas>
What calculations that needs to be considered when finding proper mouse position in this case. Current code for mouse position is
function getMousePos(canvas, evt) {
let ancestor = document.getElementById('viewer')
var offsetAncestor = ancestor.getBoundingClientRect();
var rect = canvas.getBoundingClientRect(), // abs. size of element
scaleX = canvas.width / rect.width, // relationship bitmap vs. element for X
scaleY = canvas.height / rect.height; // relationship bitmap vs. element for Y
// return {
// x: (evt.clientX - rect.left) * scaleX, // scale mouse coordinates after they have
// y: (evt.clientY - rect.top) * scaleY // been adjusted to be relative to element
// }
return {
x: (evt.clientX - (rect.left - offsetAncestor.left)), // scale mouse coordinates after they have
y: (evt.clientY - (rect.top + offsetAncestor.top)) // been adjusted to be relative to element
}
}