1 CGAffineTransform
定义如下:
struct CGAffineTransform {
CGFloat a, b, c, d;
CGFloat tx, ty;
};
这只定义了部分数据,这个其实是一个3*3的矩阵,最后一列永远是[0,0,1]。
/* Return a transform which translates by `(tx, ty)':
t' = [ 1 0 0 1 tx ty ] */
CGAffineTransform CGAffineTransformMakeTranslation(CGFloat tx,
CGFloat ty);
x‘ = x + tx,y’= y = ty,这样实现了偏移。
/* Return a transform which scales by `(sx, sy)':
t' = [ sx 0 0 sy 0 0 ] */
CG_EXTERN CGAffineTransform CGAffineTransformMakeScale(CGFloat sx, CGFloat sy);
x’=xsx+ysy。这样就实现了缩放。
/* Return a transform which rotates by `angle' radians:
t' = [ cos(angle) sin(angle) -sin(angle) cos(angle) 0 0 ] */
CG_EXTERN CGAffineTransform CGAffineTransformMakeRotation(CGFloat angle));