Wednesday, 10 October 2012

HTML5 Canvas - Detect Mouse Position

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.


This text is displayed if your browser does not support HTML5 Canvas.

Source Code


No comments:

Post a Comment