Element point map for html5 canvas element, need algorithm

Posted by Artiom Chilaru on Stack Overflow See other posts from Stack Overflow or by Artiom Chilaru
Published on 2010-04-24T18:33:08Z Indexed on 2010/04/24 19:13 UTC
Read the original article Hit count: 243

Filed under:
|

I'm currently working on a pure html 5 canvas implementation of the "flying tag cloud sphere", which many of you have undoubtedly seen as a flash object in some pages.

The tags are drawn fine, and the performance is satisfactory, but there's one thing in the canvas element that's kind of breaking this idea: you can't identify the objects that you've drawn on a canvas, as it's just a simple flat "image"..

What I have to do in this case is catch the click event, and try to "guess" which element was clicked. So I have to have some kind of matrix, which stores a link to a tag object for each pixel on the canvas, AND I have to update this matrix on every redraw. Now this sounds incredibly inefficient, and before I even start trying to implement this, I want to ask the community - is there some "well known" algorithm that would help me in this case? Or maybe I'm just missing something, and the answer is right behind the corner? :)

© Stack Overflow or respective owner

Related posts about html5

Related posts about canvas