简体   繁体   中英

Android Java: Region Subtraction

Is it possible to subtract one Region object and subtract it from another?

Eg I have a two Regions, region1 (green) and region2 (red):

图片

How would I create a region3 that is only the part of region1 that is not also part of region2 (only green and NOT red)?

    Region r1;
    Region r2;
    Region r3 = new Region(r1); // make a copy to not change r1
    r3.op(r2, Op.DIFFERENCE); // r3 = r1-r2

If you're not bothered about changing r1 , obviously you can skip the copy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM