API  0.9.7
 All Classes Files Functions Variables Macros Groups Pages
CPColor Class Reference

#import <CPColor.h>

+ Inheritance diagram for CPColor:

Instance Methods

(float) - alphaComponent
 
(float) - blueComponent
 
(float) - brightnessComponent
 
(CPColor- colorUsingColorSpaceName:
 
(CPColor- colorWithAlphaComponent:
 
(CPArray) - components
 
(CPString- cssString
 
(CPString- description
 
(void) - encodeWithCoder:
 
(float) - greenComponent
 
(CPString- hexString
 
(CPArray) - hsbComponents
 
(float) - hueComponent
 
(id) - initWithCoder:
 
(BOOL) - isEqual:
 
(CPImage- patternImage
 
(float) - redComponent
 
(float) - saturationComponent
 
(void) - set
 
(void) - setFill
 
(void) - setStroke
 

Class Methods

(CPColor+ alternateSelectedControlColor
 
(CPColor+ blackColor
 
(CPColor+ blueColor
 
(CPColor+ brownColor
 
(CPColor+ clearColor
 
(CPColor+ colorWithCalibratedHue:saturation:brightness:alpha:
 
(CPColor+ colorWithCalibratedRed:green:blue:alpha:
 
(CPColor+ colorWithCalibratedWhite:alpha:
 
(CPColor+ colorWithCSSString:
 
(CPColor+ colorWithHexString:
 
(CPColor+ colorWithHue:saturation:brightness:
 
(CPColor+ colorWithHue:saturation:brightness:alpha:
 
(CPColor+ colorWithPatternImage:
 
(CPColor+ colorWithRed:green:blue:alpha:
 
(CPColor+ colorWithSRGBRed:green:blue:alpha:
 
(CPColor+ colorWithWhite:alpha:
 
(CPColor+ cyanColor
 
(CPColor+ darkGrayColor
 
(CPColor+ grayColor
 
(CPColor+ greenColor
 
(CPColor+ lightGrayColor
 
(CPColor+ magentaColor
 
(CPColor+ orangeColor
 
(CPColor+ purpleColor
 
(CPColor+ randomColor
 
(CPColor+ redColor
 
(CPColor+ secondarySelectedControlColor
 
(CPColor+ shadowColor
 
(CPColor+ whiteColor
 
(CPColor+ yellowColor
 

Detailed Description

CPColor can be used to represent color in an RGB or HSB model with an optional transparency value.

It also provides some class helper methods that returns instances of commonly used colors.

Definition at line 2 of file CPColor.h.

Method Documentation

- (float) alphaComponent
implementation

Returns the alpha component of this color.

Definition at line 542 of file CPColor.j.

+ (CPColor) alternateSelectedControlColor
implementation

Definition at line 434 of file CPColor.j.

+ (CPColor) blackColor
implementation

Returns a black color object. (RGBA=[0.0, 0.0, 0.0, 1.0])

Definition at line 259 of file CPColor.j.

+ (CPColor) blueColor
implementation

Returns a blue color object. (RGBA=[0.0, 0.0, 1.0, 1.0])

Definition at line 270 of file CPColor.j.

- (float) blueComponent
implementation

Returns the blue component of this color.

Definition at line 550 of file CPColor.j.

- (float) brightnessComponent
implementation

Returns the brightness component, the B in HSB, of the receiver.

Definition at line 687 of file CPColor.j.

+ (CPColor) brownColor
implementation

Returns a brown color object (RGBA=[0.6, 0.4, 0.2, 1.0])

Definition at line 358 of file CPColor.j.

+ (CPColor) clearColor
implementation

Returns a clear color (RGBA=[0.0, 0.0, 0.0, 0.0])

Definition at line 426 of file CPColor.j.

- (CPColor) colorUsingColorSpaceName: (id)  aColorSpaceName
implementation

Returns the receiver. This method is a placeholder that does nothing but may be implemented in the future.

Definition at line 606 of file CPColor.j.

- (CPColor) colorWithAlphaComponent: (float)  anAlphaComponent
implementation

Returns a new color with the same RGB as the receiver but a new alpha component.

Parameters
anAlphaComponentthe alpha component for the new color
Returns
a new color object

Definition at line 594 of file CPColor.j.

+ (CPColor) colorWithCalibratedHue: (float)  hue
saturation: (float)  saturation
brightness: (float)  brightness
alpha: (float)  alpha 
implementation

Calibrated colors are not supported in Cappuccino.

This method has the same result as [CPColor colorWithHue:saturation:brightness:alpha:].

Definition at line 176 of file CPColor.j.

+ (CPColor) colorWithCalibratedRed: (float)  red
green: (float)  green
blue: (float)  blue
alpha: (float)  alpha 
implementation
Deprecated:
in favor of colorWithRed:green:blue:alpha:

Creates a color in the RGB colorspace, with an alpha value. Each component should be between the range of 0.0 to 1.0. For the alpha component, a value of 1.0 is opaque, and 0.0 means completely transparent.

Parameters
redthe red component of the color
greenthe green component of the color
bluethe blue component of the color
alphathe alpha component
Returns
a color initialized to the values specified

Definition at line 117 of file CPColor.j.

+ (CPColor) colorWithCalibratedWhite: (float)  white
alpha: (float)  alpha 
implementation
Deprecated:
in favor of colorWithWhite:alpha:

Creates a new color object with white for the RGB components. For the alpha component, a value of 1.0 is opaque, and 0.0 means completely transparent.

Parameters
whitea float between 0.0 and 1.0
alphathe alpha component between 0.0 and 1.0
Returns
a color initialized to the values specified

Definition at line 148 of file CPColor.j.

+ (CPColor) colorWithCSSString: (CPString aString
implementation

Creates a CPColor from a valid CSS RGB string. Example, "rgb(32,64,129)".

Parameters
aStringa CSS color string
Returns
a color initialized to the value in the css string

Definition at line 460 of file CPColor.j.

+ (CPColor) colorWithHexString: (string)  hex
implementation

Creates an RGB color from a hexadecimal string. For example, the a string of "FFFFFF" would return a white CPColor. "FF0000" would return a pure red, "00FF00" would return a pure blue, and "0000FF" would return a pure green.

Parameters
hexa 6 character long string of hex
Returns
an initialized RGB color

Definition at line 239 of file CPColor.j.

+ (CPColor) colorWithHue: (float)  hue
saturation: (float)  saturation
brightness: (float)  brightness 
implementation

Creates a new color based on the given HSB components.

Note: earlier versions of this method took a hue component as degrees between 0-360, and saturation and brightness components as percent between 0-100. This method has now been corrected to take all components in the 0-1 range as in Cocoa.

Parameters
huethe hue component (0.0-1.0)
saturationthe saturation component (0.0-1.0)
brightnessthe brightness component (0.0-1.0)
Returns
the initialized color

Definition at line 166 of file CPColor.j.

+ (CPColor) colorWithHue: (float)  hue
saturation: (float)  saturation
brightness: (float)  brightness
alpha: (float)  alpha 
implementation

Creates a new color based on the given HSB components.

Note: earlier versions of this method took a hue component as degrees between 0-360, and saturation and brightness components as percent between 0-100. This method has now been corrected to take all components in the 0-1 range as in Cocoa.

Parameters
huethe hue component (0.0-1.0)
saturationthe saturation component (0.0-1.0)
brightnessthe brightness component (0.0-1.0)
alphathe opacity component (0.0-1.0)
Returns
the initialized color

Definition at line 195 of file CPColor.j.

+ (CPColor) colorWithPatternImage: (CPImage anImage
implementation

Creates a color using a tile pattern with anImage

Parameters
theimage to tile
Returns
a tiled image color object

Definition at line 449 of file CPColor.j.

+ (CPColor) colorWithRed: (float)  red
green: (float)  green
blue: (float)  blue
alpha: (float)  alpha 
implementation

Creates a color in the RGB colorspace, with an alpha value. Each component should be between the range of 0.0 to 1.0. For the alpha component, a value of 1.0 is opaque, and 0.0 means completely transparent.

Parameters
redthe red component of the color
greenthe green component of the color
bluethe blue component of the color
alphathe alpha component
Returns
a color initialized to the values specified

Definition at line 97 of file CPColor.j.

+ (CPColor) colorWithSRGBRed: (float)  red
green: (float)  green
blue: (float)  blue
alpha: (float)  alpha 
implementation

Creates a color in the sRGB colorspace with the given components and alpha values. Values below 0.0 are treated as 0.0 and values above 1.0 are treated as 1.0.

Definition at line 249 of file CPColor.j.

+ (CPColor) colorWithWhite: (float)  white
alpha: (float)  alpha 
implementation

Creates a new color object with white for the RGB components. For the alpha component, a value of 1.0 is opaque, and 0.0 means completely transparent.

Parameters
whitea float between 0.0 and 1.0
alphathe alpha component between 0.0 and 1.0
Returns
a color initialized to the values specified

Definition at line 132 of file CPColor.j.

- (CPArray) components
implementation
Returns the RGBA components of this color in an array.
The index values are ordered as:
Index   Component
0       Red
1       Green
2       Blue
3       Alpha

Definition at line 582 of file CPColor.j.

- (CPString) cssString
implementation
Returns the CSS representation of this color. The color will
be in one of the following forms:
rgb(22,44,88)
rgba(22,44,88,0.5)  // if there is an alpha
url("data:image/png;base64,BASE64ENCODEDDATA")  // if there is a pattern image

Definition at line 701 of file CPColor.j.

+ (CPColor) cyanColor
implementation

Returns a cyan color object (RGBA=[0.0, 1.0, 1.0, 1.0])

Definition at line 369 of file CPColor.j.

+ (CPColor) darkGrayColor
implementation

Returns a dark gray color object. (RGBA=[0.33 ,0.33, 0.33, 1.0])

Definition at line 281 of file CPColor.j.

- (CPString) description
implementation

Definition at line 737 of file CPColor.j.

- (void) encodeWithCoder: (CPCoder aCoder
implementation

Archives this color into a coder.

Parameters
aCoderthe coder into which the color will be archived.

Provided by category CPColor(CPCoding).

Definition at line 836 of file CPColor.j.

+ (CPColor) grayColor
implementation

Returns a gray color object. (RGBA=[0.5, 0.5, 0.5, 1.0])

Definition at line 292 of file CPColor.j.

+ (CPColor) greenColor
implementation

Returns a green color object. (RGBA=[0.0, 1.0, 0.0, 1.0])

Definition at line 303 of file CPColor.j.

- (float) greenComponent
implementation

Returns the green component of this color.

Definition at line 558 of file CPColor.j.

- (CPString) hexString
implementation

Returns a 6 character long hex string of this color.

Definition at line 709 of file CPColor.j.

- (CPArray) hsbComponents
implementation
Returns an array with the HSB values for this color.

The values are expressed as fractions between 0.0-1.0.

The index values are ordered as:
Index   Component
0       Hue
1       Saturation
2       Brightness

Definition at line 624 of file CPColor.j.

- (float) hueComponent
implementation

Returns the hue component, the H in HSB, of the receiver.

Definition at line 671 of file CPColor.j.

- (id) initWithCoder: (CPCoder aCoder
implementation

Initializes this color from the data archived in a coder.

Parameters
aCoderthe coder from which the color will be loaded

Provided by category CPColor(CPCoding).

Definition at line 824 of file CPColor.j.

- (BOOL) isEqual: (CPColor aColor
implementation

Definition at line 714 of file CPColor.j.

+ (CPColor) lightGrayColor
implementation

Returns a light gray color object (RGBA=[0.66, 0.66, 0.66, 1.0])

Definition at line 314 of file CPColor.j.

+ (CPColor) magentaColor
implementation

Returns a magenta color object (RGBA=[1.0, 0.0, 1.0, 1.0])

Definition at line 380 of file CPColor.j.

+ (CPColor) orangeColor
implementation

Returns a orange color object (RGBA=[1.0, 0.5, 0.0, 1.0])

Definition at line 391 of file CPColor.j.

- (CPImage) patternImage
implementation

Returns the image being used as the pattern for the tile in this color.

Definition at line 534 of file CPColor.j.

+ (CPColor) purpleColor
implementation

Returns a purple color object (RGBA=[0.5, 0.0, 0.5, 1.0])

Definition at line 402 of file CPColor.j.

+ (CPColor) randomColor
implementation

Provided by category CPColor(Debugging).

Definition at line 806 of file CPColor.j.

+ (CPColor) redColor
implementation

Returns a red color object (RGBA=[1.0, 0.0, 0.0, 1.0])

Definition at line 325 of file CPColor.j.

- (float) redComponent
implementation

Return the red component of this color.

Definition at line 566 of file CPColor.j.

- (float) saturationComponent
implementation

Returns the saturation component, the S in HSB, of the receiver.

Definition at line 679 of file CPColor.j.

+ (CPColor) secondarySelectedControlColor
implementation

Definition at line 439 of file CPColor.j.

- (void) set
implementation

Set's the receiver to be the fill and stroke color in the current graphics context

Provided by category CPColor(CoreGraphicsExtensions).

Definition at line 778 of file CPColor.j.

- (void) setFill
implementation

Set's the receiver to be the fill color in the current graphics context

Provided by category CPColor(CoreGraphicsExtensions).

Definition at line 787 of file CPColor.j.

- (void) setStroke
implementation

Set's the receiver to be the stroke color in the current graphics context

Provided by category CPColor(CoreGraphicsExtensions).

Definition at line 796 of file CPColor.j.

+ (CPColor) shadowColor
implementation

Returns a shadow looking color (RGBA=[0.0, 0.0, 0.0, 0.33])

Definition at line 414 of file CPColor.j.

+ (CPColor) whiteColor
implementation

Returns a white color object (RGBA=[1.0, 1.0, 1.0, 1.0])

Definition at line 336 of file CPColor.j.

+ (CPColor) yellowColor
implementation

Returns a yellow color object (RGBA=[1.0, 1.0, 0.0, 1.0])

Definition at line 347 of file CPColor.j.


The documentation for this class was generated from the following files: