Chapter 6. Line ArtBuilding Paths


Many of the graphical elements commonly found in graphics libraries, like lines, rectangles, simple polygons, and ellipses all fall into the line art category. With the line art system of Quartz 2D you can create these basic shapes and enjoy all the resolution independence of the library as well as modern graphics features like antialiasing and hardware acceleration. At the heart of the Quartz 2D line art system is a concept called the path. The overview of the Quartz imaging model in Chapter 3, "Introduction to Quartz 2D," contained the briefest glimpse of what paths are. This chapter takes a much closer look.

Figure 6.1 illustrates a number of path-based shapes and will serve as an excellent platform for an overview of paths and how Quartz 2D uses them. Each of the seven motifs in the figure is built from a different path, and the figure as a whole demonstrates many characteristics of paths. For example, you can see that paths are constructed from straight and curved segments and then colored using two different primitive drawing operations.

Figure 6.1. A Collection of Shapes Made from Paths


In Figure 6.1, the line in the upper left corner and the star on the lower left are both drawn by stroking a path. The other shapes in the figure are drawn by filling paths. The blob in the lower center and the outline of the State of Texas have been stroked and filled. The Texas path uses a relatively thin stroke while the blob uses a thicker line on its stroke.

The circular shape in the top center, the blob, and the letter A are all paths with holes in them. In fact, a path can contain more than just holes; a path can describe disjoint areas. The three small circles in the lower right corner of the figure are actually a single path formed of three disjoint, circular areas.

Stroking and filling are the two primary drawing operations for line art. The fact that there are only two drawing operations might lead you to conclude that the line art in Quartz 2D is not very sophisticated. This couldn't be further from the truth. Although there are only two drawing operations, Quartz 2D offers a large number of parameters that govern the way they draw. Those options and the flexibility of the path give the library a remarkable depth when creating graphics.

This chapter provides the first opportunity to explore the line art features of Quartz 2D and begins with a discussion of paths. To understand how Quartz 2D creates curves, you must learn about bezier curves, the mathematical structure that it uses to represent curved segments. From there you'll be ready to explore the tools and techniques that a Quartz 2D application can use to create paths.

In the next chapter, the discussion of creating line art continues by exploring the two fundamental drawing operations, filling and stroking. That chapter will demonstrate how to take the paths created using the techniques of this chapter and translate them into drawings.




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