CGMutablePath
A mutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context.
Declaration
class CGMutablePathOverview
Neither CGPath nor CGMutablePath define functions to draw a path. To draw a Core Graphics path to a graphics context, you add the path to the graphics context by calling addPath(_:) and then call one of the context’s drawing functions—see CGContext.
Each figure in the graphics path is constructed with a connected set of lines and Bézier curves, called a subpath. A subpath has an ordered set of path elements that represent single steps in the construction of the subpath. (For example, a line segment from one corner of a rectangle to another corner is a path element. Every subpath includes a starting point, which is the first point in the subpath. The path also maintains a current point, which is the last point in the last subpath.
To append a new subpath onto a mutable path, your application typically calls CGPathMoveToPoint to set the subpath’s starting point and initial current point, followed by a series of “add” calls (such as CGPathAddLineToPoint) to add line segments and curves to the subpath. As segments or curves are added to the subpath, the subpath’s current point is updated to point to the end of the last segment or curve to be added. The lines and curves of a subpath are always connected, but they are not required to form a closed set of lines. Your application explicitly closes a subpath by calling closeSubpath(). Closing the subpath adds a line segment that terminates at the subpath’s starting point, and also changes how those lines are rendered—for more information see Paths in Quartz 2D Programming Guide.
Topics
Creating Graphics Paths
Copying a Graphics Path
Constructing a Graphics Path
move(to:transform:)addLine(to:transform:)addLines(between:transform:)addRect(_:transform:)addRects(_:transform:)addEllipse(in:transform:)addRoundedRect(in:cornerWidth:cornerHeight:transform:)addArc(center:radius:startAngle:endAngle:clockwise:transform:)addArc(tangent1End:tangent2End:radius:transform:)addRelativeArc(center:radius:startAngle:delta:transform:)addCurve(to:control1:control2:transform:)addQuadCurve(to:control:transform:)addPath(_:transform:)closeSubpath()
See Also
Related Documentation
- Quartz 2D Programming Guide