NSColor provides a powerful and flexible system for
representing and manipulating colors across
different color spaces and devices. As an abstract
superclass of a class cluster, NSColor supports
multiple color models including RGB, HSB, CMYK,
grayscale, and catalog-based colors. Key features
include: * Multiple color space support (calibrated,
device-dependent, generic) *
Component-based color creation with precise
control * Comprehensive set of predefined system and
standard colors * Color space conversion and
device-specific adaptation * Pattern-based
colors using images * System appearance integration
with dynamic colors * Pasteboard integration for color
copying and pasting * Advanced color manipulation
(blending, highlighting, shadowing) * Support for
alpha transparency and composition NSColor
automatically handles color space conversions
and provides optimized representations for different
rendering contexts. The class integrates seamlessly
with the graphics system and supports both programmatic
color creation and system-provided appearance colors
that adapt to user preferences. Color spaces
NSDeviceBlackColorSpace and
NSCalibratedBlackColorSpace are
treated as synonyms for their white counterparts for
compatibility.
Returns the color appropriate for the specified
control tint. controlTint: The control tint (blue,
graphite, etc.) Returns: An NSColor matching the
control tint preference
Creates a color from color data on the pasteboard.
pasteBoard: The pasteboard to read color data
from Returns: A new NSColor from the pasteboard data,
or nil if no valid color data
Returns the NSColor on the NSPasteboard
pasteBoard or nil if it
does not exists.
Creates a color in the calibrated HSB color space.
hue: The hue component (0.0 to 1.0)
saturation: The saturation component
(0.0 to 1.0) brightness: The brightness
component (0.0 to 1.0) alpha: The
alpha transparency component (0.0 to 1.0)
Returns: A new NSColor instance in calibrated HSB
color space
Creates and returns a new NSColor in a
NSCalibratedRGBColorSpace space
name, with hue, saturation,
brightness and alpha as
specified. Valid values are the range 0.0 to
1.0. Out of range values will be clipped.
Creates a color in the calibrated RGB color space.
red: The red component (0.0 to 1.0) green:
The green component (0.0 to 1.0) blue: The
blue component (0.0 to 1.0) alpha: The
alpha transparency component (0.0 to 1.0)
Returns: A new NSColor instance in calibrated RGB
color space
Creates and returns a new NSColor in a
NSCalibratedRGBColorSpace space
name, with red, green,
blue and alpha as specified.
Valid values are the range 0.0 to 1.0. Out of range
values will be clipped.
Creates a grayscale color in the calibrated
white color space. white: The grayscale
value (0.0 for black to 1.0 for white)
alpha: The alpha transparency component
(0.0 to 1.0) Returns: A new NSColor instance in
calibrated white color space
Creates and returns a new NSColor in a
NSCalibratedWhiteColorSpace
space name, with red, green, blue and
alpha as specified. Valid values are the
range 0.0 to 1.0. Out of range values will be
clipped.
Creates a color from a color catalog. listName: The
name of the color catalog colorName: The name of the
color within the catalog Returns: A new NSColor
instance from the specified catalog, or
nil if not found
Creates a color with the specified color
space and component values. space: The
NSColorSpace to use comp: Array of component
values number: Number of components in the array
Returns: A new NSColor instance in the specified
color space
Creates a color in the device CMYK color space.
cyan: The cyan component (0.0 to 1.0)
magenta: The magenta component (0.0 to
1.0) yellow: The yellow component (0.0 to
1.0) black: The black component (0.0 to
1.0) alpha: The alpha transparency
component (0.0 to 1.0) Returns: A new NSColor
instance in device CMYK color space
Creates and returns a new NSColor in a
NSDeviceCMYKColorSpace space name,
with cyan, magenta,
yellow, black and
alpha as specified. Valid values are the
range 0.0 to 1.0. Out of range values will be
clipped.
Creates a color in the device HSB color space. hue:
The hue component (0.0 to 1.0) saturation:
The saturation component (0.0 to 1.0)
brightness: The brightness component
(0.0 to 1.0) alpha: The alpha transparency
component (0.0 to 1.0) Returns: A new NSColor
instance in device HSB color space
Creates and returns a new NSColor in a
NSDeviceCMYKColorSpace space name,
with hue, saturation,
brightness and alpha as
specified. Valid values are the range 0.0 to
1.0. Out of range values will be clipped.
Creates a color in the device RGB color space. red:
The red component (0.0 to 1.0) green: The
green component (0.0 to 1.0) blue: The
blue component (0.0 to 1.0) alpha: The
alpha transparency component (0.0 to 1.0)
Returns: A new NSColor instance in device RGB
color space
Creates and returns a new NSColor in a
NSDeviceCMYKColorSpace space name,
with red, green,
blue and alpha as specified.
Valid values are the range 0.0 to 1.0. Out of range
values will be clipped.
Creates a grayscale color in the device
white color space. white: The grayscale
value (0.0 for black to 1.0 for white)
alpha: The alpha transparency component
(0.0 to 1.0) Returns: A new NSColor instance in device
white color space
Creates and returns a new NSColor in a
NSDeviceWhiteColorSpace space
name, with red, green, blue and alpha as
specified. Valid values are the range 0.0 to
1.0. Out of range values will be clipped.
Creates a pattern color using the specified
image. image: The image to use
as the pattern Returns: A new NSColor that draws the
image as a repeating pattern
Returns whether alpha components are ignored in
color operations. Returns: YES if alpha
components are ignored, NO if they
are used Returns whether TODO
Returns a color that is a blend between this color
and another color. fraction: The fraction of
the other color to blend (0.0 to 1.0) aColor: The color
to blend with Returns: A new NSColor representing the
blended color
Returns a version of the color converted to the
specified color space. space: The
target NSColorSpace Returns: A new NSColor in the
specified color space, or
nil if conversion fails
Returns a version of the color converted to the
specified color space. colorSpace: The target
color space name Returns: A new NSColor in the
specified color space, or nil if
conversion fails
Returns a version of the color converted to the
specified color space and device. colorSpace: The
target color space name deviceDescription:
Dictionary describing the target device
characteristics Returns: A new NSColor in
the specified color space for the device, or
nil if conversion fails
Returns a version of the color with a different
alpha component. alpha: The new
alpha value (0.0 to 1.0) Returns: A new
NSColor with the specified alpha
component
Gets the CMYK components of the color. cyan: Pointer
to store the cyan component (0.0 to 1.0)
magenta: Pointer to store the magenta
component (0.0 to 1.0) yellow: Pointer to store
the yellow component (0.0 to 1.0) black:
Pointer to store the black component
(0.0 to 1.0) alpha: Pointer to store the
alpha component (0.0 to 1.0)
Gets the cyan, magenta,
yellow,black and alpha values
from the NSColor. Raises a
NSInternalInconsistencyException
if the NSColor is not a CYMK color
Gets the HSB components of the color. hue: Pointer to
store the hue component (0.0 to 1.0)
saturation: Pointer to store the
saturation component (0.0 to 1.0)
brightness: Pointer to store the
brightness component (0.0 to 1.0) alpha:
Pointer to store the alpha component
(0.0 to 1.0)
Gets the hue, saturation,
brightness and alpha values
from the NSColor. Raises a
NSInternalInconsistencyException
if the NSColor is not a RGB color
Gets the RGB components of the color. red: Pointer to
store the red component (0.0 to 1.0)
green: Pointer to store the green
component (0.0 to 1.0) blue: Pointer to store the
blue component (0.0 to 1.0) alpha: Pointer
to store the alpha component (0.0 to 1.0)
Gets the red, green,
blue and alpha values from
the NSColor. Raises a
NSInternalInconsistencyException
if the NSColor is not a RGB color
Gets the grayscale components of the color. white:
Pointer to store the grayscale value (0.0 to 1.0)
alpha: Pointer to store the alpha
component (0.0 to 1.0)
Gets the whitealpha values
from the NSColor. Raises a
NSInternalInconsistencyException
if the NSColor is not a greyscale color
Returns a highlighted version of the color. level:
The highlight level (0.0 for no change, 1.0
for maximum highlight) Returns: A new NSColor
representing the highlighted color
Returns the localized color name component of a
catalog-based color. Returns: The localized
name of the color within the catalog, or
nil if not a catalog color
Returns a shadowed version of the color. level: The
shadow level (0.0 for no change, 1.0 for
maximum shadow) Returns: A new NSColor representing
the shadowed color