Working with Color
Colors in the
Application Kit
are represented by instances of the NSColor class,
which provides an interface for creating colors and setting the color
used by the current graphics context. AppKit supports several color
spaces that fall into three categories:
- Device-dependent
Color spaces support colors that may appear differently on different devices (such as a color printer or monitor).
- Device-independent
Colors are calibrated so they appear the same on any output device.
- Named
Color spaces represent colors that don’t correspond to numerical values, but are referenced in a catalogue of named colors.
The six color spaces supported by the Application Kit are based on these three categories, as detailed in Table 4-3.
|
Color space name |
Description |
NSDeviceCMYKColorSpace |
Cyan, magenta, yellow, black, and alpha components |
NSDeviceRGBColorSpace |
Red, green, blue, and alpha components; or hue, saturation, brightness, and alpha components |
NSCalibratedRGBColorSpace |
Red, green, blue, and alpha components; or hue, saturation, brightness, and alpha components |
NSDeviceWhiteColorSpace |
White and alpha components (grayscale) |
NSCalibratedWhiteColorSpace |
White and alpha components (grayscale) |
NSNamedColorSpace |
Catalog name and color name components |
The color spaces that are NSDevice... are
device-dependent color spaces, while those that are
NSCalibrated... color spaces are
device-independent. Table 4-3 lists constant ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access