本文介绍了如何重置以标识“当前变换矩阵”有一些CGContext函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CTM上做了一系列翻译和旋转,在某些时候,我需要重置它以进行身份​​验证,然后再进行转换。

I'm doing a series of translations and rotations on the CTM and at some point I need to reset it to identity before going further with transformations.

(显然,应该有一个名为CGContextSetCTM的函数),因为效率是关键,我不想使用CGContextSaveGState / CGContextRestoreGState ...

I can't find any proper way to do it (obviously, there should have been a function named CGContextSetCTM or so) and since efficiency is the key, I don't want to use CGContextSaveGState/CGContextRestoreGState...

推荐答案

通过,将其转换为,并将当前矩阵乘以倒数(这很重要!)与。 CTM现在是身份。

Get current transformation matrix via CGContextGetCTM, invert it with CGAffineTransformInvert and multiply the current matrix by the inverted one (that's important!) with CGContextConcatCTM. CTM is now identity.

这篇关于如何重置以标识“当前变换矩阵”有一些CGContext函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:06