From what I can understand in the documentation, I can use the Path.op() method in order to perform an operation on a path. Perhaps I'm misunderstanding something however, because writing this unit test:
public void testInsidePathHits() {
Path path = new Path();
path.moveTo(500, 490);
path.lineTo(500, 510);
Path intersectPath = new Path();
intersectPath.addCircle(500, 500, 75, Path.Direction.CW);
intersectPath.op(path, Path.Op.INTERSECT);
boolean isHit = !intersectPath.isEmpty();
assertTrue("The line should cross through the target", isHit);
}
fails. Meaning that my code is telling me that the paths do not intersect - which is impossible since path
is fully contained within the bounds of intersectPath
.
Can anyone shed some light on this?
Edit: Using regions does not seem to change anything as:
Region region1 = new Region();
region1.setPath(path, clip);
Region region2 = new Region();
region2.setPath(intersectPath, clip);
boolean isHit = !region1.quickReject(region2) && region1.op(region2, Region.Op.INTERSECT);
still fails the assertion.