Chapter 4. The Graphics Context


A Core Graphics drawing context, or CGContext, is the fundamental connection that Quartz 2D forges between your application and a graphics device. The system creates contexts for devices as diverse as an inexpensive black and white inkjet printers to a large, high resolution, color displays. In spite of the differences between the devices, the CGContexts provide a single drawing API that is common to both contexts. In most instances, your application need only concern itself with how to use this abstract drawing API and can leave the details of the underlying drawing destination to the system.

The graphics context is a central player in the Quartz 2D API and we spend quite some time in later chapters discussing specific functionality your application accesses through the CGContext API. The context maintains a complete drawing environment including the coordinate space and a large number of settings that act as parameters to drawing commands.

Your application will send all of its drawing commands to the graphics context. The previous chapter introduced the abstract drawing environment, user space, in which your application builds its graphics. The context is the object that defines user space and manages the mapping between its own drawing environment and the physical drawing mechanics of the output device. Programs change the mapping between user space and the device by calling routines in the CGContext API.

Understanding the role of the graphics parameters that make up the graphics state of a context is essential. Quartz 2D uses these parameters to manipulate basic drawing and to create special effects. Equally important, however, is understanding how to change those values efficiently. Quartz 2D manages its graphics state with a stack. This may seem unusual if you are used to using other graphics libraries.

This chapter provides a broad reaching overview of the functionality in a CGContext. Toward the end, you will see the different ways your application might create or receive a graphics context. The graphics state stack is discussed and a brief glimpse at some of the parameters found in the graphics state is provided. Let us start by exploring the features of the context's drawing environment, user space.




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