Programming with Quartz: 2D and PDF Graphics in Mac OS X

Chapter 2: Quartz 2D Drawing Basics

No matter how complex a drawing appears, it's the result of performing a number of basic operations. Paths define shapes. Shapes can be filled, stroked, or both. The painting color can be opaque or have a degree of transparency. Lines can be solid or dashed. Clipping determines which portions of drawing are visible. Drawing can be scaled and otherwise transformed. PDF documents can be treated as a single graphic element but can themselves be arbitrarily complex.

The basic operations available in Quartz produce results that would be difficult to obtain using most other imaging systems. This chapter contains relatively simple examples that illustrate basic drawing operations. Subsequent chapters build on the concepts in these simple examples to show how to achieve more and more complex results.

Quartz Graphics Contexts

Quartz always draws into a graphics context. As described in "Quartz 2D Overview" (page 8), a graphics context is an abstract representation of a drawing destination. A window, a bitmap, and a PDF file are examples of "destinations" that are represented by a graphics context. A Quartz graphics context is an opaque data structure called a CGContextRef. The Quartz routines that affect the context all take a CGContextRef as a parameter. Quartz has no notion of a "current context"; you always pass a context directly to Quartz functions.

Depending on the task, an application either creates a graphics context or obtains one from a framework (such as when the application draws into a window). "More About Graphics Contexts" (page...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Graphics Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.