如何在绘制之前旋转 cgpath?

发布于 2024-10-07 10:31:37 字数 141 浏览 1 评论 0原文

我可以画一条路径......而且我有点确定我需要使用仿射变换。

我不明白的是如何旋转路径并保持相同的中心。

我对这里缺少代码表示歉意......但我所拥有的只是对 CGContextRotateCTM 的失败调用,这似乎停止了所有绘图。

I can draw a path...and i am somewhat sure that i need to use affine transform.

what i don't get is how to rotate the path and keep the same center.

I apologize for the lack of code here...but all I have is a failed call to CGContextRotateCTM that seemed to halt all drawing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月野兔 2024-10-14 10:31:37

围绕中心旋转:

CGContextTranslateCTM (ctx, center.x, center.y);
CGContextRotateCTM (ctx, angleInRadians);
CGContextTranslateCTM (ctx, -center.x, -center.y);
CGContextAddPath (ctx, path);

我可能有向后的平移符号(即旋转之前而不是之后的负平移),尽管我相信 CTM 方法是预连接的,所以这些调用的数学表示是

CTMnew = -T * R * T * CTMcurrent

To rotate around the center:

CGContextTranslateCTM (ctx, center.x, center.y);
CGContextRotateCTM (ctx, angleInRadians);
CGContextTranslateCTM (ctx, -center.x, -center.y);
CGContextAddPath (ctx, path);

I might have the translate signs backward (i.e. negative translation before rotate instead of after), although I believe the CTM methods pre-concat, so the mathematical representation of those calls is

CTMnew = -T * R * T * CTMcurrent
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文