Cocoa Drawing Guide
PDF
Introduction
Overview of Cocoa Drawing
Cocoa Drawing Support
The Painter’s Model
The Drawing Environment
The Graphics Context
The Graphics State
The Coordinate System
Transforms
Color and Color Spaces
Basic Drawing Elements
Geometry Support
Shape Primitives
Images
Gradients
Text
Views and Drawing
Common Drawing Tasks
Graphics Contexts
Graphics Context Basics
The Current Context
Graphics State Information
Screen Canvases and Print Canvases
Graphics Contexts and Quartz
Modifying the Current Graphics State
Setting Colors and Patterns
Setting Path Attributes
Setting Text Attributes
Setting Compositing Options
Setting the Clipping Region
Setting the Anti-aliasing Options
Creating Graphics Contexts
Creating a Screen-Based Context
Creating a PDF or PostScript Context
Threading and Graphics Contexts
Coordinate Systems and Transforms
Coordinate Systems Basics
Local Coordinate Systems
Points Versus Pixels
User Space
Device Space
Resolution-Independent User Interface
Transform Basics
The Identity Transform
Transformation Operations
Translation
Scaling
Rotation
Transformation Ordering
Transform Mathematics
Using Transforms in Your Code
Creating and Applying a Transform
Undoing a Transformation
Transforming Coordinates
Converting from Window to View Coordinates
Flipped Coordinate Systems
Configuring Your View to Use Flipped Coordinates
Drawing Content in a Flipped Coordinate System
Drawing Shape Primitives
Drawing With Application Kit Functions
Drawing Images
Drawing Text
Creating a Flip Transform
Cocoa Use of Flipped Coordinates
Doing Pixel-Exact Drawing
Tips for Resolution Independent Drawing in Cocoa
Accessing the Current Scale Factor
Adjusting the Layout of Your Content
Converting Coordinate Values
Color and Transparency
About Color and Transparency
Color Models and Color Spaces
Color Objects
Color Component Values
Transparency
Pattern Colors
Color Lists
Color Matching
Creating Colors
Working with Colors
Applying Colors to Drawn Content
Applying Color to Text
Getting the Components of a Color
Choosing Colors
Working with Color Spaces
Converting Between Color Spaces
Mapping Physical Colors to a Color Space
Paths
Path Building Blocks
The NSBezierPath Class
Path Elements
Subpaths
Path Attributes
Line Width
Line Cap Styles
Line Join Styles
Line Dash Style
Line Flatness
Miter Limits
Winding Rules
Manipulating Geometric Types
Drawing Fundamental Shapes
Adding Points
Adding Lines and Polygons
Adding Rectangles
Adding Rounded Rectangles
Adding Ovals and Circles
Adding Arcs
Adding Bezier Curves
Adding Text
Drawing the Shapes in a Path
Drawing Rectangles
Working with Paths
Building Paths
Improving Rendering Performance
Reuse Your Path Objects
Correctness Versus Efficiency
Reduce Path Complexity
Manipulating Individual Path Elements
Transforming a Path
Creating a CGPathRef From an NSBezierPath Object
Detecting Mouse Hits on a Path
Images
Image Basics
Image Representations
Image Representation Classes
How an Image Representation Is Chosen
Images and Caching
Caching and Image Data Retention
Caching Images Separately
Image Size and Resolution
Image Coordinate Systems
Drawing Versus Compositing
Supported Image File Formats
Basic Formats
TIFF Compression
Support for Other File Formats
Guidelines for Using Images
Creating NSImage Objects
Loading an Existing Image
Loading a Named Image
Drawing to an Image
Creating a Bitmap
Capturing the Contents of a View or Image
Drawing Directly to a Bitmap
Creating a PDF or EPS Image Representation
Using a Quartz Image to Create an NSImage
Working with Images
Drawing Images into a View
Drawing Resizable Textures Using Images
Creating an OpenGL Texture
Applying Core Image Filters
Getting and Setting Bitmap Properties
Converting a Bitmap to a Different Format
Associating a Custom Color Profile With an Image
Converting Between Color Spaces
Creating the Target Image
Using a Custom Color Profile
Premultiplying Alpha Values for Bitmaps
Creating New Image Representation Classes
Text
Text Attributes
Simple Text Drawing
Advanced Text Drawing
Advanced Drawing Techniques
Adding Shadows to Drawn Paths
Creating Gradient Fills
Using the NSGradient Class
Configuring the Colors of a Gradient Object
Drawing to a High-Level Path
Using the Primitive Drawing Routines
Using Quartz Shadings in Cocoa
Drawing to the Screen
Capturing the Screen
Full-Screen Drawing in OpenGL
Full-Screen Drawing in Cocoa
Disabling Screen Updates
Using NSTimer for Animated Content
Using Cocoa Animation Objects
Optimizing Your Drawing Code
Draw Minimally
Avoid Forcing Synchronous Updates
Reuse Your Objects
Minimize State Changes
Incorporating Other Drawing Technologies
Using Quartz in Your Application
Using Quartz Features
Graphics Type Conversions
Getting a Quartz Graphics Context
Creating a Cocoa Graphics Context Using Quartz
Modifying the Graphics State
Using OpenGL in Your Application
Using NSOpenGLView
Creating an OpenGL Graphics Context
Using QuickTime in Your Application
Using the QuickTime Kit
Using QuickTime C-Based Functions
Using Quartz Composer Compositions
Choosing the Right Imaging Technology
Revision History
Related Reference
Objective-C
NSAffineTransform
NSBezierPath
NSColor
NSGradient
NSGraphicsContext
NSImage