views:

678

answers:

1

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

+4  A: 

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.

EightyEight
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...
Ariel Malka