【问题标题】:How to rotate a cgpath before drawing it?如何在绘制之前旋转 cgpath?
【发布时间】:2010-12-13 02:41:42
【问题描述】:

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

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

对于此处缺少代码,我深表歉意……但我所拥有的只是对 CGContextRotateCTM 的失败调用,它似乎停止了所有绘图。

【问题讨论】:

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


    【解决方案1】:

    围绕中心旋转:

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

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

    CTMnew = -T * R * T * CTMcurrent
    

    【讨论】:

    • 我会的。我已经放弃了这个问题。我稍后会试试这个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    • 2011-01-16
    • 1970-01-01
    • 2014-03-30
    • 1970-01-01
    相关资源
    最近更新 更多