So, I know a similar question has been asked before but this is asking for something slightly different: My canvas has a x%
CSS style width and a y
width. Nothing is constant, but an example would be:
canvas.style.width;
// Returns: 60%
canvas.width;
// Returns: 800
So, I need to figure out how to find the X on the canvas where the mouse is (the position should be in the canvas' width so for example, if you were to click on a coordinate it would draw that coordinate on the canvas).
How can I do this knowing that 1px
of my screen does not equal 1px
of my canvas? I know how to evaluate the Y once I get the equation for the X.