If you are looking for such interactivity, <canvas> is probably not what you want. You are looking for SVG . There is a fantastic library called Raphaël that allows you to work with the SVG piece of cake in all browsers, even on IE6. It is also fully compatible with jQuery , so you can:
var paper = Raphael(10, 50, 320, 200); var img = paper.image("/path/to/img.png", 10, 10, 80, 80); $(img).click(onImgClick);
I am sure that it will be better for you and be easier to use than <canvas> .
Note. Raphaël has some helpers for major events, such as "click" and "mousedown", just do img.click(onImgClick) , but if you already use the jQuery library, which you probably know, I would recommend consistency and use of processing library events.
bcherry
source share