Monday, March 28, 2011

How to reset to identity the "current transformation matrix" with some CGContext function?

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.

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...

From stackoverflow
  • 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.

    Ariel Malka : Seems to be a viable workaround but it's terribly inefficient. I don't understand why Apple is not exposing any function to directly reset the matrix...

0 comments:

Post a Comment