CTM transforms vs Affine Transforms in iOS (for translate, rotate, scale)

參考URL:http://stackoverflow.com/questions/30756907/ctm-transforms-vs-affine-transforms-in-ios-for-translate-rotate-scale


https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html


https://developer.apple.com/library/ios/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_affine/dq_affine.html#//apple_ref/doc/uid/TP30001066-CH204-SW1



CTM is a current transformation matrix and the CTM methods will make operations on the current matrix.

The other version of functions will make the transformation on a given matrix which means you need to specify which matrix you are trying to transform. After you did so you may apply the transform to the CTM any way you want or use it for any other purpose.

For instance these 2 operations would be the same:

CGContextTranslateCTM(context, 10, 10);

Affine:

CGAffineTransform transform = CGAffineTransformIdentity;transform = CGAffineTransformTranslate(transform, 10, 10);CGContextConcatCTM(context, transform);

As you can see the first one is more or less just a convenience so you do not need to write so much code.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章