Path contains point


Hi there,

I am on Mac and - at least on my platform - it seems that the hitPath.contains function returns false if the point lies exactly ON the path. You can see this best if you make a rectangular path. In this case if the point to be tested lies on the very first or very last pixel of the rectangle the function returns false. Is this the way it is supposed to work? or does it have to do with the collisionDetectionTolerence parameter?

Can someone shed some light on it, please?

Thank you.

  • Luigi


Well, shapes are floating point, so it’s fairly ambiguous whether a point that’s on the line should be included or not, and with curves you’ll always get a bit of error because it needs to flatten the path to do the detection, so basically I’d say not to make any assumptions about it.

If you’re seeing this because you’re trying to work out whether a pixel is inside a path, then you probably should be adding 0.5 to your coords so that it’s the centre of the pixel you’re testing for, and not its top-left corner?