getIntersection gives wrong key due to anti-aliasing
Closed this issue · 1 comments
bernieke commented
When you draw an arc (circle) as hitbox, you'll notice that at the boundary it's possible for getIntersection to return the wrong key.
I'm assuming this has to do with anti-aliasing, where additional pixels with different colors are added by the browser to smooth the arc.
Maybe the color check could be expanded to make sure at least three neighboring pixels (out of a 3x3 square) have the same color?
ericdrowell commented
that is correct - and yes, there are a few ways to get around this. checking neighboring pixels however is also error prone. The safest, surest way to avoid this issue is to draw your hit regions using whole pixels. For example https://www.geeksforgeeks.org/bresenhams-circle-drawing-algorithm/