Class

NSAffineTransform

A graphics coordinate transformation.

Declaration

@interface NSAffineTransform : NSObject

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

+ transform

Creates a new affine transform initialized to the identity matrix.

- init

Initializes an affine transform matrix to the identity matrix.

- initWithTransform:

Initializes the receiver’s matrix using another transform object.

Accumulating Transformations

- rotateByDegrees:

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

- rotateByRadians:

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

- scaleBy:

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

- scaleXBy:yBy:

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

- translateXBy:yBy:

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

- appendTransform:

Appends the specified matrix to the receiver’s matrix.

- prependTransform:

Prepends the specified matrix to the receiver’s matrix.

- invert

Replaces the receiver’s matrix with its inverse matrix.

Transforming Data and Objects

- transformPoint:

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

- transformSize:

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

- transformBezierPath:

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

Accessing the Transformation Matrix

transformStruct

The matrix coefficients stored as the transformation matrix.

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

- set

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

- 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

Geometry

CGFloat

The basic type for all floating-point values.

NSPoint

A point in a Cartesian coordinate system.

NSSize

A two-dimensional size.

NSRect

A rectangle.

NSEdgeInsets

A description of the distance between the edges of two rectangles.