Chapter 5. Transformations


The separation of user space from device space is the source of much of the power of the Quartz 2D graphics library. As we've already seen, your application constructs its graphics in the resolution independent graphics environment of user space, but before the computer can reproduce the graphics on a device, it must first move the graphics to device space. Transformations are the tools that the computer uses to move graphics from one coordinate system to another.

Quartz 2D includes a set of tools for creating and combining transformations. Your application can take advantage of these tools and use them to simplify many of your drawings. The general strategy is to select a convenient coordinate system in which to draw your graphics. You can then use the tools in the Quartz 2D API to create a transformation that establishes that coordinate system. It takes some time to get the hang of using transformations in this way, but once you do, you'll wonder how you ever drew graphics without them.

Many computer graphics libraries represent transformations using a matrices. Quartz 2D is no exception, and like those other libraries it uses linear algebra to apply transformations with geometric objects like points, rectangles, and paths. You don't have to understand the mathematics behind transformations to use them effectively, but if you are familiar with the math, there are some Quartz 2D APIs that allow you to use the explicit matrix representation of transformations. At the end of this chapter we take the briefest of looks at the math behind transformations. If you want more information on the matrix representation of transformations and how you can use Linear Algebra to combine them, you can consult any modern computer graphics textbook.

The rest of this chapter looks at fundamental building blocks of Quartz 2D transformations and also examines the tools your application uses to combine the basics and create more complex transformations. The drawing sample demonstrates an instance of using transformations to simplify a complex drawing. The chapter ends with looking at some of the mathematics behind Quartz 2D transformations.




Quartz 2D Graphics for Mac OS X Developers
Quartz 2D Graphics for Mac OS X Developers
ISBN: 0321336631
EAN: 2147483647
Year: 2006
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net