Transformation
The core drawing model defines two fully independent coordinate spaces: User space, one representing the document page, and the device space, and the other representing the resolution of the native device. User-space coordinates are floating-point numbers that are independent of the pixel resolution in device space. When you want to print or display your document, the user space coordinates in Quartz maps are automatically converted to device space coordinates. Therefore, you never have to rewrite your application, or write down additional code to tweak the output of your application on different devices.
You can do this by modifying the default user space or CTM on the current transformation matrix, and after you create a graphics context, CTM is the unit matrix. You can modify the CTM using the quartz conversion function to get a result that modifies the user space drawing.
This chapter:
* Provides an overview that you can use to perform conversion functions
* Explains how to modify CTM
* Describes how to create an affine transform
* Explains how to determine that two conversions are equivalent
* Describes how to get user-to-device space conversion
* Discuss affine transformations in mathematics
About the core Drawing transformation feature
You can easily know that with the quartz 2D built-in conversion function, you can scale and rotate your drawing with just a few lines of code, and you will be able to apply these transformations to any order and any combination. Figure 5-1 illustrates the effect of zooming and rotating an image. Each conversion you apply is used to update CTM. CTM always represents a mapping between user space and device space, and this mapping ensures that the output of the application on any display screen or printer is good.
Figure 5-1 Applying scaling and rotation
The core drawing API provides five features that allow you to get and modify CTM, you can rotate, pan, and zoom CTM. And you can also connect an affine transformation matrix and CTM to see the modification of the current transformation matrix.
Quartz 2D Official document translation (ongoing update)