If I have an NSBezierPath
object, is there a way to get coordinates(x,y) of all the points drawn? I want to move an NSRect
along the path.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
An NSBezierPath doesn't define exactly which points it draws in, but it does contain the points needed to define its pieces. You can use the
elementAtIndex:associatedPoints:
method to get the points for each vector element in the path. To get each point in the path you would have to iterate over all of the elements and get the associated points. For straight lines, this method will give you the endpoint, but if you keep track of the previous point you can use as many points as you want between them.For curves, you would need to implement the code to determine the curve's path to find points along the curve. It would be much simpler to flatten the path, using
bezierPathByFlatteningPath
, which returns a new path with all curves converted into straight lines.Here's an example which flattens a path and prints the endpoints of all lines in the result. If your path contains long straight lines, you will want to add points along lines depending on the length.
No, because a path is vector based, not pixel based. You would have to render the path in a
CGContextRef
, and then check which pixels got set from that. But there is no built in method for this.If you need to move a rectangle along the path, however, you could probably use a
CALayer
to do this, although I'm not entirely sure how.