You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While a voronoi or quadtree can be used as a technique for single point events (i.e. tooltips), hit detection for paths/rects/etc (ex. GeoPath or Pie arcs) are more challenging.
Using the r-tree algorithm such as is available with Flatbush provides fast boundary box lookups, although you can get multiple results for overlapping boxes and will need to do a deeper compare (using something like geoContains())
Another technique is to draw a second (hidden) canvas with distinct colors and register data for each color in a lookup, and then use context.getImageData() to get the color for the pointer coordinates, and return the data. This has some challenges with canvas anti-aliasing on the edges, but is simpler (especially without needing a deeper comparison)
While a voronoi or quadtree can be used as a technique for single point events (i.e. tooltips), hit detection for paths/rects/etc (ex. GeoPath or Pie arcs) are more challenging.
Using the r-tree algorithm such as is available with Flatbush provides fast boundary box lookups, although you can get multiple results for overlapping boxes and will need to do a deeper compare (using something like
geoContains()
)Another technique is to draw a second (hidden) canvas with distinct colors and register data for each color in a lookup, and then use
context.getImageData()
to get the color for the pointer coordinates, and return the data. This has some challenges with canvas anti-aliasing on the edges, but is simpler (especially without needing a deeper comparison)The text was updated successfully, but these errors were encountered: