iOS Quartz 2d drawing, drawing sometimes requires a graphical transformation.
Remember: Quartz 2D Transformation is the beginning of the CG, do not mix with the core animation, Core Animatin is the beginning of the CA.
iOS provides a set of API interfaces that can be used for image transformations, and general image transformations are divided into, pan, zoom, and rotate.
Translation
void CgcontextTranslateCTM (cgcontextref C, CGFloat tx, cgfloat ty);
Scaling
void Cgcontextscale CTM (cgcontextref C, CGFloat tx, cgfloat ty);
Rotating
void CgcontextRotateCTM (cgcontextref C, CGFloat tx, cgfloat ty);
This set of APIs has a keyword
1, Cgcontext
2, Translate/scale/rotate
3. CTM (current transformation matrix) transformation
So, the core of this API is matrix transformations.
To be more flexible with matrix transformations, iOS provides the actual matrix transformation functions,
Application transform
void Cgcontextconcatctm (Cgcontextref C, cgaffinetransform transform);
Get the transform of the context
Cgaffinetransform CGCONTEXTGETCTM (cgcontextref c);
The Matrix transformation API provided by iOS
Cgaffinetransform cgaffinetransfommaketranslation(cgfloat tx, cgfloat ty);
Cgaffinetransform cgaffinetransfommake scale (cgfloat TX, cgfloat ty);
Cgaffinetransform cgaffinetransfommakeRotation(cgfloat tx, cgfloat ty);
Cgaffinetransform Cgaffinetransformmake (CGFloat x, cgfloat y, cgfloat C, CGFloat D, CGFloat tx, cgfloat ty);
Cgaffinetransform cgaffinetransfomtranslation(Cgaffinttransform t, cgfloat tx, cgfloat ty);
Cgaffinetransform cgaffinetransfomScale (Cgaffinttransform t,cgfloat tx, cgfloat ty);
Cgaffinetransform cgaffinetransfomRotation(Cgaffinttransform t,cgfloat tx, cgfloat ty);
There is no difference between this set of APIs and the previous CGCONTEXTXXXCTM, and there is a lot of trouble, but there is no advantage in applying cgcontext here.
What is the advantage of this set of APIs???
Quartz 2D Drawing, image transformation