Thursday, 20 December 2018

How to subtract the intersection of UIBezierPath A&B from A?

Suppose we have two UIBezierPaths, path1 and path2.

We want to get a new path that is the result of subtracting path2 from path1:

enter image description here

The way this is done (as seen here) is to do this:

path1.append(path2.reversing())

BUT, that only seems to work for circumstances where path1 fully encompasses path2.

For example, consider the case where there is only a partial intersection -- path1 does not fully encompass path2. This is what happens if we apply the same method as above:

enter image description here

In Android, the answer is:

path1.op(path2, Path.Op.DIFFERENCE);

So... how do you perform this operation on IOS?



from How to subtract the intersection of UIBezierPath A&B from A?

No comments:

Post a Comment