I have a canvas with 100% width
and height
.
It is part of a remote desktop I am working on. Currently I am stuck because the mouse position does not reflect the position on the canvas correctly.
When I send the data to the desktop I have to compensate for different screen sizes.
var x = Math.floor( mouse.x / canvas.width * 100 );
var y = Math.floor( mouse.y / canvas.height * 100 );
However when I try draw on the canvas with those x
and z
values I am not getting the correct positions.
The reason that I need the canvas / am trying to use percentage is that it is going to be an overlay on top of a video. And the user has to draw a rectangle around the video to get an offset because videos often display black sidebars for aspect ratios.
Here is a example of the canvas that does not put the rectangle in the right position:
Edit: FYI: Firefox does not seem to run the jsfiddle properly due to the way jsfiddle works apparently. Try Chrome.