Open bluepixeltech opened 2 years ago
Hi! I'm glad to hear you're finding the library useful :)
I believe you'll be able to get what you want if you use an unclosed circle path. UIBezierPath(ovalIn: frame)
will create a path that has a .closePath
element as its last element. If you instead trim off that closePath element:
// a circle is closed and has 2 or more elements
var circlePath = UIBezierPath(ovalIn: frame)
assert(circlePath.isClosed && circlePath.elementCount >= 2)
// trim off the last closePath element
circlePath = circlePath.trimming(toElement: circlePath.elementCount - 2, andTValue: 1.0)
assert(!circlePath.isClosed)
// now using circlePath for the intersection won't return a closed shape
I think that'll do what you need. there's a chance that the closePath element is inside the box, which means the intersection will return up to two pieces of the circle. the order you append them may make a difference as well, so keep that in mind.
Thanks a lot!
First of all thank you for the very useful library you created! I have a question regarding the intersection of two paths and I hope you will have a chance to help me. Suppose that we have two paths like the following image, one rectangle and a circle. We I get the intersection of the two as an array and then append them the result is a path depicted in red in the image which is correct. However, for my application I need to exclude the line in the red path and only keep the arc. How can I do that? Thank you in advance.
n