Structure
An affine transformation matrix for use in drawing 2D graphics.
--用于绘制2D图形的仿射变换矩阵。
An affine transformation matrix is used to rotate, scale, translate, or skew the objects you draw in a graphics context. The CGAffineTransform type provides functions for creating, concatenating, and applying affine transformations.
--仿射变换矩阵用于旋转、缩放、平移或倾斜您在图形上下文中绘制的对象。CGAffineTransform类型提供了用于创建、连接和应用仿射转换的函数。
Affine transforms are represented by a 3 by 3 matrix:
--仿射变换由一个3乘3的矩阵表示:
Because the third column is always (0,0,1), the CGAffineTransform data structure contains values for only the first two columns.
--因为第三列总是(0,0,1),所以CGAffineTransform数据结构只包含前两列的值。(数学知识,不懂就听就是了)
Conceptually, an affine transform multiplies a row vector representing each point (x,y) in your drawing by this matrix, producing a vector that represents the corresponding point (x’,y’):
--从概念上讲,一个仿射变换用这个矩阵乘以表示图中每个点(x,y)的行向量,得到一个表示对应点(x,y)的向量。
Given the 3 by 3 matrix, the following equations are used to transform a point (x, y) in one coordinate system into a resultant point (x’,y’) in another coordinate system.
--已知3×3矩阵,用以下方程将一个坐标系中的点(x, y)转换为另一个坐标系中的合成点(x, y)。
The matrix thereby “links” two coordinate systems—it specifies how points in one coordinate system map to points in another.
--因此,矩阵“链接”两个坐标系它指定了一个坐标系中的点如何映射到另一个坐标系中的点。
Note that you do not typically need to create affine transforms directly. If you want only to draw an object that is scaled or rotated, for example, it is not necessary to construct an affine transform to do so. The most direct way to manipulate your drawing—whether by movement, scaling, or rotation—is to call the functions translateBy(x:y:), scaleBy(x:y:), or rotate(by:), respectively. You should generally only create an affine transform if you want to reuse it later.
--注意,你不需要直接创建仿射变换矩阵那么复杂的东西,系统已经为你封装好一些变换的方法,直接调用就可以了。例如,如果您是想通过移动、缩放还是旋转来操作您的绘图,最直接的方法是分别调用函数 translateBy(x:y:), scaleBy(x:y:), 和rotate(by:)。只有以后想复用变换时,你才需要自己创建一个仿射变换。
init(rotationAngle: CGFloat)
Returns an affine transformation matrix constructed from a rotation value you provide.
--构造给定旋转角度的仿射变换矩阵
init(scaleX: CGFloat, y: CGFloat)
Returns an affine transformation matrix constructed from scaling values you provide.
--构造给定缩放倍数的仿射变换矩阵
init(translationX: CGFloat, y: CGFloat)
Returns an affine transformation matrix constructed from translation values you provide.
--构造给定平移距离的仿射变换矩阵
init()
init(a: CGFloat, b: CGFloat, c: CGFloat, d: CGFloat, tx: CGFloat, ty: CGFloat)
--自定义矩阵构造仿射变换
init(from: Decoder)
var isIdentity: Bool
Checks whether an affine transform is the identity transform.
--检查仿射变换是否是恒等变换。
var a: CGFloat
The entry at position [1,1] in the matrix.
var b: CGFloat
The entry at position [1,2] in the matrix.
var c: CGFloat
The entry at position [2,1] in the matrix.
var d: CGFloat
The entry at position [2,2] in the matrix.
var tx: CGFloat
The entry at position [3,1] in the matrix.
var ty: CGFloat
The entry at position [3,2] in the matrix.
static var identity: CGAffineTransform
The identity transform.
--恒等变换
func concatenating(CGAffineTransform) -> CGAffineTransform
Returns an affine transformation matrix constructed by combining two existing affine transforms.
--通过两个已存在的仿射变换构造仿射变换矩阵
func inverted() -> CGAffineTransform
Returns an affine transformation matrix constructed by inverting an existing affine transform.
--返回当前矩阵的转置矩阵
func rotated(by: CGFloat) -> CGAffineTransform
Returns an affine transformation matrix constructed by rotating an existing affine transform.
--返回旋转后仿射变换矩阵。
func scaledBy(x: CGFloat, y: CGFloat) -> CGAffineTransform
Returns an affine transformation matrix constructed by scaling an existing affine transform.
--返回通过缩放后的仿射变换矩阵。
func translatedBy(x: CGFloat, y: CGFloat) -> CGAffineTransform
Returns an affine transformation matrix constructed by translating an existing affine transform.
--返回通过平移后的仿射变换矩阵。
func encode(to: Encoder)
static func == (CGAffineTransform, CGAffineTransform) -> Bool
struct CGFloat
The basic type for floating-point scalar values in Core Graphics and related frameworks.
struct CGPoint
A structure that contains a point in a two-dimensional coordinate system.
struct CGSize
A structure that contains width and height values.
struct CGRect
A structure that contains the location and dimensions of a rectangle.
struct CGVector
A structure that contains a two-dimensional vector.