assign event at figure that I painted in canvas
-
25-10-2019 - |
Question
I want assign event at figure that I painted in canvas..
How to assign event?
example - painted 500px - 500px quadrangle and appear explanation if on mouse over.
Solution
IF you know your quadrangle position, with and height; you can use the following code to get your mouse position.
function onMouseMove(e) {
mouseX = e.clientX - canvas.offsetLeft;
mouseY = e.clientY - canvas.offsetTop;
}
Finally test if your mouse coordinates fall within your quadrangle,
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow