Overlapping path detection in Android

enter image description hereI want to know if there is any way to determine if the current path touches a path / crosses an existing path. The existing path is either drawn, or partially in the background. It would also be useful if I can find this after the current path has been completely drawn. In the worst case, can I do some stepwise testing to see if the two paths touch?

+5
source share
2 answers

Use the path to define the string, then set this path for android.graphics.Region. Later check all regions against each other, they intersect or not,

region1.op(region2, Op.INTERSECT);
0
source

, , , , , . , stackoverflow.

    ArrayList<Pair<Pair<Integer,Integer>,Pair<Integer,Integer>>> lineList = new ArrayList<Pair<Pair<Integer, Integer>, Pair<Integer, Integer>>>();

    // add all your lines to the list
    // lineList.add(line);

    // handle the last line
    int startX = 10;
    int startY = 20;
    int endX = 40;
    int endY = 50;

    Pair<Integer,Integer> lineStart = new Pair<Integer, Integer>(startX, startY);
    Pair<Integer,Integer> lineEnd = new Pair<Integer, Integer>(startX, startY);
    Pair<Pair<Integer,Integer>,Pair<Integer,Integer>> lastLine = new Pair<Pair<Integer, Integer>, Pair<Integer, Integer>>(lineStart, lineEnd);

    for(Pair<Pair<Integer,Integer>,Pair<Integer,Integer>> l: lineList){
        // if "lastLine" intersects "l" do you stuff
    }
0

All Articles