<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGPath",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@T@CGPathRef"
  },
  "title" : "CGPath"
}
-->

# CGPath

An immutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context.

```
class CGPath
```

## Overview

Neither `CGPath` nor [`CGMutablePath`](/documentation/CoreGraphics/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(_:)`](/documentation/CoreGraphics/CGContext/addPath(_:)) and then call one of the context’s drawing functions—see [`CGContext`](/documentation/CoreGraphics/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.

## Topics

### Creating Graphics Paths

[`init(rect:transform:)`](/documentation/CoreGraphics/CGPath/init(rect:transform:))

Create an immutable path of a rectangle.

[`init(ellipseIn:transform:)`](/documentation/CoreGraphics/CGPath/init(ellipseIn:transform:))

Create an immutable path of an ellipse.

[`init(roundedRect:cornerWidth:cornerHeight:transform:)`](/documentation/CoreGraphics/CGPath/init(roundedRect:cornerWidth:cornerHeight:transform:))

Create an immutable path of a rounded rectangle.

### Retaining and Releasing a Path

[`CGPathRelease`](/documentation/CoreGraphics/CGPathRelease)

Decrements the retain count of a graphics path.

[`CGPathRetain`](/documentation/CoreGraphics/CGPathRetain)

Increments the retain count of a graphics path.

### Copying a Graphics Path

[`copy()`](/documentation/CoreGraphics/CGPath/copy())

Creates an immutable copy of a graphics path.

[`copy(using:)`](/documentation/CoreGraphics/CGPath/copy(using:))

Creates an immutable copy of a graphics path transformed by a transformation matrix.

[`copy(dashingWithPhase:lengths:transform:)`](/documentation/CoreGraphics/CGPath/copy(dashingWithPhase:lengths:transform:))

Returns a new path equivalent to the results of drawing the path with a dashed stroke.

[`CGPathCreateCopyByDashingPath`](/documentation/CoreGraphics/CGPathCreateCopyByDashingPath)

Creates a dashed copy of another path.

[`copy(strokingWithWidth:lineCap:lineJoin:miterLimit:transform:)`](/documentation/CoreGraphics/CGPath/copy(strokingWithWidth:lineCap:lineJoin:miterLimit:transform:))

Returns a new path equivalent to the results of drawing the path with a solid stroke.

[`CGPathCreateCopyByStrokingPath`](/documentation/CoreGraphics/CGPathCreateCopyByStrokingPath)

Creates a stroked copy of another path.

[`mutableCopy()`](/documentation/CoreGraphics/CGPath/mutableCopy())

Creates a mutable copy of an existing graphics path.

[`mutableCopy(using:)`](/documentation/CoreGraphics/CGPath/mutableCopy(using:))

Creates a mutable copy of a graphics path transformed by a transformation matrix.

### Examining a Graphics Path

[`CGPathEqualToPath`](/documentation/CoreGraphics/CGPathEqualToPath)

Indicates whether two graphics paths are equivalent.

[`boundingBox`](/documentation/CoreGraphics/CGPath/boundingBox)

Returns the bounding box containing all points in a graphics path.

[`boundingBoxOfPath`](/documentation/CoreGraphics/CGPath/boundingBoxOfPath)

Returns the bounding box of a graphics path.

[`currentPoint`](/documentation/CoreGraphics/CGPath/currentPoint)

Returns the current point in a graphics path.

[`contains(_:using:transform:)`](/documentation/CoreGraphics/CGPath/contains(_:using:transform:))

Returns whether the specified point is interior to the path.

[`CGPathContainsPoint`](/documentation/CoreGraphics/CGPathContainsPoint)

Checks whether a point is contained in a graphics path.

[`isEmpty`](/documentation/CoreGraphics/CGPath/isEmpty)

Indicates whether or not a graphics path is empty.

[`isRect(_:)`](/documentation/CoreGraphics/CGPath/isRect(_:))

Indicates whether or not a graphics path represents a rectangle.

### Applying a Function to the Elements of a Path

[`apply(info:function:)`](/documentation/CoreGraphics/CGPath/apply(info:function:))

For each element in a graphics path, calls a custom applier function.

[`CGPathApplierFunction`](/documentation/CoreGraphics/CGPathApplierFunction)

Defines a callback function that can view an element in a graphics path.

[`CGPathElement`](/documentation/CoreGraphics/CGPathElement)

A data structure that provides information about a path element.

[`CGPathElementType`](/documentation/CoreGraphics/CGPathElementType)

The type of element found in a path.

### Constants

[`CGPathDrawingMode`](/documentation/CoreGraphics/CGPathDrawingMode)

Options for rendering a path.

[`CGPathElementType`](/documentation/CoreGraphics/CGPathElementType)

The type of element found in a path.

[`CGLineCap`](/documentation/CoreGraphics/CGLineCap)

Styles for rendering the endpoint of a stroked line.

[`CGLineJoin`](/documentation/CoreGraphics/CGLineJoin)

Junction types for stroked lines.

### Working with Core Foundation Types

[`typeID`](/documentation/CoreGraphics/CGPath/typeID)

Returns the Core Foundation type identifier for Core Graphics paths.

### Instance Methods

[`applyWithBlock(_:)`](/documentation/CoreGraphics/CGPath/applyWithBlock(_:))

[`componentsSeparated(using:)`](/documentation/CoreGraphics/CGPath/componentsSeparated(using:))

[`flattened(threshold:)`](/documentation/CoreGraphics/CGPath/flattened(threshold:))

[`intersection(_:using:)`](/documentation/CoreGraphics/CGPath/intersection(_:using:))

[`intersects(_:using:)`](/documentation/CoreGraphics/CGPath/intersects(_:using:))

[`lineIntersection(_:using:)`](/documentation/CoreGraphics/CGPath/lineIntersection(_:using:))

[`lineSubtracting(_:using:)`](/documentation/CoreGraphics/CGPath/lineSubtracting(_:using:))

[`normalized(using:)`](/documentation/CoreGraphics/CGPath/normalized(using:))

[`subtracting(_:using:)`](/documentation/CoreGraphics/CGPath/subtracting(_:using:))

[`symmetricDifference(_:using:)`](/documentation/CoreGraphics/CGPath/symmetricDifference(_:using:))

[`union(_:using:)`](/documentation/CoreGraphics/CGPath/union(_:using:))

## See Also

  [Quartz 2D Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001066)



---

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)