如何获得CGPath的CGPoint [英] How to get the CGPoint(s) of a CGPath
问题描述
如何获得包含在给定 CGPath
中的所有 CGPoint
(s)的数组( CGMutablePathRef
)?
How can I get an array with all the CGPoint
(s) contained in a given CGPath
(CGMutablePathRef
)?
推荐答案
您可以使用 CGPathApply()以在路径中的每个段迭代和运行与该段的自定义功能。这将为您提供路径所具有的所有信息。
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.
但是,如果通过所有CGPoint(s),则表示每个点都有一个像素呈现给它,这是一个无限大小的集合。虽然您当然可以使用apply函数来获取每个段,然后对于每个非移动段,使用段的控制点评估您自己的数学运算,以获得您想要的任何密度的点列表。
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.
这篇关于如何获得CGPath的CGPoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!