The Quartz 2D API defines a variety of opaque data types in addition to graphics contexts. Because the API is part of the Core Graphics framework, the data types and the routines that operate on them use the CG prefix.
Quartz 2D creates objects from opaque data types that your application operates on to achieve a particular drawing output. Figure 1-4 shows the sorts of results you can achieve when you apply drawing operations to three of the objects provided by Quartz 2D. For example:
You can rotate and display a PDF page by creating a PDF page object, applying a rotation operation to the graphics context, and asking Quartz 2D to draw the page to a graphics context.
You can draw a pattern by creating a pattern object, defining the shape that makes up the pattern, and setting up Quartz 2D to use the pattern as paint when it draws to a graphics context.
You can fill an area with an axial or radial shading by creating a shading object, providing a function that determines the color at each point in the shading, and then asking Quartz 2D to use the shading as a fill color.
The opaque data types available in Quartz 2D include the following:
CGPathRef, used for vector graphics to create paths that you fill or stroke. See “Paths.”
CGImageRef, used to represent bitmap images and bitmap image masks based on sample data that you supply. See “Bitmap Images and Image Masks.”
CGLayerRef, used to represent a drawing layer that can be used for repeated drawing (such as for backgrounds or patterns) and for offscreen drawing, available starting in Mac OS X v10.4. See “CGLayer Drawing”
CGPatternRef, used for repeated drawing, available starting in Mac OS X v10.2. See “Patterns.”
CGShadingRef (available starting in Mac OS X v10.2) and CGGradientRef available starting in Mac OS X v10.5), used to paint gradients. See “Gradients.”
CGFunctionRef, used to define callback functions that take an arbitrary number of floating-point arguments, available starting in Mac OS X v10.2. You use this data type when you create gradients for a shading. See “Gradients.”
CGColorRef and CGColorSpaceRef, used to inform Quartz how to interpret color. CGColor is available starting in Mac OS X v10.3. See “Color and Color Spaces.”
CGPSConverterRef, used to convert PostScript to PDF, available starting in Mac OS X v10.3. See “PostScript Conversion.”
CGDataConsumerRef and CGDataProviderRef, which you use to move data into and out of Quartz. See “Data Management.”
Note: The preferred way for managing image data in Mac OS X v10.4 and later is to use CGImageSourceRef and CGImageDestinationRef. See Image I/O Programming Guide.
CGPDFDictionaryRef, CGPDFObjectRef, CGPDFPageRef, CGPDFStream, CGPDFStringRef, and CGPDFArrayRef, which provide access to PDF metadata, are available starting in Mac OS X v10.3. See “PDF Document Creation, Viewing, and Transforming.”
CGPDFScannerRef and CGPDFContentStreamRef, which parse PDF metadata and are available starting in Mac OS X v10.4. See “PDF Document Parsing.”
Last updated: 2007-12-11