<!--
{
  "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

[`bezierPath`](/documentation/AppKit/NSBezierPath/bezierPath)

Creates and returns a new Bézier path object.

[`init(ovalIn:)`](/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:)`](/documentation/AppKit/NSBezierPath/init(rect:))

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

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

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

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

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

A flattened version of the path object.

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

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

### Constructing a Path

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

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

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

Appends a straight line to the path.

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

Adds a Bezier cubic curve to the path.

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

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

Closes the most recently added subpath.

[`relativeMove(to:)`](/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.

[`relativeLine(to:)`](/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.

[`relativeCurve(to:controlPoint1:controlPoint2:)`](/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.

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

### Appending Common Shapes to a Path

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

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

[`appendPoints(_:count:)`](/documentation/AppKit/NSBezierPath/appendPoints(_:count:))

Appends a series of line segments to the path.

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

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

[`appendArc(from:to:radius:)`](/documentation/AppKit/NSBezierPath/appendArc(from:to:radius:))

Appends an arc to the path.

[`appendArc(withCenter:radius:startAngle:endAngle:)`](/documentation/AppKit/NSBezierPath/appendArc(withCenter:radius:startAngle:endAngle:))

Appends an arc of a circle to the path.

[`appendArc(withCenter:radius:startAngle:endAngle:clockwise:)`](/documentation/AppKit/NSBezierPath/appendArc(withCenter:radius:startAngle:endAngle:clockwise:))

Appends an arc of a circle to the path.

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

Appends a rectangular path to the path.

[`appendRoundedRect(_:xRadius:yRadius:)`](/documentation/AppKit/NSBezierPath/appendRoundedRect(_:xRadius:yRadius:))

Appends a rounded rectangular path to the path.

[`append(withCGGlyph:in:)`](/documentation/AppKit/NSBezierPath/append(withCGGlyph:in:))

Appends an outline of the specified glyph to the path.

[`append(withCGGlyphs:count:in:)`](/documentation/AppKit/NSBezierPath/append(withCGGlyphs:count:in:))

Appends the outlines of the specified glyphs to the path.

[`appendGlyph(_:in:)`](/documentation/AppKit/NSBezierPath/appendGlyph(_:in:))

Appends an outline of the specified glyph to the path.

[`appendGlyphs(_:count:in:)`](/documentation/AppKit/NSBezierPath/appendGlyphs(_:count:in:))

Appends the outlines of the specified glyphs to the path.

[`appendPackedGlyphs(_:)`](/documentation/AppKit/NSBezierPath/appendPackedGlyphs(_:))

Appends an array of packed glyphs to the path.

### Accessing a Path’s Attributes

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

The winding rule used to fill the path.

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

The line cap style for the path.

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

The line join style for the path.

[`lineWidth`](/documentation/AppKit/NSBezierPath/lineWidth)

The width of stroked path lines.

[`miterLimit`](/documentation/AppKit/NSBezierPath/miterLimit)

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

[`flatness`](/documentation/AppKit/NSBezierPath/flatness)

The accuracy with which curves are rendered.

[`getLineDash(_:count:phase:)`](/documentation/AppKit/NSBezierPath/getLineDash(_:count:phase:))

Returns the line-stroking pattern for the receiver.

[`setLineDash(_:count:phase:)`](/documentation/AppKit/NSBezierPath/setLineDash(_:count:phase:))

Sets the line-stroking pattern for the path.

### Configuring Default Path Attributes

[`defaultWindingRule`](/documentation/AppKit/NSBezierPath/defaultWindingRule)

Returns the default winding rule used to fill all paths.

[`defaultLineCapStyle`](/documentation/AppKit/NSBezierPath/defaultLineCapStyle)

Returns the default line cap style for all paths.

[`defaultLineJoinStyle`](/documentation/AppKit/NSBezierPath/defaultLineJoinStyle)

Returns the default line join style for all paths.

[`defaultLineWidth`](/documentation/AppKit/NSBezierPath/defaultLineWidth)

Returns the default line width for the all paths.

[`defaultMiterLimit`](/documentation/AppKit/NSBezierPath/defaultMiterLimit)

Returns the default miter limit for all paths.

[`defaultFlatness`](/documentation/AppKit/NSBezierPath/defaultFlatness)

The default flatness value for all paths.

### Drawing a Path

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

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

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

Paints the region enclosed by the path.

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

Fills the specified rectangular path with the current fill color.

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

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

[`strokeLine(from:to:)`](/documentation/AppKit/NSBezierPath/strokeLine(from:to:))

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

[`drawPackedGlyphs(_:at:)`](/documentation/AppKit/NSBezierPath/drawPackedGlyphs(_:at:))

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

### Specifying a Clipping Path

[`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.

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

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

[`clip(_:)`](/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

[`contains(_:)`](/documentation/AppKit/NSBezierPath/contains(_:))

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

### Querying a Path

[`bounds`](/documentation/AppKit/NSBezierPath/bounds)

The bounding box of the path.

[`controlPointBounds`](/documentation/AppKit/NSBezierPath/controlPointBounds)

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

[`currentPoint`](/documentation/AppKit/NSBezierPath/currentPoint)

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

[`isEmpty`](/documentation/AppKit/NSBezierPath/isEmpty)

A Boolean value that indicates whether the path is empty.

### Applying Transformations

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

Transforms all points in the path using the specified transform.

### Accessing Elements of a Path

[`cgPath`](/documentation/AppKit/NSBezierPath/cgPath)

[`elementCount`](/documentation/AppKit/NSBezierPath/elementCount)

The total number of path elements in the path.

[`element(at:)`](/documentation/AppKit/NSBezierPath/element(at:))

Returns the type of path element at the specified index.

[`element(at:associatedPoints:)`](/documentation/AppKit/NSBezierPath/element(at:associatedPoints:))

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

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

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

[`setAssociatedPoints(_:at:)`](/documentation/AppKit/NSBezierPath/setAssociatedPoints(_:at:))

Changes the points associated with the specified path element.

### Caching a Path

[`cachesBezierPath`](/documentation/AppKit/NSBezierPath/cachesBezierPath)

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

[`setCachesBezierPath:`](/documentation/AppKit/NSBezierPath/setCachesBezierPath:)

Sets whether the path should cache its path information.

### Constants

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

Constants that specify basic path element commands.

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

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

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

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

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

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



---

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)