[TOC] [Prev] [Next] [Bottom]

NSColor

Inherits From:
NSResponder : NSObject

Conforms To:
NSCoding
NSCopying
NSObject (NSObject)

Declared In:
AppKit/NSColor.h


Class At A Glance

Purpose

An NSColor object represents a color, which is defined in a color space, each point of which has a set of components (such as red, green, and blue) that uniquely define a color.

Principal Attributes

Creation

Various colorWith... and colorUsing... methods
Preset colors: blackColor, blueColor, etc.

Commonly Used Methods

colorUsingColorSpaceName: Creates an NSColor in the specified color space.
set Sets the drawing color.


Class Description

An NSColor object represents color and sometimes opacity (alpha). By sending a set message to an NSColor instance, you set the color for the current PostScript drawing context. This causes subsequently drawn graphics to have the color represented by the NSColor instance.

Color Spaces

A color is defined in some particular color space. A color space consists of a set of dimensions-such as red, green, and blue in the case of RGB space. Each point in the space represents a unique color, and the point's location along each dimension is called a component. An individual color is usually specified by the numeric values of its components, which range from 0.0 to 1.0. For instance, a pure red is specified in RGB space by the component values 1.0, 0.0, and 0.0.

Some color spaces include an alpha component, which defines the color's opacity. An alpha value of 1.0 means completely opaque, and 0.0 means completely transparent. The alpha component is ignored when the color is used on a device that doesn't support alpha, such as a printer.

There are three kinds of color spaces in the Application Kit:

NSColors provided by the Application Kit use eight different color spaces, referred to by these global NSString variables:

Global Variable Color Space Description
NSDeviceCMYKColorSpace Cyan, magenta, yellow, black, and alpha components
NSDeviceWhiteColorSpace White and alpha components
NSDeviceBlackColorSpace Black and alpha components
NSDeviceRGBColorSpace Red, green, blue, and alpha components Hue, saturation, brightness, and alpha components
NSCalibratedWhiteColorSpace White and alpha components
NSCalibratedBlackColorSpace Black and alpha components
NSCalibratedRGBColorSpace Red, green, blue, and alpha components Hue, saturation, brightness, and alpha components
NSNamedColorSpace Catalog name and color name components

Color spaces whose names start with "NSDevice" are device-dependent; those whose names start with "NSCalibrated" are device-independent.

Color Components

There's usually no need to retrieve the individual components of a color, but when needed, you can either retrieve a set of components (using such methods as getRed:green:blue:alpha:) or an individual component (using such methods as redComponent). However, it's illegal to ask an NSColor for components that aren't defined for its color space. You can identify the color space by sending a colorSpaceName message to the NSColor object. If you need to ask an NSColor for components that aren't in its color space (for instance, when you've gotten the color from the color panel), first convert the color to the appropriate color space using the colorUsingColorSpaceName: method. If the color is already in the specified color space, you get the same color back; otherwise you get a conversion that's usually lossy or that's correct only for the current device. You get back nil if the specified conversion can't be done.

Creating Subclasses

Subclasses of NSColor need to implement the colorSpaceName and set methods, as well as the methods that return the components for that color space and the methods in the NSCoding protocol. Some other methods-such as colorWithAlphaComponent:, isEqual:, and colorUsingColorSpaceName:device:-may also be implemented if they make sense for the color space. Mutable subclasses (if any) should additionally implement copyWithZone: to provide a true copy.

System Colors

NSColor has a number of methods which return "system" colors; colors that are controlled by user preferences. These colors-including controlColor, textColor, and selectedTextColor-should be used by developers who want to create custom controls or subclass existing controls which honor the user's color preferences. System colors are implemented as named colors in a special color list named "System." To extract the components of a system color, you must use NSColor's colorUsingColorSpaceName: method to convert the color to a color space known to respond to the component accessor methods you need.

An NSSystemColorsDidChangeNotification is sent when the system colors have been changed (such as through a system control panel interface). If you have any non-system colors that depend on the system colors, you can change them when you receive this notification.


Adopted Protocols

NSCoding
- encodeWithCoder:
- initWithCoder:
NSCopying
- copyWithZone:

Method Types

Creating an NSColor object from Component Values
+ colorWithCalibratedHue:saturation:brightness:alpha:
+ colorWithCalibratedRed:green:blue:alpha:
+ colorWithCalibratedWhite:alpha:
+ colorWithCatalogName:colorName:
+ colorWithDeviceCyan:magenta:yellow:black:alpha:
+ colorWithDeviceHue:saturation:brightness:alpha:
+ colorWithDeviceRed:green:blue:alpha:
+ colorWithDeviceWhite:alpha:
Creating an NSColor With Preset Components
+ blackColor
+ blueColor
+ brownColor
+ clearColor
+ cyanColor
+ darkGrayColor
+ grayColor
+ greenColor
+ lightGrayColor
+ magentaColor
+ orangeColor
+ purpleColor
+ redColor
+ whiteColor
+ yellowColor
Creating a system color-that is, an NSColor whose value is specified by user preferences
+ controlBackgroundColor
+ controlColor
+ controlHighlightColor
+ controlLightHighlightColor
+ controlShadowColor
+ controlDarkShadowColor
+ controlTextColor
+ disabledControlTextColor
+ gridColor
+ highlightColor
+ knobColor
+ scrollBarColor
+ selectedControlColor
+ selectedControlTextColor
+ selectedMenuItemColor
+ selectedMenuItemTextColor
+ selectedTextBackgroundColor
+ selectedTextColor
+ selectedKnobColor
+ shadowColor
+ textBackgroundColor
+ textColor
+ windowFrameColor
+ windowFrameTextColor
Ignoring Alpha Components
+ ignoresAlpha
+ setIgnoresAlpha:
Copying and Pasting
+ colorFromPasteboard:
- writeToPasteboard:
Retrieving a Set of Components
- getCyan:magenta:yellow:black:alpha:
- getHue:saturation:brightness:alpha:
- getRed:green:blue:alpha:
- getWhite:alpha:
Retrieving Individual Components
- alphaComponent
- blackComponent
- blueComponent
- brightnessComponent
- catalogNameComponent
- colorNameComponent
- cyanComponent
- greenComponent
- hueComponent
- localizedCatalogNameComponent
- localizedColorNameComponent
- magentaComponent
- redComponent
- saturationComponent
- whiteComponent
- yellowComponent
Converting to Another Color Space
- colorSpaceName
- colorUsingColorSpaceName:
- colorUsingColorSpaceName:device:
Changing the Color
- blendedColorWithFraction:ofColor:
- colorWithAlphaComponent:
- highlightWithLevel:
- shadowWithLevel:
Drawing
- drawSwatchInRect:
- set

Class Methods

blackColor

+ (NSColor *)blackColor

Returns an NSColor in NSCalibratedWhiteColorSpace whose grayscale value is 0.0 and whose alpha value is 1.0.

See also: - blackComponent


blueColor

+ (NSColor *)blueColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 0.0, 0.0, 1.0 and whose alpha value is 1.0.

See also: - blueComponent


brownColor

+ (NSColor *)brownColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 0.6, 0.4, 0.2 and whose alpha value is 1.0.


clearColor

+ (NSColor *)clearColor

Returns an NSColor in NSCalibratedWhiteColorSpace whose grayscale and alpha values are both 0.0.


colorFromPasteboard:

+ (NSColor *)colorFromPasteboard:(NSPasteboard *)pasteBoard

Returns the NSColor currently on the pasteboard, or nil if the pasteboard doesn't contain color data. The returned color's alpha component is set to 1.0 if ignoresAlpha returns YES.

See also: - writeToPasteboard:


colorWithCalibratedHue:saturation:brightness:alpha:

+ (NSColor *)colorWithCalibratedHue:(float)hue
saturation:(float)saturation
brightness:(float)brightness
alpha:(float)alpha

Creates and returns an NSColor whose color space is NSCalibratedRGBColorSpace, whose opacity value is alpha, and whose components in HSB space would be hue, saturation, and brightness. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.)

See also: + colorWithCalibratedRed:green:blue:alpha:, + colorWithDeviceHue:saturation:brightness:alpha:, - getHue:saturation:brightness:alpha:


colorWithCalibratedRed:green:blue:alpha:

+ (NSColor *)colorWithCalibratedRed:(float)red
green:(float)green
blue:(float)blue
alpha:(float)alpha

Creates and returns an NSColor whose color space is NSCalibratedRGBColorSpace, whose opacity value is alpha, and whose RGB components are red, green, and blue. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.)

See also: + colorWithCalibratedHue:saturation:brightness:alpha:, + colorWithDeviceRed:green:blue:alpha:, - getRed:green:blue:alpha:


colorWithCalibratedWhite:alpha:

+ (NSColor *)colorWithCalibratedWhite:(float)white
alpha:(float)alpha

Creates and returns an NSColor whose color space is NSCalibratedWhiteColorSpace, whose opacity value is alpha, and whose grayscale value is white. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.)

See also: + colorWithDeviceWhite:alpha:, - getWhite:alpha:


colorWithCatalogName:colorName:

+ (NSColor *)colorWithCatalogName:(NSString *)listName
colorName:(NSString *)colorName

Creates and returns an NSColor whose color space is NSNamedColorSpace, by finding the color named colorName in the catalog named listName, which may be a standard catalog.

See also: - catalogNameComponent, - colorNameComponent, - localizedCatalogNameComponent


colorWithDeviceCyan:magenta:yellow:black:alpha:

+ (NSColor *)colorWithDeviceCyan:(float)cyan
magenta:(float)magenta
yellow:(float)yellow
black:(float)black
alpha:(float)alpha

Creates and returns an NSColor whose color space is NSDeviceCMYKColorSpace, whose opacity value is alpha, and whose CMYK components are cyan, magenta, yellow, and black. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setcmykcolor.

See also: - getCyan:magenta:yellow:black:alpha:


colorWithDeviceHue:saturation:brightness:alpha:

+ (NSColor *)colorWithDeviceHue:(float)hue
saturation:(float)saturation
brightness:(float)brightness
alpha:(float)alpha

Creates and returns an NSColor whose color space is NSDeviceRGBColorSpace, whose opacity value is alpha, and whose components in HSB space would be hue, saturation, and brightness. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setrgbcolor.

See also: + colorWithCalibratedHue:saturation:brightness:alpha:, - colorWithDeviceRed:green:blue:alpha:, - getHue:saturation:brightness:alpha:


colorWithDeviceRed:green:blue:alpha:

+ (NSColor *)colorWithDeviceRed:(float)red
green:(float)green
blue:(float)blue
alpha:(float)alpha

Creates and returns an NSColor whose color space is NSDeviceRGBColorSpace, whose opacity value is alpha, and whose RGB components are red, green, and blue. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setrgbcolor.

See also: + colorWithCalibratedRed:green:blue:alpha:, + colorWithDeviceHue:saturation:brightness:alpha:, - getRed:green:blue:alpha:


colorWithDeviceWhite:alpha:

+ (NSColor *)colorWithDeviceWhite:(float)white
alpha:(float)alpha

Creates and returns an NSColor whose color space is NSDeviceWhiteColorSpace, whose opacity value is alpha, and whose grayscale value is white. (Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.) In PostScript, this colorspace corresponds directly to the device-dependent operator setgray.

See also: + colorWithCalibratedWhite:alpha:, - getWhite:alpha:


controlBackgroundColor

+ (NSColor *)controlBackgroundColor

Returns the system color used for the background of large controls such as browsers, table views and clip views. By default, this color is light gray on the Macintosh, and COLOR_WINDOW on Windows. For general information on system colors, see the "System Colors" section of the class description, above.


controlColor

+ (NSColor *)controlColor

Returns the system color used for the flat surfaces of a control. By default, the control color is light gray on the Macintosh, and COLOR_3DFACE in Windows. A control's beveled edges, which set it in relief, are drawn in the colors returned by controlShadowColor, controlDarkShadowColor, controlHighlightColor and controlLightHighlightColor. When a control is selected-that is, clicked or dragged-it changes to the color returned by selectedControlColor.

The return value of controlColor is also the system color used for window backgrounds. For general information about system colors, see the "System Colors" section of the class description, above.


controlDarkShadowColor

+ (NSColor *)controlDarkShadowColor

Returns the system color used for the dark edge of the shadow dropped from controls. Controls are displayed as though they were lit from the upper left. Two dark borders, representing shadows, run along the bottom and right. controlDarkShadowColor returns the color of the outer, darker border. By default, this color is black on the Macintosh, and COLOR_3DDKSHADOW on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + controlShadowColor


controlHighlightColor

+ (NSColor *)controlHighlightColor

Returns the system color used for the highlighted bezels of controls. Controls are displayed as though they were lit from the upper left. Two light borders, representing reflections from the light source, run along the top and left. controlHighlightColor returns the color of the inner, duller border. By default, this color is light gray on the Macintosh, and COLOR_3DLIGHT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + controlLightHighlightColor


controlLightHighlightColor

+ (NSColor *)controlLightHighlightColor

Returns the system color used for light highlights in controls. Controls are displayed as though they were lit from the upper left. Two light borders, representing reflections from the light source, run along the top and left. controlLightHighlightColor returns the color of the outer, brighter border. By default, this color is white on the Macintosh, and COLOR_3DHILIGHT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + controlHighlightColor


controlShadowColor

+ (NSColor *)controlShadowColor

Returns the system color used for the shadows dropped from controls. Controls are displayed as though they were lit from the upper left. Two dark borders, representing shadows, run along the bottom and right. controlShadowColor returns the color of the inner, lighter border. By default, this color is dark gray on the Macintosh, and COLOR_3DSHADOW on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + controlDarkShadowColor


controlTextColor

+ (NSColor *)controlTextColor

Returns the system color used for text on controls that aren't disabled. By default, the text color is black on the Macintosh, and COLOR_BTNTEXT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + disabledControlTextColor


cyanColor

+ (NSColor *)cyanColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 0.0, 1.0, 1.0 and whose alpha value is 1.0.

See also: - cyanComponent


darkGrayColor

+ (NSColor *)darkGrayColor

Returns an NSColor in NSCalibratedWhiteColorSpace whose grayscale value is 1/3 and whose alpha value is 1.0.

See also: + lightGrayColor, + grayColor


disabledControlTextColor

+ (NSColor *)disabledControlTextColor

Returns the system color used for text on disabled controls. By default, the text color is dark gray on the Macintosh, and COLOR_3DSHADOW on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + controlTextColor


grayColor

+ (NSColor *)grayColor

Returns an NSColor in NSCalibratedWhiteColorSpace whose grayscale value is 0.5 and whose alpha value is 1.0.

See also: + lightGrayColor, + darkGrayColor


greenColor

+ (NSColor *)greenColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 0.0, 1.0, 0.0 and whose alpha value is 1.0.

See also: - greenComponent


gridColor

+ (NSColor *)gridColor

Returns the system color used for the optional gridlines in, for example, a table view. By default, this color is gray on the Macintosh, and COLOR_3DFACE on Windows. For general information about system colors, see the "System Colors" section of the class description, above.


highlightColor

+ (NSColor *)highlightColor

Returns the system color that represents the virtual light source on the screen. By default, this color is white on the Macintosh, and COLOR_3DHILIGHT on Windows. This method is invoked by the highlightWithLevel: method. For general information about system colors, see the "System Colors" section of the class description, above.

See also: - highlightWithLevel:


ignoresAlpha

+ (BOOL)ignoresAlpha

Returns YES if the application doesn't support alpha. This value returned is consulted when an application imports alpha (through color dragging, for instance). The value determines whether the color panel has an opacity slider. This value is YES by default, indicating that the opacity components of imported colors will be set to 1.0. If an application wants alpha, it can invoke the setIgnoresAlpha method with a parameter of NO.

See also: + setIgnoresAlpha:, - alphaComponent


knobColor

+ (NSColor *)knobColor

Returns the system color used for the flat surface of a slider knob that hasn't been selected. By default, this color is light blue on the Macintosh, and COLOR_3DFACE on Windows. The knob's beveled edges, which set it in relief, are drawn in highlighted and shadowed versions of the face color. When a knob is selected, its color changes to selectedKnobColor. For general information about system colors, see the "System Colors" section of the class description, above.


lightGrayColor

+ (NSColor *)lightGrayColor

Returns an NSColor in NSCalibratedWhiteColorSpace whose grayscale value is 2/3 and whose alpha value is 1.0.

See also: + grayColor, + darkGrayColor


magentaColor

+ (NSColor *)magentaColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 1.0, 0.0, 1.0 and whose alpha value is 1.0.

See also: - magentaComponent


orangeColor

+ (NSColor *)orangeColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 1.0, 0.5, 0.0 and whose alpha value is 1.0.


purpleColor

+ (NSColor *)purpleColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 0.5, 0.0, 0.5 and whose alpha value is 1.0.


redColor

+ (NSColor *)redColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 1.0, 0.0, 0.0 and whose alpha value is 1.0.

See also: - redComponent


scrollBarColor

+ (NSColor *)scrollBarColor

Returns the system color used for scroll "bars"-that is, for the groove in which a scroller's knob moves. By default, this color is gray on the Macintosh, and COLOR_SCROLLBAR on Windows. On Windows, when a scroll bar is dragged, its color changes to the return value of selectedControlColor; on the Macintosh, however, its color does not change. For general information about system colors, see the "System Colors" section of the class description, above.


selectedControlColor

+ (NSColor *)selectedControlColor

Returns the system color used for the face of a selected control-that is a control being clicked or dragged. By default, this color is white on the Macintosh, and COLOR_HIGHLIGHT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + selectedControlTextColor


selectedControlTextColor

+ (NSColor *)selectedControlTextColor

Returns the system color used for text in a selected control-that is a control being clicked or dragged. By default, this color is black on the Macintosh, and COLOR_HIGHLIGHTTEXT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + selectedControlColor


selectedKnobColor

+ (NSColor *)selectedKnobColor

Returns the system color used for the slider knob when it is selected-that is, dragged. By default, this color is light blue on the Macintosh, and COLOR_HIGHLIGHT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + knobColor


selectedMenuItemColor

+ (NSColor *)selectedMenuItemColor

Returns the system color used for the face of selected menu items. By default, this color is white on the Macintosh, and COLOR_HIGHLIGHT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + selectedMenuItemTextColor


selectedMenuItemTextColor

+ (NSColor *)selectedMenuItemTextColor

Returns the system color used for the text in menu items. By default, this color is black on the Macintosh, and COLOR_HIGHLIGHTTEXT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + selectedMenuItemColor


selectedTextBackgroundColor

+ (NSColor *)selectedTextBackgroundColor

Returns the system color used for the background of selected text. By default, this color is light gray on the Macintosh, and COLOR_HIGHLIGHT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + selectedTextColor


selectedTextColor

+ (NSColor *)selectedTextColor

Returns the system color used for selected text. By default, this color is black on the Macintosh, and COLOR_HIGHLIGHTTEXT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + selectedTextBackgroundColor


setIgnoresAlpha:

+ (void)setIgnoresAlpha:(BOOL)flag

If flag is YES, The application won't support alpha. In this case, no opacity slider is displayed in the color panel, and colors dragged in or pasted have their alpha values set to 1.0. Applications which need to import alpha can invoke this method with flag set to NO and explicitly make colors opaque in cases where it matters to them.

See also: + ignoresAlpha, - alphaComponent


shadowColor

+ (NSColor *)shadowColor

Returns the system color that represents the virtual shadows cast by raised objects on the screen. This method is invoked by shadowWithLevel:. By default, the color it returns is black on the Macintosh, and COLOR_3DDKSHADOW on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: - shadowWithLevel:


textBackgroundColor

+ (NSColor *)textBackgroundColor

Returns the system color used for the text background. By default, this color is white on the Macintosh, and COLOR_WINDOW on Windows. When text is selected, its background color changes to the return value of selectedTextBackgroundColor. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + textColor


textColor

+ (NSColor *)textColor

Returns the system color used for text. By default, this color is black on the Macintosh, and COLOR_WINDOWTEXT on Windows. When text is selected, its background color changes to the return value of selectedTextColor. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + textBackgroundColor


whiteColor

+ (NSColor *)whiteColor

Returns an NSColor in NSCalibratedWhiteColorSpace whose grayscale and alpha values are both 1.0.

See also: - whiteComponent


windowFrameColor

+ (NSColor *)windowFrameColor

Returns the system color used for window frames, except for their text. By default, this color is gray on the Macintosh, and COLOR_ACTIVEBORDER on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + windowFrameTextColor


windowFrameTextColor

+ (NSColor *)windowFrameTextColor

Returns the system color used for the text in window frames. By default, this color is black on the Macintosh, and COLOR_CAPTIONTEXT on Windows. For general information about system colors, see the "System Colors" section of the class description, above.

See also: + windowFrameColor


yellowColor

+ (NSColor *)yellowColor

Returns an NSColor in NSCalibratedRGBColorSpace whose RGB value is 1.0, 1.0, 0.0 and whose alpha value is 1.0.

See also: - yellowComponent


Instance Methods

alphaComponent

- (float)alphaComponent

Returns the receiver's alpha (opacity) component. Returns 1.0 (opaque) if the receiver has no alpha component.

See also: - getCyan:magenta:yellow:black:alpha:, - getHue:saturation:brightness:alpha:, - getRed:green:blue:alpha:, - getWhite:alpha:


blackComponent

- (float)blackComponent

Returns the receiver's black component. Raises an exception if the receiver isn't a CMYK color.

See also: - getCyan:magenta:yellow:black:alpha:


blendedColorWithFraction:ofColor:

- (NSColor *)blendedColorWithFraction:(float)fraction
ofColor:(NSColor *)color

Creates and returns an NSColor in NSCalibratedRGBColorSpace whose component values are a weighted sum of the receiver's and color's. The method converts color and a copy of the receiver to RGB, and then sets each component of the returned color to fraction of color's value plus 1 - fraction of the receiver's. Returns nil if the colors can't be converted to NSCalibratedRGBColorSpace.


blueComponent

- (float)blueComponent

Returns the receiver's blue component. Raises an exception if the receiver isn't an RGB color.

See also: - getRed:green:blue:alpha:


brightnessComponent

- (float)brightnessComponent

Returns the brightness component of the HSB color equivalent to the receiver. Raises an exception if the receiver isn't an RGB color.

See also: - getHue:saturation:brightness:alpha:


catalogNameComponent

- (NSString *)catalogNameComponent

Returns the name of the catalog containing the receiver's name, or raises an exception if the receiver's color space isn't NSNamedColorSpace.

See also: + colorWithCatalogName:colorName:, - colorNameComponent, - localizedCatalogNameComponent


colorNameComponent

- (NSString *)colorNameComponent

Returns the receiver's name, or raises an exception if the receiver's color space isn't NSNamedColorSpace.

See also: + colorWithCatalogName:colorName:, - catalogNameComponent, - localizedCatalogNameComponent


colorSpaceName

- (NSString *)colorSpaceName

Returns the name of the receiver's color space. This method should be implemented in subclasses of NSColor.

See also: - colorUsingColorSpaceName:, - colorUsingColorSpaceName:device:


colorUsingColorSpaceName:

- (NSColor *)colorUsingColorSpaceName:(NSString *)colorSpace

Creates and returns an NSColor whose color is the same as the receiver's, except that the new NSColor is in the color space named colorSpace. If colorSpace is nil, the most appropriate color space is used.

Returns nil if the specified conversion cannot be done.

See also: - colorSpaceName


colorUsingColorSpaceName:device:

- (NSColor *)colorUsingColorSpaceName:(NSString *)colorSpace
device:(NSDictionary *)deviceDescription

Creates and returns an NSColor whose color is the same as the receiver's, except that the new NSColor is in the color space named colorSpace and is specific to the device described by deviceDescription. Device descriptions can be obtained from windows, screens, and printers with the deviceDescription method. If colorSpace is nil, the most appropriate color space is used.

If deviceDescription is nil, the current device (as obtained from the currently lockFocus'ed view's window or, if printing, the current printer) is used.

Returns nil if the specified conversion cannot be done.

See also: - colorSpaceName, - colorUsingColorSpaceName:


colorWithAlphaComponent:

- (NSColor *)colorWithAlphaComponent:(float)alpha

Creates and returns an NSColor that has the same color space and component values as the receiver, except that its alpha component is alpha. If the receiver's color space doesn't include an alpha component, the receiver is returned. A subclass which has explicit opacity components should override this method to return a color with the specified alpha.

See also: - alphaComponent, - blendedColorWithFraction:ofColor:


cyanComponent

- (float)cyanComponent

Returns the receiver's cyan component. Raises an exception if the receiver isn't a CMYK color.

See also: - getCyan:magenta:yellow:black:alpha:


drawSwatchInRect:

- (void)drawSwatchInRect:(NSRect)rect

Draws the current color in the rectangle rect. Subclasses adorn the rectangle in some manner to indicate the type of color. This method is invoked by color wells, swatches, and other user-interface objects that need to display colors.


getCyan:magenta:yellow:black:alpha:

- (void)getCyan:(float *)cyan
magenta:(float *)magenta
yellow:(float *)yellow
black:(float *)black
alpha:(float *)alpha

Returns the receiver's CMYK and alpha values in the respective arguments. If NULL is passed in as an argument, the method doesn't set that value. Raises an exception if the receiver isn't a CMYK color.

See also: - alphaComponent, - blackComponent, - cyanComponent, - magentaComponent, - yellowComponent


getHue:saturation:brightness:alpha:

- (void)getHue:(float *)hue
saturation:(float *)saturation
brightness:(float *)brightness
alpha:(float *)alpha

Returns the receiver's HSB and alpha values in the respective arguments. If NULL is passed in as an argument, the method doesn't set that value. Raises an exception if the receiver isn't an RGB color.

See also: - alphaComponent, - brightnessComponent, - hueComponent, - saturationComponent


getRed:green:blue:alpha:

- (void)getRed:(float *)red
green:(float *)green
blue:(float *)blue
alpha:(float *)alpha

Returns the receiver's RGB and alpha values in the respective arguments. If NULL is passed in as an argument, the method doesn't set that value. Raises an exception if the receiver isn't an RGB color.

See also: - alphaComponent, - blueComponent, - greenComponent, - redComponent


getWhite:alpha:

- (void)getWhite:(float *)white
alpha:(float *)alpha

Returns the receiver's grayscale and alpha values in the respective arguments. If NULL is passed in as an argument, the method doesn't set that value. Raises an exception if the receiver isn't a grayscale color.

See also: - alphaComponent, - whiteComponent


greenComponent

- (float)greenComponent

Returns the receiver's green component. Raises an exception if the receiver isn't an RGB color.

See also: - getRed:green:blue:alpha:


highlightWithLevel:

- (NSColor *)highlightWithLevel:(float)highlightLevel

Returns an NSColor in NSCalibratedRGBColorSpace that represents a blend between the receiver and the highlight color-that is, the NSColor returned by highlightColor. The highlight color's contribution to the blend depends on highlightLevel, which should be a number between 0.0 and 1.0. (A highlightLevel below 0.0 is interpreted as 0.0; a highlightLevel above 1.0 is interpreted as 1.0.)

Returns nil if the colors can't be converted to NSCalibratedRGBColorSpace. Invoke this method when you want to brighten the receiving NSColor for use in highlights.

See also: - shadowWithLevel:


hueComponent

- (float)hueComponent

Returns the hue component of the HSB color equivalent to the receiver. Raises an exception if the receiver isn't an RGB color.

See also: - getHue:saturation:brightness:alpha:


localizedCatalogNameComponent

- (NSString *)localizedCatalogNameComponent

Like catalogNameComponent, but returns a localized string. This string may be displayed in user-interface items like color pickers.

See also: + colorWithCatalogName:colorName:, - colorNameComponent


localizedColorNameComponent

- (NSString *)localizedColorNameComponent

Like colorNameComponent, but returns a localized string. This string may be displayed in user-interface items like color pickers.

See also: + colorWithCatalogName:colorName:, - catalogNameComponent, - colorNameComponent, - localizedCatalogNameComponent


magentaComponent

- (float)magentaComponent

Returns the receiver's magenta component. Raises an exception if the receiver isn't a CMYK color.

See also: - getCyan:magenta:yellow:black:alpha:


redComponent

- (float)redComponent

Returns the receiver's red component. Raises an exception if the receiver isn't an RGB color.

See also: - getRed:green:blue:alpha:


saturationComponent

- (float)saturationComponent

Returns the saturation component of the HSB color equivalent to the receiver. Raises an exception if the receiver isn't an RGB color.

See also: - getHue:saturation:brightness:alpha:


set

- (void)set

Sets the color of subsequent PostScript drawing to the color that the receiver represents. If the application is drawing to the screen rather than printing, this method also sets the current drawing context's alpha value to the value returned by alphaComponent; if the color doesn't know about alpha, it's set to 1.0. This method should be implemented in subclasses.


shadowWithLevel:

- (NSColor *)shadowWithLevel:(float)shadowLevel

Returns an NSColor in NSCalibratedRGBColorSpace that represents a blend between the receiver and the shadow color-that is, the NSColor returned by shadowColor. The shadow color's contribution to the blend depends on shadowLevel, which should be a number between 0.0 and 1.0. (A shadowLevel below 0.0 is interpreted as 0.0; a shadowLevel above 1.0 is interpreted as 1.0.)

Returns nil if the colors can't be converted to NSCalibratedRGBColorSpace. Invoke this method when you want to darken the receiving NSColor for use in shadows.

See also: - highlightWithLevel:


whiteComponent

- (float)whiteComponent

Returns the receiver's white component. Raises an exception if the receiver isn't a grayscale color.

See also: - getWhite:alpha:


writeToPasteboard:

- (void)writeToPasteboard:(NSPasteboard *)pasteBoard

Writes the receiver's data to the pasteboard, unless the pasteboard doesn't support color data (in which case the method does nothing).

See also: + colorFromPasteboard:


yellowComponent

- (float)yellowComponent

Returns the receiver's yellow component. Raises an exception if the receiver isn't a CMYK color.

See also: - getCyan:magenta:yellow:black:alpha:


Notifications

NSSystemColorsDidChangeNotification

Sent when the system colors have been changed (such as through a system control panel interface).

This notification contains no notification object and no userInfo dictionary.



[TOC] [Prev] [Next] [Bottom]

Copyright © 1997, Apple Computer, Inc. All rights reserved.