---
title: CGPath
framework: coregraphics
role: symbol
role_heading: Class
path: coregraphics/cgpath
---

# CGPath

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

## Declaration

```swift
class CGPath
```

## Overview

Overview 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.

## Topics

### Creating Graphics Paths

- [init(rect:transform:)](coregraphics/cgpath/init(rect:transform:).md)
- [init(ellipseIn:transform:)](coregraphics/cgpath/init(ellipsein:transform:).md)
- [init(roundedRect:cornerWidth:cornerHeight:transform:)](coregraphics/cgpath/init(roundedrect:cornerwidth:cornerheight:transform:).md)

### Copying a Graphics Path

- [copy()](coregraphics/cgpath/copy().md)
- [copy(using:)](coregraphics/cgpath/copy(using:).md)
- [copy(dashingWithPhase:lengths:transform:)](coregraphics/cgpath/copy(dashingwithphase:lengths:transform:).md)
- [copy(strokingWithWidth:lineCap:lineJoin:miterLimit:transform:)](coregraphics/cgpath/copy(strokingwithwidth:linecap:linejoin:miterlimit:transform:).md)
- [mutableCopy()](coregraphics/cgpath/mutablecopy().md)
- [mutableCopy(using:)](coregraphics/cgpath/mutablecopy(using:).md)

### Examining a Graphics Path

- [boundingBox](coregraphics/cgpath/boundingbox.md)
- [boundingBoxOfPath](coregraphics/cgpath/boundingboxofpath.md)
- [currentPoint](coregraphics/cgpath/currentpoint.md)
- [contains(_:using:transform:)](coregraphics/cgpath/contains(_:using:transform:).md)
- [isEmpty](coregraphics/cgpath/isempty.md)
- [isRect(_:)](coregraphics/cgpath/isrect(_:).md)

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

- [apply(info:function:)](coregraphics/cgpath/apply(info:function:).md)
- [CGPathApplierFunction](coregraphics/cgpathapplierfunction.md)
- [CGPathElement](coregraphics/cgpathelement.md)
- [CGPathElementType](coregraphics/cgpathelementtype.md)

### Working with Core Foundation Types

- [typeID](coregraphics/cgpath/typeid.md)

### Instance Methods

- [applyWithBlock(_:)](coregraphics/cgpath/applywithblock(_:).md)
- [componentsSeparated(using:)](coregraphics/cgpath/componentsseparated(using:).md)
- [flattened(threshold:)](coregraphics/cgpath/flattened(threshold:).md)
- [intersection(_:using:)](coregraphics/cgpath/intersection(_:using:).md)
- [intersects(_:using:)](coregraphics/cgpath/intersects(_:using:).md)
- [lineIntersection(_:using:)](coregraphics/cgpath/lineintersection(_:using:).md)
- [lineSubtracting(_:using:)](coregraphics/cgpath/linesubtracting(_:using:).md)
- [normalized(using:)](coregraphics/cgpath/normalized(using:).md)
- [subtracting(_:using:)](coregraphics/cgpath/subtracting(_:using:).md)
- [symmetricDifference(_:using:)](coregraphics/cgpath/symmetricdifference(_:using:).md)
- [union(_:using:)](coregraphics/cgpath/union(_:using:).md)

## Relationships

### Inherited By

- [CGMutablePath](coregraphics/cgmutablepath.md)

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Related Documentation

- [Quartz 2D Programming Guide](apple-archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction.md)

### 2D Drawing

- [CGContext](coregraphics/cgcontext.md)
- [CGImage](coregraphics/cgimage.md)
- [CGMutablePath](coregraphics/cgmutablepath.md)
- [CGLayer](coregraphics/cglayer.md)
