By issuing a series of instructions for moving an imaginary pen, you trace out a path. Such a path does not constitute drawing! First you provide a path; then you draw. Drawing can mean stroking the path or filling the path, or both. Again, this should be a familiar notion from certain drawing applications.
A path is constructed by tracing it out from point to point. Think of the drawing system as holding a pen. Then you must first tell that pen where to position itself, setting the current point; after that, you issue a series of commands telling it how to trace out each subsequent piece of the path. Each additional piece of the path starts at the current point; its end becomes the new current point.
Here are some path-drawing commands you’re likely to give:
- Position the current point
- Trace a line
- Trace a rectangle
- Trace an ellipse or circle
- Trace an arc
- Trace a Bezier curve with one or two control points
- Close the current path
CGContextClosePath. This appends a line from the last point of the path to the first point. There’s no need to do this if you’re about to fill the path, since it’s done for you.
- Stroke or fill the current path
CGContextDrawPath. Stroking or filling the current ...