Search code examples
iphoneiphone-sdk-3.0affinetransform

Is there a way to obtain a total Affine Transform that represents the current layer state?


I mean, if I have an object and I apply 3 transforms to it, for example, suppose I don't know what each transform is doing, but I have the matrices.

So, I have

Object X > transform1 > transform2 > transform3 > final result

is there a way to obtain an Affine Transform that can represent the 3 transforms, so I can obtain the same result just doing one transform? For example

Object X > super transform > final result

where super transform = transform1 > transform2 > transform3

how do I do that on the iphone sdk using CGAffineTransform ?

thanks for any help.


Solution

  • Have a look at CGAffineTransformConcat(). You can use this to combine two transformations. If you want to combine three transformations into one, something like this should work:

    // Assumes you have CGAffineTransform transform1, transform2, transform3
    
    CGAffineTransform finalTransform = CGAffineTransformConcat(CGAffineTransformConcat(transform1, transform2), transform3);