DrawKit
Vector and illustration framework for Mac OS X
Instance Methods | Class Methods | List of all members
NSColor(DKAdditions) Category Reference

Instance Methods

(NSColor *) - colorWithHSBAverageFrom:
 Returns a colour by averaging the receiver with <color> in hsb space. More...
 
(NSColor *) - colorWithHSBBlendFrom:blendingAmounts:
 Returns a colour by blending the receiver with <color> in hsb space. More...
 
(NSColor *) - colorWithHueAndSaturationFrom:
 Returns a copy ofthe receiver but substituting the hue and saturation from the given colour. More...
 
(NSColor *) - colorWithHueFrom:
 Returns a copy ofthe receiver but substituting the hue from the given colour. More...
 
(NSColor *) - colorWithLuminosity
 Returns a grey rgb colour having the same luminosity as the receiver. More...
 
(NSColor *) - colorWithRGBAverageFrom:
 Returns a colour by averaging the receiver with <color> in rgb space. More...
 
(NSColor *) - colorWithRGBBlendFrom:blendingAmounts:
 Returns a colour by blending the receiver with <color> in rgb space. More...
 
(NSColor *) - contrastingColor
 Returns black or white to give best contrast with the receiver's colour. More...
 
(NSColor *) - darkerColorWithLevel:
 Returns a darker colour based on a blend between the receiver and black. More...
 
(NSString *) - hexString
 Returns a standard web-formatted hexadecimal representation of the receiver's colour. More...
 
(NSColor *) - interpolatedColorToColor:atValue:
 Returns a colour by interpolating between the receiver and a second colour. More...
 
(NSColor *) - invertedColor
 Returns the colour with each colour component subtracted from 1. More...
 
(NSColor *) - lighterColorWithLevel:
 Returns a lighter colour based on a blend between the receiver and white. More...
 
(CGFloat- luminosity
 Returns the luminosity value of the receiver. More...
 
(CGColorRef- newQuartzColor
 Returns a quartz CGColorRef corresponding to the receiver's colours. More...
 

Class Methods

(NSColor *) + colorByInterpolatingFrom:to:atValue:
 Returns a colour by interpolating between two colours. More...
 
(NSColor *) + colorWithHexString:
 Returns an RGB colour corresponding to the standard-formatted HTML hexadecimal colour string. More...
 
(NSColor *) + colorWithWavelength:
 Returns an RGB colour approximating the wavelength. More...
 
(NSColor *) + contrastingColor:
 
(NSColor *) + rgbBlack
 Returns the colour black as an RGB Color. More...
 
(NSColor *) + rgbGrey:
 Returns a grey RGB colour. More...
 
(NSColor *) + rgbGrey:withAlpha:
 Returns a grey RGB colour. More...
 
(NSColor *) + rgbGreyWithLuminosityFrom:withAlpha:
 Returns a grey RGB colour with the same perceived brightness as the source colour. More...
 
(NSColor *) + rgbWhite
 Returns the colour white as an RGB Color. More...
 
(NSColor *) + veryLightGrey
 A very light grey colour. More...
 

Detailed Description

Author
Contributions from the community; see CONTRIBUTORS.md
Date
2005-2015

Method Documentation

+ (NSColor*) colorByInterpolatingFrom: (NSColor *)  startColor
to: (NSColor *)  endColor
atValue: (CGFloat interpValue 

Returns a colour by interpolating between two colours.

Parameters
startColora colour
endColora second colour
interpValuea value between 0 and 1
Returns
a colour that is intermediate between startColor and endColor, in RGB space
+ (NSColor*) colorWithHexString: (NSString *)  hex

Returns an RGB colour corresponding to the standard-formatted HTML hexadecimal colour string.

Parameters
hexa string formatted '#RRGGBB'
Returns
rgb equivalent colour
- (NSColor*) colorWithHSBAverageFrom: (NSColor *)  color

Returns a colour by averaging the receiver with <color> in hsb space.

Input colours must be in RGB colour space

Parameters
coloraverage with this colour
Returns
average of the two colours
- (NSColor*) colorWithHSBBlendFrom: (NSColor *)  color
blendingAmounts: (CGFloat[])  blends 

Returns a colour by blending the receiver with <color> in hsb space.

Parameters
colorblend with this colour
blendingAmountsan array of four values, each 0..1, specifies how components from each colour are
Returns
blend of the two colours
- (NSColor*) colorWithHueAndSaturationFrom: (NSColor *)  color

Returns a copy ofthe receiver but substituting the hue and saturation from the given colour.

Input colours must be in RGB colour space

Parameters
colordonates hue and saturation
Returns
a colour with the hue, sat of <color> but the receiver's brightness
- (NSColor*) colorWithHueFrom: (NSColor *)  color

Returns a copy ofthe receiver but substituting the hue from the given colour.

If the receiver is black or white or otherwise fully unsaturated, colourization may not produce visible results. Input colours must be in RGB colour space

Parameters
colordonates hue
Returns
a colour with the hue of <color> but the receiver's saturation and brightness
- (NSColor*) colorWithLuminosity

Returns a grey rgb colour having the same luminosity as the receiver.

Returns
a grey colour having the same luminosity
- (NSColor*) colorWithRGBAverageFrom: (NSColor *)  color

Returns a colour by averaging the receiver with <color> in rgb space.

Input colours must be in RGB colour space

Parameters
coloraverage with this colour
Returns
average of the two colours
- (NSColor*) colorWithRGBBlendFrom: (NSColor *)  color
blendingAmounts: (CGFloat[])  blends 

Returns a colour by blending the receiver with <color> in rgb space.

Parameters
colorblend with this colour
blendingAmountsan array of four values, each 0..1, specifies how components from each colour are
Returns
blend of the two colours
+ (NSColor*) colorWithWavelength: (CGFloat lambda

Returns an RGB colour approximating the wavelength.

Lambda range outside 380 to 780 (nm) returns black

Parameters
lambdathe wavelength in nanometres
Returns
approximate rgb equivalent colour
- (NSColor*) contrastingColor

Returns black or white to give best contrast with the receiver's colour.

Returns
black or white
+ (NSColor*) contrastingColor: (NSColor *)  color
- (NSColor*) darkerColorWithLevel: (CGFloat amount

Returns a darker colour based on a blend between the receiver and black.

The alpha value is unchanged

Parameters
amounta value 0.0..1.0, 0 returns the original colour, 1 returns black.
Returns
a darkened version of the receiver
- (NSString*) hexString

Returns a standard web-formatted hexadecimal representation of the receiver's colour.

Format is '#000000' (black) to '#FFFFFF' (white)

Returns
hexadecimal string
- (NSColor*) interpolatedColorToColor: (NSColor *)  secondColor
atValue: (CGFloat interpValue 

Returns a colour by interpolating between the receiver and a second colour.

Parameters
secondColouranother colour
interpValuea value between 0 and 1
Returns
a colour that is intermediate between the receiver and secondColor, in RGB space
- (NSColor*) invertedColor

Returns the colour with each colour component subtracted from 1.

The alpha value is not inverted

Returns
the "inverse" of the receiver
- (NSColor*) lighterColorWithLevel: (CGFloat amount

Returns a lighter colour based on a blend between the receiver and white.

The alpha value is unchanged

Parameters
amounta value 0.0..1.0, 0 returns the original colour, 1 returns white.
Returns
a lightened version of the receiver
- (CGFloat) luminosity

Returns the luminosity value of the receiver.

Luminosity of a colour is both subjective and dependent on the display characteristics of particular monitors, etc. A frequently used formula can be traced to experiments done by the NTSC television standards committee in 1953, which was based on tube phosphors in common use at that time. A more modern formula is applicable for LCD monitors. This method uses the NTSC formula if NTSC_1953_STANDARD is defined, otherwise the modern one.

Returns
a value 0..1 that is the colour's luminosity
- (CGColorRef) newQuartzColor

Returns a quartz CGColorRef corresponding to the receiver's colours.

Returned colour uses the generic RGB colour space, regardless of the receivers colourspace. Caller is responsible for releasing the colour ref when done.

Returns
CGColorRef
+ (NSColor*) rgbBlack

Returns the colour black as an RGB Color.

Uses the RGB Color space, not the greyscale Colorspace you get with NSColor's blackColor method.

Returns
the colour black
+ (NSColor*) rgbGrey: (CGFloat grayscale

Returns a grey RGB colour.

Uses the RGB Color space, not the greyscale Colorspace you get with NSColor's grey method.

Parameters
grayscale0 to 1.0
Returns
a grey colour
+ (NSColor*) rgbGrey: (CGFloat grayscale
withAlpha: (CGFloat alpha 

Returns a grey RGB colour.

Uses the RGB Color space, not the greyscale Colorspace you get with NSColor's grey method.

Parameters
grayscale0 to 1.0
alpha0 to 1.0
Returns
a grey colour with variable opacity
+ (NSColor*) rgbGreyWithLuminosityFrom: (NSColor *)  colour
withAlpha: (CGFloat alpha 

Returns a grey RGB colour with the same perceived brightness as the source colour.

Parameters
colourany colour
alpha0 to 1.0
Returns
a grey colour in rgb space of equivalent luminosity
+ (NSColor*) rgbWhite

Returns the colour white as an RGB Color.

Uses the RGB Color space, not the greyscale Colorspace you get with NSColor's whiteColor method.

Returns
the colour white
+ (NSColor*) veryLightGrey

A very light grey colour.

Returns
a very light grey colour in rgb space