API 0.9.5
CPColor Class Reference

#import <CPColor.h>

Inheritance diagram for CPColor:

List of all members.

Instance Methods

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

Class Methods

(CPColor+ alternateSelectedControlColor
(CPColor+ blackColor
(CPColor+ blueColor
(CPColor+ brownColor
(CPColor+ clearColor
(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+ 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

Returns the alpha component of this color.

Definition at line 531 of file CPColor.j.

+ (CPColor) alternateSelectedControlColor

Definition at line 430 of file CPColor.j.

+ (CPColor) blackColor

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

Definition at line 255 of file CPColor.j.

+ (CPColor) blueColor

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

Definition at line 266 of file CPColor.j.

- (float) blueComponent

Returns the blue component of this color.

Definition at line 539 of file CPColor.j.

+ (CPColor) brownColor

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

Definition at line 354 of file CPColor.j.

+ (CPColor) clearColor

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

Definition at line 422 of file CPColor.j.

- (CPColor) colorWithAlphaComponent: (float)  anAlphaComponent

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 583 of file CPColor.j.

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

Creates a color in the RGB color space, 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 164 of file CPColor.j.

+ (CPColor) colorWithCalibratedWhite: (float)  white
alpha: (float)  alpha 
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 195 of file CPColor.j.

+ (CPColor) colorWithCSSString: (CPString aString

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 456 of file CPColor.j.

+ (CPColor) colorWithHexString: (string)  hex

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 246 of file CPColor.j.

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

Creates a new color in HSB space.

Parameters:
huethe hue value
saturationthe saturation value
brightnessthe brightness value
Returns:
the initialized color

Definition at line 209 of file CPColor.j.

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

Definition at line 214 of file CPColor.j.

+ (CPColor) colorWithPatternImage: (CPImage anImage

Creates a color using a tile pattern with anImage

Parameters:
theimage to tile
Returns:
a tiled image color object

Definition at line 445 of file CPColor.j.

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

Creates a color in the RGB color space, 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 144 of file CPColor.j.

+ (CPColor) colorWithWhite: (float)  white
alpha: (float)  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 179 of file CPColor.j.

- (CPArray) components

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 571 of file CPColor.j.

- (CPString) cssString

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 655 of file CPColor.j.

+ (CPColor) cyanColor

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

Definition at line 365 of file CPColor.j.

+ (CPColor) darkGrayColor

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

Definition at line 277 of file CPColor.j.

- (CPString) description

Definition at line 691 of file CPColor.j.

- (void) encodeWithCoder: (CPCoder aCoder

Archives this color into a coder.

Parameters:
aCoderthe coder into which the color will be archived.

Definition at line 790 of file CPColor.j.

+ (CPColor) grayColor

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

Definition at line 288 of file CPColor.j.

+ (CPColor) greenColor

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

Definition at line 299 of file CPColor.j.

- (float) greenComponent

Returns the green component of this color.

Definition at line 547 of file CPColor.j.

- (CPString) hexString

Returns a 6 character long hex string of this color.

Definition at line 663 of file CPColor.j.

- (CPArray) hsbComponents

Returns an array with the HSB values for this color. The index values are ordered as:

Index   Component
0       Hue
1       Saturation
2       Brightness

Definition at line 602 of file CPColor.j.

- (id) initWithCoder: (CPCoder aCoder

Initializes this color from the data archived in a coder.

Parameters:
aCoderthe coder from which the color will be loaded

Definition at line 778 of file CPColor.j.

- (BOOL) isEqual: (CPColor aColor

Definition at line 668 of file CPColor.j.

+ (CPColor) lightGrayColor

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

Definition at line 310 of file CPColor.j.

+ (CPColor) magentaColor

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

Definition at line 376 of file CPColor.j.

+ (CPColor) orangeColor

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

Definition at line 387 of file CPColor.j.

- (CPImage) patternImage

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

Definition at line 523 of file CPColor.j.

+ (CPColor) purpleColor

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

Definition at line 398 of file CPColor.j.

+ (CPColor) randomColor

Definition at line 760 of file CPColor.j.

+ (CPColor) redColor

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

Definition at line 321 of file CPColor.j.

- (float) redComponent

Return the red component of this color.

Definition at line 555 of file CPColor.j.

+ (CPColor) secondarySelectedControlColor

Definition at line 435 of file CPColor.j.

- (void) set

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

Definition at line 732 of file CPColor.j.

- (void) setFill

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

Definition at line 741 of file CPColor.j.

- (void) setStroke

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

Definition at line 750 of file CPColor.j.

+ (CPColor) shadowColor

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

Definition at line 410 of file CPColor.j.

+ (CPColor) whiteColor

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

Definition at line 332 of file CPColor.j.

+ (CPColor) yellowColor

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

Definition at line 343 of file CPColor.j.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines