I want to detect clicks on canvas elements which are drawn using paths. So far I have stored element paths in a JavaScript data structure and then check the coordinates of hits which match the element's coordinates. Rendering each element path and checking the hits would be inefficient when there are a lot of elements. I believe there must be an algorithm for this kind of coordinate search, can anyone help me with this?
feedback
|
You should probably take a look at engines that already do that like: But I'm pretty sure they maintain some state relative to position and shape and check against those for every frame update. | |||
feedback
|