Chapter 14. Drawing with Quartz

Although we’ve mentioned Quartz several times, we’ve never used it to do much in the way of customized drawing. The reason for this is largely a result of the power of the Cocoa Application Kit — most of the objects that we’ve used up to this point already know how to generate Quartz to display themselves on the screen, so we haven’t had to generate it ourselves.

Quartz is itself a complete graphics drawing system. It is a subject far too vast to cover fully in this chapter, so instead of even trying to give you a complete description of Quartz, this chapter is designed simply to give you a sense of how Quartz drawing is done in the Cocoa environment. At the end of the chapter, we’ll provide some references for further information.

Animation in an About Panel

The ultimate goal of this chapter is to create an animation in an About panel (box) for our MathPaper application. The MathPaper About panel will have four kinds of drawing in it, each of which will require different Quartz primitives. We will draw an icon, a Bezier curve, some straight lines, and some text, as shown in Figure 14-1. We will also demonstrate animation: the Bezier curve will spin and the icon will pulsate. This chapter is dedicated to learning enough about Quartz and Cocoa to develop this About panel. It’ll be fun!

MathPaper’s About panel: the icon pulsates and the star spins

Figure 14-1. MathPaper’s About panel: the icon pulsates and the star ...

Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.