如何在绘制之前旋转cgpath?

时间:2010-12-13 02:41:43

标签: core-animation core-graphics rotation quartz-graphics cgpath

我可以绘制一条路径......我确信我需要使用仿射变换。

我没有得到的是如何旋转路径并保持相同的中心。

我为此处缺少代码道歉...但我所拥有的是对CGContextRotateCTM的失败调用,似乎停止了所有绘图。

1 个答案:

答案 0 :(得分:3)

围绕中心旋转:

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

我可能会向后转换符号(即在旋转之前而不是之后的负转换),虽然我相信CTM方法预先连接,所以这些调用的数学表示是

CTMnew = -T * R * T * CTMcurrent
相关问题