CGPath

Immutable and mutable types for graphics paths: mathematical descriptions of shapes or lines to be drawn in a graphics context.

Overview

Neither CGPathRef nor CGMutablePathRef 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 CGContextAddPath 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.

To append a new subpath onto a mutable path, your application typically calls CGPathMoveToPoint to set the subpath’s starting point and initial current point, followed by a series of "add” calls (such as 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 CGPathCloseSubpath. 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 in Quartz 2D Programming Guide.

Topics

Creating and Managing Paths

CGPathCreateMutable

Creates a mutable graphics path.

CGPathCreateWithEllipseInRect

Create an immutable path of an ellipse.

CGPathCreateWithRect

Create an immutable path of a rectangle.

CGPathCreateWithRoundedRect

Create an immutable path of a rounded rectangle.

CGPathCreateCopy

Creates an immutable copy of a graphics path.

CGPathCreateCopyByTransformingPath

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

CGPathCreateCopyByDashingPath

Creates a dashed copy of another path.

CGPathCreateCopyByStrokingPath

Creates a stroked copy of another path.

CGPathCreateMutableCopy

Creates a mutable copy of an existing graphics path.

CGPathCreateMutableCopyByTransformingPath

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

CGPathRelease

Decrements the retain count of a graphics path.

CGPathRetain

Increments the retain count of a graphics path.

Modifying Core Graphics Paths

CGPathAddArc

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

CGPathAddRelativeArc

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

CGPathAddArcToPoint

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

CGPathAddCurveToPoint

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

CGPathAddLines

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

CGPathAddLineToPoint

Appends a line segment to a mutable graphics path.

CGPathAddPath

Appends a path to onto a mutable graphics path.

CGPathAddQuadCurveToPoint

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

CGPathAddRect

Appends a rectangle to a mutable graphics path.

CGPathAddRects

Appends an array of rectangles to a mutable graphics path.

CGPathAddRoundedRect

Appends a rounded rectangle to a mutable graphics path.

CGPathApply

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

CGPathMoveToPoint

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

CGPathCloseSubpath

Closes and completes a subpath in a mutable graphics path.

CGPathAddEllipseInRect

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

Getting Information about Core Graphics Paths

CGPathEqualToPath

Indicates whether two graphics paths are equivalent.

CGPathGetBoundingBox

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

CGPathGetPathBoundingBox

Returns the bounding box of a graphics path.

CGPathGetCurrentPoint

Returns the current point in a graphics path.

CGPathGetTypeID

Returns the Core Foundation type identifier for Core Graphics paths.

CGPathIsEmpty

Indicates whether or not a graphics path is empty.

CGPathIsRect

Indicates whether or not a graphics path represents a rectangle.

CGPathContainsPoint

Checks whether a point is contained in a graphics path.

Callbacks

CGPathApplierFunction

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

Data Types

CGPathRef

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

CGMutablePathRef

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

CGPathElement

A data structure that provides information about a path element.

Constants

CGPathDrawingMode

Options for rendering a path.

CGPathElementType

The type of element found in a path.

CGLineCap

Styles for rendering the endpoint of a stroked line.

CGLineJoin

Junction types for stroked lines.

See Also

Opaque Types

CGBitmapContext

A type of CGContextRef that you can use for drawing bits to memory.

CGColor

A set of components that define a color, with a color space specifying how to interpret them.

CGColorConversionInfo

An object that describes how to convert between color spaces for use by other system services.

CGColorSpace

A profile that specifies how to interpret a color value for display.

CGContext

A Quartz 2D drawing destination.

CGDataConsumer

An abstraction for data-writing tasks that eliminates the need to manage a raw memory buffer.

CGDataProvider

An abstraction for data-reading tasks that eliminates the need to manage a raw memory buffer.

CGFont

A set of character glyphs and layout information for drawing text.

CGFunction

A general facility for defining and using callback functions.

CGGLContext

Deprecated. A type of CGContextRef for drawing OpenGL content.

CGGradient

A definition for a smooth transition between colors for drawing radial and axial gradient fills.

CGImage

A bitmap image or image mask.

CGLayer

An offscreen context for reusing content drawn with Core Graphics.

CGPattern

A 2D pattern to be used for drawing graphics paths.

CGPDFArray

An array structure within a PDF document.

CGPDFContentStream

A representation of one or more content data streams in a PDF page.

CGPDFContext

A type of CGContextRef for drawing PDF content.

CGPDFDictionary

A dictionary structure within a PDF document.

CGPDFDocument

A document that contains PDF (Portable Document Format) drawing information.

CGPDFObject

An object representing content within a PDF document.

CGPDFOperatorTable

A set of callback functions for operators used when scanning content in a PDF document.

CGPDFPage

A page in a PDF document.

CGPDFScanner

A parser object for handling content and operators in a PDF content stream.

CGPDFStream

A stream or sequence of data bytes in a PDF document.

CGPDFString

A text string in a PDF document.

CGPSConverter

An object that converts PostScript data to PDF data.

CGShading

A definition for a smooth transition between colors, controlled by a custom function you provide, for drawing radial and axial gradient fills.