0

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.

  • http://stackoverflow.com/q/11184397/794088 might help – petey Jan 01 '15 at 00:12
  • Nope, no help that I'm seeing. It suggested using the same Path operation that I'm already using. I tried using Regions as specified in the first comment (see edit above) but it still fails the assertion. – Troy Pavlek Jan 01 '15 at 00:24
  • `Path#op()` methods deal mainly with areas. Apparently, an intersection of a single point is considered empty. You can verify this by checking that the intersection of two line segment `Path`s is empty. – Mike M. Jan 01 '15 at 05:06

0 Answers0