Class

NSAffineTransform

An object representing a graphics coordinate transformation that bridges to AffineTransform; use NSAffineTransform when you need reference semantics or other Foundation-specific behavior.

Overview

A transformation specifies how points in one coordinate system are transformed to points in another coordinate system. An affine transformation is a special type of transformation that preserves parallel lines in a path but does not necessarily preserve lengths or angles. Scaling, rotation, and translation are the most commonly used manipulations supported by affine transforms, but shearing is also possible.

Methods for applying affine transformations to the current graphics context and a method for applying an affine transformation to an NSBezierPath object are described in NSAffineTransform Additions Reference in the Application Kit.

Topics

Creating an Affine Transform

init()

Initializes an affine transform matrix to the identity matrix.

init(transform: AffineTransform)

Initializes the receiver’s matrix using another transform object.

Accumulating Transformations

func rotate(byDegrees: CGFloat)

Applies a rotation factor (measured in degrees) to the receiver’s transformation matrix.

func rotate(byRadians: CGFloat)

Applies a rotation factor (measured in radians) to the receiver’s transformation matrix.

func scale(by: CGFloat)

Applies the specified scaling factor along both x and y axes to the receiver’s transformation matrix.

func scaleX(by: CGFloat, yBy: CGFloat)

Applies scaling factors to each axis of the receiver’s transformation matrix.

func translateX(by: CGFloat, yBy: CGFloat)

Applies the specified translation factors to the receiver’s transformation matrix.

func append(AffineTransform)

Appends the specified matrix to the receiver’s matrix.

func prepend(AffineTransform)

Prepends the specified matrix to the receiver’s matrix.

func invert()

Replaces the receiver’s matrix with its inverse matrix.

Transforming Data and Objects

func transform(NSPoint)

Applies the receiver’s transform to the specified point and returns the result.

func transform(NSSize)

Applies the receiver’s transform to the specified size and returns the results.

func transform(NSBezierPath)

Creates and returns a new NSBezierPath object with each point in the given path transformed by the receiver.

Accessing the Transformation Matrix

var transformStruct: NSAffineTransformStruct

The matrix coefficients stored as the transformation matrix.

struct NSAffineTransformStruct

A structure that defines the three-by-three matrix that performs an affine transform between two coordinate systems.

Setting and Building the Current Transformation Matrix

func set()

Sets the current transformation matrix to the receiver’s transformation matrix.

func concat()

Appends the receiver’s matrix to the current transformation matrix stored in the current graphics context, replacing the current transformation matrix with the result.

Relationships

Inherits From

See Also

Using Reference Types

typealias AffineTransform.ReferenceType

An alias for this value type's equivalent reference type.