获取有关 CGpath、UIBezierPath 的信息?
我有一系列路径,大部分是直线,或几乎是直线。 我想将它们分类为水平、垂直、对角线以及它们绘制的方向(上->下、下->上、左->右、右->左等)。有些线条是 L 形的,我也想要这些信息。
如果我知道路径的端点,这可能可以完成,但我不知道如何提取该信息。另外,我需要的不仅仅是 L 形线,因为端点将表示对角线。我查看了所有参考页面,但找不到此类信息。 所以,如果你知道这一点,或者以其他方式获取我正在寻找的信息......谢谢
I have a series of paths, mostly straight lines, or almost straight lines.
I'd like to categorize them as horizontal, vertical, diagonal, and also the direction in which they are drawn (up->down, down->up, left->right, right->left etc). some of the lines are L shaped, and I'd like that info too.
this can probably be done if i knew the endpoints of the path, but i don't know how to extract that info. Also, I need more than that for L shaped lines since the endpoints would indicate a diagonal. I've looked on all the reference pages, and can't find that sort of info.
so, if you know that, or another way to get the information i'm looking for ... thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
访问底层结构的唯一方法是使用
CGPathApply
方法。您传递一个C
函数,该函数传递每个元素(CGPathElement
) 在贝塞尔曲线路径中。您应该能够通过该方法辨别出线条的类型。有一个关于使用 CGPathApply 的
很好的例子
。这并不完全是您所需要的,但看起来是一个很好的起点。The only way you can access the underlying structure is using the
CGPathApply
method on it. You pass aC
function that is passed each of the elements(CGPathElement
) in the bezier path. You should be able to discern what type of line it is in that method.There is a
good example
on usingCGPathApply
. It's not exactly what you need but looks like a good starting point.