transformation - CTM transforms vs Affine Transforms in iOS (for translate, rotate, scale) -
i read through transforms documentation in quartz 2d programming guide. in there appears 2 ways make transformations. 1 way through modifying current transformation matrix (ctm). has methods following:
cgcontexttranslatectm
cgcontextrotatectm
cgcontextscalectm
the other way use affine transforms. has methods following:
cgaffinetransformtranslate
cgaffinetransformrotate
cgaffinetransformscale
the docs state
the affine transform functions available in quartz operate on matrices, not on ctm.
but don't understand how affects me practically. seems can same result using either method. when should use ctm transforms , when should use affine transforms?
ctm current transformation matrix , ctm methods make operations on current matrix.
the other version of functions make transformation on given matrix means need specify matrix trying transform. after did may apply transform ctm way want or use other purpose.
for instance these 2 operations same:
cgcontexttranslatectm(context, 10, 10);
affine:
cgaffinetransform transform = cgaffinetransformidentity; transform = cgaffinetransformtranslate(transform, 10, 10); cgcontextconcatctm(context, transform);
as can see first 1 more or less convenience not need write code.
Comments
Post a Comment