gpt4 book ai didi

ios - 确定 CGMutablePathRef 的边界?

转载 作者:行者123 更新时间:2023-11-28 19:09:13 24 4
gpt4 key购买 nike

我有 CGMutablePathRef 创建的路径

  CGMutablePathRef pointsPathpath = CGPathCreateMutable();
CGPathMoveToPoint(pointsPathpath, NULL, firstPoint.x, firstPoint.y);
CGPathAddLineToPoint(pointsPathpath, NULL, secondPoint.x, secondPoint.y);
CGPathAddLineToPoint(pointsPathpath, NULL, thirdPoint.x, thirdPoint.y);
CGPathAddLineToPoint(pointsPathpath, NULL, fourthPoint.x, fourthPoint.y);
CGPathCloseSubpath(pointsPathpath);

有没有办法得到它的边界点?

提前致谢。

最佳答案

Core Graphics 有两种方法来计算 CGPath 的“边界框”。

  1. CGPathGetPathBoundingBox()
  2. CGPathGetBoundingBox()

第一个返回包含路径中所有点但包括曲线控制点的最小边界框。

第二个确实包括曲线的控制点。

您的路径没有任何曲线,因此它们将返回相同的矩形,但对于更高级的路径,它们通常会返回不同的区域。

下图说明了它们的区别。末端带圆圈的黑线是路径中曲线的控制点。

enter image description here

关于ios - 确定 CGMutablePathRef 的边界?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17348941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com