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

Quartz shadings, sometimes also called gradients or blends, provide a way to paint with color that varies smoothly across the painted area. You've already seen two approaches to drawing shadings. The rotated ellipses shown in Figure 5.5 (page 96) are produced by manually painting a sequence of shapes, smoothly varying the color of the shapes as they are drawn. The green-to-red ramp shown in Figure 9.5 (page 223) is a synthetic image generated by code.
Each of the approaches has disadvantages. The sequence-of-shapes approach relies on the code to decide how many shapes to draw and how far apart to space each shape. The synthetic image approach uses a blend that is pre-rendered as an image. In each approach, the decisions about the resolution and color steps needed for good fidelity are already "baked" into the drawing. Scaling the output produced by these techniques may produce substandard results when drawn at another size or resolution.
A better approach is to use Quartz shadings. Quartz shadings allow you to describe the shading at a high level and postpone the details of how the shading is actually rendered until the rendering actually occurs. Shadings are also captured into PDF documents at a high level, allowing the rendering engine to decide how to render the shading based on the device resolution, bit depth, and CTM at the time the drawing of the PDF document actually occurs.
Quartz provides two different kinds of shadings, axial