NSBezierPath
An object that can create paths using PostScript-style commands.
Declaration
class NSBezierPathOverview
Paths consist of straight and curved line segments joined together. Paths can form recognizable shapes such as rectangles, ovals, arcs, and glyphs; they can also form complex polygons using either straight or curved line segments. A single path can be closed by connecting its two endpoints, or it can be left open.
An NSBezierPath object can contain multiple disconnected paths, whether they are closed or open. Each of these paths is referred to as a subpath. The subpaths of a Bézier path object must be manipulated as a group. The only way to manipulate subpaths individually is to create separate NSBezierPath objects for each.
For a given NSBezierPath object, you can stroke the path’s outline or fill the region occupied by the path. You can also use the path as a clipping region for views or other regions. Using methods of NSBezierPath, you can also perform hit detection on the filled or stroked path. Hit detection is needed to implement interactive graphics, as in rubber banding and dragging operations.
The current graphics context is automatically saved and restored for all drawing operations involving Bézier path objects, so your application does not need to worry about the graphics settings changing across invocations.
Topics
Creating a Bézier Path
Constructing a Path
move(to:)line(to:)curve(to:controlPoint1:controlPoint2:)curve(to:controlPoint:)close()relativeMove(to:)relativeLine(to:)relativeCurve(to:controlPoint1:controlPoint2:)relativeCurve(to:controlPoint:)
Appending Common Shapes to a Path
append(_:)appendPoints(_:count:)appendOval(in:)appendArc(from:to:radius:)appendArc(withCenter:radius:startAngle:endAngle:)appendArc(withCenter:radius:startAngle:endAngle:clockwise:)appendRect(_:)appendRoundedRect(_:xRadius:yRadius:)append(withCGGlyph:in:)append(withCGGlyphs:count:in:)appendGlyph(_:in:)appendGlyphs(_:count:in:)appendPackedGlyphs(_:)
Accessing a Path’s Attributes
windingRulelineCapStylelineJoinStylelineWidthmiterLimitflatnessgetLineDash(_:count:phase:)setLineDash(_:count:phase:)
Configuring Default Path Attributes
defaultWindingRuledefaultLineCapStyledefaultLineJoinStyledefaultLineWidthdefaultMiterLimitdefaultFlatness
Drawing a Path
Specifying a Clipping Path
Performing Hit-Testing
Querying a Path
Applying Transformations
Accessing Elements of a Path
cgPathelementCountelement(at:)element(at:associatedPoints:)removeAllPoints()setAssociatedPoints(_:at:)