Core Graphics

Harness the power of Quartz technology to perform lightweight 2D rendering with high-fidelity output. Handle path-based drawing, anti-aliased rendering, gradients, images, color management, PDF documents, and more.


The Core Graphics framework is based on the Quartz advanced drawing engine. It provides low-level, lightweight 2D rendering with unmatched output fidelity. You use this framework to handle path-based drawing, transformations, color management, offscreen rendering, patterns, gradients and shadings, image data management, image creation, and image masking, as well as PDF document creation, display, and parsing.

In macOS, Core Graphics also includes services for working with display hardware, low-level user input events, and the windowing system.


Geometric Data Types

struct CGFloat

The basic type for floating-point scalar values in Core Graphics and related frameworks.

struct CGPoint

A structure that contains a point in a two-dimensional coordinate system.

struct CGSize

A structure that contains width and height values.

struct CGRect

A structure that contains the location and dimensions of a rectangle.

struct CGVector

A structure that contains a two-dimensional vector.

struct CGAffineTransform

An affine transformation matrix for use in drawing 2D graphics.

2D Drawing

class CGContext

A Quartz 2D drawing environment.

class CGImage

A bitmap image or image mask.

class CGPath

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

class CGMutablePath

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

class CGLayer

An offscreen context for reusing content drawn with Core Graphics.

Colors and Fonts

class CGColor

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

class CGColorConversionInfo

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

class CGColorSpace

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

class CGFont

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

Working with PDF Documents

class CGPDFDocument

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

Utility and Support Classes

class CGDataConsumer

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

class CGDataProvider

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

class CGShading

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

class CGGradient

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

class CGFunction

A general facility for defining and using callback functions.

class CGPattern

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


Quartz Display Services

Provides direct access to features in the macOS window server for configuring and controlling display hardware.

Quartz Event Services

Provides features for managing event taps—filters for observing and altering the stream of low-level user input events in macOS.

Quartz Window Services

Provides information about the windows managed by the macOS window server.


enum CGPathFillRule

Rules for determining which regions are interior to a path, used by the fillPath(using:) and clip(using:) methods.


struct CGPSConverterCallbacks

A structure for holding the callbacks provided when you create a PostScript converter object.


class CGPSConverter

An opaque data type used to convert PostScript data to PDF data.

See Also

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software