Class

NSAffineTransform

The NSAffineTransform class provides methods for creating, concatenating, and applying affine transformations.

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.

Symbols

Creating an NSAffineTransform Object

init(transform: AffineTransform)

Initializes the receiver’s matrix using another transform object and returns the receiver.

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 NSPoint data type and returns the results.

func transform(NSSize)

Applies the receiver’s transform to the specified NSSize data type and returns the results.

Accessing the Transformation Structure

var transformStruct: NSAffineTransformStruct

Returns the matrix coefficients stored in the receiver’s matrix.

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.

Transforming Bezier Paths

func transform(NSBezierPath)

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

Constants

NSAffineTransformStruct

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

Initializers

Relationships

Inherits From