How to get the CGPoint(s) of a CGPath

前端 未结 4 1166
天命终不由人
天命终不由人 2020-11-27 04:22

How can I get an array with all the CGPoint(s) contained in a given CGPath (CGMutablePathRef)?

4条回答
  •  难免孤独
    2020-11-27 04:47

    You can use CGPathApply() to iterate over every segment in the path and run a custom function with that segment. That will give you all the information the path has.

    However, if by "all the CGPoint(s)", you meant every point that has a pixel rendered to it, that's an infinitely-sized set. Although you could certainly use the apply function to get each segment, and then for every non-move segment, evaluate your own math with the segment's control points to get a list of points at whatever density you want.

提交回复
热议问题