有没有一种有效的方法来检测 CGPath 和 CGRect 是否相交?
我考虑过循环遍历 CGRect 内的每个点,如下所示:
for (CGPoint point in rect) {
if (CGPathContainsPoint(path, nil, point, NO)) {
intersects = YES;
break;
}
但我想知道是否有更好的方法。
In my app there are many CGrects and one CGPath that may change its shape. I just need to check which rects are intersecting with the path, as shown in the image bellow.
![enter image description here](https://i.stack.imgur.com/xfaqC.png)
- 在位图中绘制路径(alpha 上白色)
- 然后检查位图的矩形部分。检查该区域是否有白色,这意味着重叠
-- 为了提高性能,仅绘制矩形中的位图部分。
我还没有尝试过这个,它不会提供实时性能,但对我来说听起来不错
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)