<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSBezierPath",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBezierPath"
  },
  "title" : "NSBezierPath"
}
-->

# NSBezierPath

An object that can create paths using PostScript-style commands.

```
class NSBezierPath
```

## Overview

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`](/documentation/AppKit/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`](/documentation/AppKit/NSBezierPath) objects for each.

For a given [`NSBezierPath`](/documentation/AppKit/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`](/documentation/AppKit/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

[`+ (NSBezierPath *) bezierPath;`](/documentation/AppKit/NSBezierPath/bezierPath)

Creates and returns a new Bézier path object.

[`init(ovalIn: NSRect)`](/documentation/AppKit/NSBezierPath/init(ovalIn:))

Creates and returns a new Bézier path object initialized with an oval path inscribed in the specified rectangle.

[`init(rect: NSRect)`](/documentation/AppKit/NSBezierPath/init(rect:))

Creates and returns a new Bézier path object initialized with a rectangular path.

[`init(roundedRect: NSRect, xRadius: CGFloat, yRadius: CGFloat)`](/documentation/AppKit/NSBezierPath/init(roundedRect:xRadius:yRadius:))

Creates and returns a new Bézier path object initialized with a rounded rectangular path.

[`init(cgPath: CGPath)`](/documentation/AppKit/NSBezierPath/init(cgPath:)-96cxk)

[`var flattened: NSBezierPath`](/documentation/AppKit/NSBezierPath/flattened)

A flattened version of the path object.

[`var reversed: NSBezierPath`](/documentation/AppKit/NSBezierPath/reversed)

A path containing the reversed contents of the current path object.

### Constructing a Path

[`func move(to: NSPoint)`](/documentation/AppKit/NSBezierPath/move(to:))

Moves the path’s current point to the specified location.

[`func line(to: NSPoint)`](/documentation/AppKit/NSBezierPath/line(to:))

Appends a straight line to the path.

[`func curve(to: NSPoint, controlPoint1: NSPoint, controlPoint2: NSPoint)`](/documentation/AppKit/NSBezierPath/curve(to:controlPoint1:controlPoint2:))

Adds a Bezier cubic curve to the path.

[`func curve(to: NSPoint, controlPoint: NSPoint)`](/documentation/AppKit/NSBezierPath/curve(to:controlPoint:))

[`func close()`](/documentation/AppKit/NSBezierPath/close())

Closes the most recently added subpath.

[`func relativeMove(to: NSPoint)`](/documentation/AppKit/NSBezierPath/relativeMove(to:))

Moves the path’s current point to a new point whose location is the specified distance from the current point.

[`func relativeLine(to: NSPoint)`](/documentation/AppKit/NSBezierPath/relativeLine(to:))

Appends a straight line segment to the path starting at the current point and moving towards the specified point, relative to the current location.

[`func relativeCurve(to: NSPoint, controlPoint1: NSPoint, controlPoint2: NSPoint)`](/documentation/AppKit/NSBezierPath/relativeCurve(to:controlPoint1:controlPoint2:))

Adds a Bezier cubic curve to the path from the current point to a new location, which is specified as a relative distance from the current point.

[`func relativeCurve(to: NSPoint, controlPoint: NSPoint)`](/documentation/AppKit/NSBezierPath/relativeCurve(to:controlPoint:))

### Appending Common Shapes to a Path

[`func append(NSBezierPath)`](/documentation/AppKit/NSBezierPath/append(_:))

Appends the contents of the specified path object to the path.

[`func appendPoints(NSPointArray, count: Int)`](/documentation/AppKit/NSBezierPath/appendPoints(_:count:))

Appends a series of line segments to the path.

[`func appendOval(in: NSRect)`](/documentation/AppKit/NSBezierPath/appendOval(in:))

Appends an oval path to the path, inscribing the oval in the specified rectangle.

[`func appendArc(from: NSPoint, to: NSPoint, radius: CGFloat)`](/documentation/AppKit/NSBezierPath/appendArc(from:to:radius:))

Appends an arc to the path.

[`func appendArc(withCenter: NSPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat)`](/documentation/AppKit/NSBezierPath/appendArc(withCenter:radius:startAngle:endAngle:))

Appends an arc of a circle to the path.

[`func appendArc(withCenter: NSPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)`](/documentation/AppKit/NSBezierPath/appendArc(withCenter:radius:startAngle:endAngle:clockwise:))

Appends an arc of a circle to the path.

[`func appendRect(NSRect)`](/documentation/AppKit/NSBezierPath/appendRect(_:))

Appends a rectangular path to the path.

[`func appendRoundedRect(NSRect, xRadius: CGFloat, yRadius: CGFloat)`](/documentation/AppKit/NSBezierPath/appendRoundedRect(_:xRadius:yRadius:))

Appends a rounded rectangular path to the path.

[`func append(withCGGlyph: CGGlyph, in: NSFont)`](/documentation/AppKit/NSBezierPath/append(withCGGlyph:in:))

Appends an outline of the specified glyph to the path.

[`func append(withCGGlyphs: UnsafePointer<CGGlyph>, count: Int, in: NSFont)`](/documentation/AppKit/NSBezierPath/append(withCGGlyphs:count:in:))

Appends the outlines of the specified glyphs to the path.

[`func appendGlyph(NSGlyph, in: NSFont)`](/documentation/AppKit/NSBezierPath/appendGlyph(_:in:))

Appends an outline of the specified glyph to the path.

[`func appendGlyphs(UnsafeMutablePointer<NSGlyph>, count: Int, in: NSFont)`](/documentation/AppKit/NSBezierPath/appendGlyphs(_:count:in:))

Appends the outlines of the specified glyphs to the path.

[`func appendPackedGlyphs(UnsafePointer<CChar>)`](/documentation/AppKit/NSBezierPath/appendPackedGlyphs(_:))

Appends an array of packed glyphs to the path.

### Accessing a Path’s Attributes

[`var windingRule: NSBezierPath.WindingRule`](/documentation/AppKit/NSBezierPath/windingRule-swift.property)

The winding rule used to fill the path.

[`var lineCapStyle: NSBezierPath.LineCapStyle`](/documentation/AppKit/NSBezierPath/lineCapStyle-swift.property)

The line cap style for the path.

[`var lineJoinStyle: NSBezierPath.LineJoinStyle`](/documentation/AppKit/NSBezierPath/lineJoinStyle-swift.property)

The line join style for the path.

[`var lineWidth: CGFloat`](/documentation/AppKit/NSBezierPath/lineWidth)

The width of stroked path lines.

[`var miterLimit: CGFloat`](/documentation/AppKit/NSBezierPath/miterLimit)

The limit at which miter joins are converted to bevel joins.

[`var flatness: CGFloat`](/documentation/AppKit/NSBezierPath/flatness)

The accuracy with which curves are rendered.

[`func getLineDash(UnsafeMutablePointer<CGFloat>?, count: UnsafeMutablePointer<Int>?, phase: UnsafeMutablePointer<CGFloat>?)`](/documentation/AppKit/NSBezierPath/getLineDash(_:count:phase:))

Returns the line-stroking pattern for the receiver.

[`func setLineDash(UnsafePointer<CGFloat>?, count: Int, phase: CGFloat)`](/documentation/AppKit/NSBezierPath/setLineDash(_:count:phase:))

Sets the line-stroking pattern for the path.

### Configuring Default Path Attributes

[`class var defaultWindingRule: NSBezierPath.WindingRule`](/documentation/AppKit/NSBezierPath/defaultWindingRule)

Returns the default winding rule used to fill all paths.

[`class var defaultLineCapStyle: NSBezierPath.LineCapStyle`](/documentation/AppKit/NSBezierPath/defaultLineCapStyle)

Returns the default line cap style for all paths.

[`class var defaultLineJoinStyle: NSBezierPath.LineJoinStyle`](/documentation/AppKit/NSBezierPath/defaultLineJoinStyle)

Returns the default line join style for all paths.

[`class var defaultLineWidth: CGFloat`](/documentation/AppKit/NSBezierPath/defaultLineWidth)

Returns the default line width for the all paths.

[`class var defaultMiterLimit: CGFloat`](/documentation/AppKit/NSBezierPath/defaultMiterLimit)

Returns the default miter limit for all paths.

[`class var defaultFlatness: CGFloat`](/documentation/AppKit/NSBezierPath/defaultFlatness)

The default flatness value for all paths.

### Drawing a Path

[`func stroke()`](/documentation/AppKit/NSBezierPath/stroke())

Draws a line along the path using the current stroke color and drawing attributes.

[`func fill()`](/documentation/AppKit/NSBezierPath/fill())

Paints the region enclosed by the path.

[`class func fill(NSRect)`](/documentation/AppKit/NSBezierPath/fill(_:))

Fills the specified rectangular path with the current fill color.

[`class func stroke(NSRect)`](/documentation/AppKit/NSBezierPath/stroke(_:))

Strokes the path of the specified rectangle using the current stroke color and the default drawing attributes.

[`class func strokeLine(from: NSPoint, to: NSPoint)`](/documentation/AppKit/NSBezierPath/strokeLine(from:to:))

Strokes a line between two points using the current stroke color and the default drawing attributes.

[`class func drawPackedGlyphs(UnsafePointer<CChar>, at: NSPoint)`](/documentation/AppKit/NSBezierPath/drawPackedGlyphs(_:at:))

Draws a set of packed glyphs at the specified point in the current coordinate system.

### Specifying a Clipping Path

[`func addClip()`](/documentation/AppKit/NSBezierPath/addClip())

Intersects the area enclosed by the path with the clipping path of the current graphics context and makes the resulting shape the current clipping path.

[`func setClip()`](/documentation/AppKit/NSBezierPath/setClip())

Replaces the clipping path of the current graphics context with the area inside the path.

[`class func clip(NSRect)`](/documentation/AppKit/NSBezierPath/clip(_:))

Intersects the specified rectangle with the clipping path of the current graphics context and makes the resulting shape the current clipping path.

### Performing Hit-Testing

[`func contains(NSPoint) -> Bool`](/documentation/AppKit/NSBezierPath/contains(_:))

Returns a Boolean value that indicates whether the path contains the specified point.

### Querying a Path

[`var bounds: NSRect`](/documentation/AppKit/NSBezierPath/bounds)

The bounding box of the path.

[`var controlPointBounds: NSRect`](/documentation/AppKit/NSBezierPath/controlPointBounds)

The bounding box of the path, including any control points.

[`var currentPoint: NSPoint`](/documentation/AppKit/NSBezierPath/currentPoint)

The current point (the trailing point or ending point in the most recently added segment).

[`var isEmpty: Bool`](/documentation/AppKit/NSBezierPath/isEmpty)

A Boolean value that indicates whether the path is empty.

### Applying Transformations

[`func transform(using: AffineTransform)`](/documentation/AppKit/NSBezierPath/transform(using:))

Transforms all points in the path using the specified transform.

### Accessing Elements of a Path

[`var cgPath: CGPath`](/documentation/AppKit/NSBezierPath/cgPath)

[`var elementCount: Int`](/documentation/AppKit/NSBezierPath/elementCount)

The total number of path elements in the path.

[`func element(at: Int) -> NSBezierPath.ElementType`](/documentation/AppKit/NSBezierPath/element(at:))

Returns the type of path element at the specified index.

[`func element(at: Int, associatedPoints: NSPointArray?) -> NSBezierPath.ElementType`](/documentation/AppKit/NSBezierPath/element(at:associatedPoints:))

Gets the element type and (and optionally) the associated points for the path element at the specified index.

[`func removeAllPoints()`](/documentation/AppKit/NSBezierPath/removeAllPoints())

Removes all path elements from the path, effectively clearing the path.

[`func setAssociatedPoints(NSPointArray?, at: Int)`](/documentation/AppKit/NSBezierPath/setAssociatedPoints(_:at:))

Changes the points associated with the specified path element.

### Caching a Path

[`- (BOOL) cachesBezierPath;`](/documentation/AppKit/NSBezierPath/cachesBezierPath)

Returns a Boolean value that indicates whether this object maintains a cached image of its path.

[`- (void) setCachesBezierPath:(BOOL) flag;`](/documentation/AppKit/NSBezierPath/setCachesBezierPath:)

Sets whether the path should cache its path information.

### Constants

[`enum ElementType`](/documentation/AppKit/NSBezierPath/ElementType)

Constants that specify basic path element commands.

[`enum LineJoinStyle`](/documentation/AppKit/NSBezierPath/LineJoinStyle-swift.enum)

Constants that specify the shape of the joins between connected segments of a stroked path.

[`enum LineCapStyle`](/documentation/AppKit/NSBezierPath/LineCapStyle-swift.enum)

Constants that specify the shape of endpoints for an open path when it is stroked.

[`enum WindingRule`](/documentation/AppKit/NSBezierPath/WindingRule-swift.enum)

Constants that specify the winding rule a Bézier path uses.

### Initializers

[`init(CGPath: CGPath)`](/documentation/AppKit/NSBezierPath/init(CGPath:)-4nao7)

[`init?(coder: NSCoder)`](/documentation/AppKit/NSBezierPath/init(coder:))

[`init(ovalInRect: NSRect)`](/documentation/AppKit/NSBezierPath/init(ovalInRect:))

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)