Coordinate System Transformations

The NSAffineTransform class can warp the drawing canvas. The main purpose of this is to enable a single NSBezierPath object to define a path that can be used multiple times. In the star example in Chapter 12, four different stars are drawn at four different locations. They are all drawn using the same NSBezierPath object, without changing the object’s path or the location of its points. Moving the canvas, or translation, is one of the ways that NSAffineTransform can alter drawing. It can also perform scaling (changing the size) and rotation. Other effects such as skew are also possible. Slanting is an example of skewing. After skewing, what was once a right angle is no longer a right angle.

Defining an NSAffineTransform ...

Get Cocoa® Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.