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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -