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

# CGMutablePath

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

```
class CGMutablePath
```

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

To append a new subpath onto a mutable path, your application typically calls [`CGPathMoveToPoint`](/documentation/CoreGraphics/CGPathMoveToPoint) to set the subpath’s starting point and initial current point, followed by a series of “add” calls (such as [`CGPathAddLineToPoint`](/documentation/CoreGraphics/CGPathAddLineToPoint)) to add line segments and curves to the subpath. As segments or curves are added to the subpath, the subpath’s current point is updated to point to the end of the last segment or curve to be added. The lines and curves of a subpath are always connected, but they are not required to form a closed set of lines. Your application explicitly closes a subpath by calling [`closeSubpath()`](/documentation/CoreGraphics/CGMutablePath/closeSubpath()). Closing the subpath adds a line segment that terminates at the subpath’s starting point, and also changes how those lines are rendered—for more information see [Paths](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/dq_paths.html#//apple_ref/doc/uid/TP30001066-CH211) in [Quartz 2D Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001066).

## Topics

### Creating Graphics Paths

[`init()`](/documentation/CoreGraphics/CGMutablePath/init())

Creates a mutable graphics path.

### 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

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

### Constructing a Graphics Path

[`move(to:transform:)`](/documentation/CoreGraphics/CGMutablePath/move(to:transform:))

Begins a new subpath at the specified point.

[`addLine(to:transform:)`](/documentation/CoreGraphics/CGMutablePath/addLine(to:transform:))

Appends a straight line segment from the current point to the specified point.

[`addLines(between:transform:)`](/documentation/CoreGraphics/CGMutablePath/addLines(between:transform:))

Adds a sequence of connected straight-line segments to the path.

[`addRect(_:transform:)`](/documentation/CoreGraphics/CGMutablePath/addRect(_:transform:))

Adds a rectangular subpath to the path.

[`addRects(_:transform:)`](/documentation/CoreGraphics/CGMutablePath/addRects(_:transform:))

Adds a set of rectangular subpaths to the path.

[`addEllipse(in:transform:)`](/documentation/CoreGraphics/CGMutablePath/addEllipse(in:transform:))

Adds an ellipse that fits inside the specified rectangle.

[`addRoundedRect(in:cornerWidth:cornerHeight:transform:)`](/documentation/CoreGraphics/CGMutablePath/addRoundedRect(in:cornerWidth:cornerHeight:transform:))

Adds a subpath to the path, in the shape of a rectangle with rounded corners.

[`addArc(center:radius:startAngle:endAngle:clockwise:transform:)`](/documentation/CoreGraphics/CGMutablePath/addArc(center:radius:startAngle:endAngle:clockwise:transform:))

Adds an arc of a circle to the path, specified with a radius and angles.

[`addArc(tangent1End:tangent2End:radius:transform:)`](/documentation/CoreGraphics/CGMutablePath/addArc(tangent1End:tangent2End:radius:transform:))

Adds an arc of a circle to the path, specified with a radius and two tangent lines.

[`addRelativeArc(center:radius:startAngle:delta:transform:)`](/documentation/CoreGraphics/CGMutablePath/addRelativeArc(center:radius:startAngle:delta:transform:))

Adds an arc of a circle to the path, specified with a radius and a difference in angle.

[`addCurve(to:control1:control2:transform:)`](/documentation/CoreGraphics/CGMutablePath/addCurve(to:control1:control2:transform:))

Adds a cubic Bézier curve to the path, with the specified end point and control points.

[`addQuadCurve(to:control:transform:)`](/documentation/CoreGraphics/CGMutablePath/addQuadCurve(to:control:transform:))

Adds a quadratic Bézier curve to the path, with the specified end point and control point.

[`addPath(_:transform:)`](/documentation/CoreGraphics/CGMutablePath/addPath(_:transform:))

Appends another path object to the path.

[`closeSubpath()`](/documentation/CoreGraphics/CGMutablePath/closeSubpath())

Closes and completes a subpath in a mutable graphics path.

### Constructing a Graphics Path

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

Starts a new subpath at a specified location in a mutable graphics path.

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

Appends a line segment to a mutable graphics path.

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

Appends an array of new line segments to a mutable graphics path.

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

Appends a rectangle to a mutable graphics path.

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

Appends an array of rectangles to a mutable graphics path.

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

Adds to a path an ellipse that fits inside a rectangle.

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

Appends a rounded rectangle to a mutable graphics path.

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

Appends an arc to a mutable graphics path, possibly preceded by a straight line segment.

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

Appends an arc to a mutable graphics path, possibly preceded by a straight line segment.

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

Appends an arc to a mutable graphics path, possibly preceded by a straight line segment.

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

Appends a cubic Bézier curve to a mutable graphics path.

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

Appends a quadratic Bézier curve to a mutable graphics path.

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

Appends a path to onto a mutable graphics path.

[`closeSubpath()`](/documentation/CoreGraphics/CGMutablePath/closeSubpath())

Closes and completes a subpath in a mutable graphics path.

## 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)