This script shows how to capture the mouse positions and mouse click within a HTML5 canvas. In addition, a hotspot polygon (should be convex) object defined can be used as a generic object for other project. More than one hotspot polygon can be defined in the same canvas.
To test the code, move the mouse over the following area, click anywhere as you wish.
For the following code to function properly in Firefox, you should add style="position: relative;" in the <canvas> tag.
Source Code
No comments:
Post a Comment