15.6. Constructing Paths
You want to be able to draw any shape that you wish on a graphics context.
Construct and draw paths.
A series of points placed together can form a shape. A
series of shapes put together builds a path. Paths can easily be
managed by Core Graphics. In Recipe 15.5, we
worked indirectly with paths using
CGContext functions. But Core Graphics also
has functions that work directly with paths, as we shall soon
Paths belong to whichever graphics context they are drawn on. Paths do not have boundaries or specific shapes, unlike the shapes we draw on them. But paths do have bounding boxes. Please bear in mind that boundaries are not the same as bounding boxes. Boundaries are limits above which you cannot draw on a canvas, while the bounding box of a path is the smallest rectangle that contains all the shapes, points, and other objects that have been drawn on that specific path. Think of paths as stamps and think of your graphics context as the envelope. Your envelope could be the same every time you mail something to your friend, but what you put on that context (the stamp or the path) can be different.
After you finish drawing on a path, you can then draw that path on the graphics context. Developers familiar with game programming know the concept of buffers, which draw their scenes and, at appropriate times, flush the images onto the screen. Paths are those buffers. They are like blank canvases that can be drawn on graphics contexts when ...