API  0.9.10
CPColor Class Reference

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+ checkerBoardColor
 
(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
 
(CPString+ defaultThemeClass
 
(CPColor+ grayColor
 
(CPColor+ greenColor
 
(CPColor+ lightGrayColor
 
(CPColor+ magentaColor
 
(CPColor+ orangeColor
 
(CPColor+ purpleColor
 
(CPColor+ randomColor
 
(CPColor+ redColor
 
(CPColor+ secondarySelectedControlColor
 
(CPColor+ selectedTextBackgroundColor
 
(CPColor+ shadowColor
 
(CPDictionary+ themeAttributes
 
(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 77 of file CPColor.j.

Method Documentation

◆ alphaComponent()

- (float) alphaComponent
implementation

Returns the alpha component of this color.

Definition at line 596 of file CPColor.j.

◆ alternateSelectedControlColor()

+ (CPColor) alternateSelectedControlColor
implementation

Definition at line 466 of file CPColor.j.

◆ blackColor()

+ (CPColor) blackColor
implementation

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

Definition at line 283 of file CPColor.j.

◆ blueColor()

+ (CPColor) blueColor
implementation

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

Definition at line 294 of file CPColor.j.

◆ blueComponent()

- (float) blueComponent
implementation

Returns the blue component of this color.

Definition at line 604 of file CPColor.j.

◆ brightnessComponent()

- (float) brightnessComponent
implementation

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

Definition at line 741 of file CPColor.j.

◆ brownColor()

+ (CPColor) brownColor
implementation

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

Definition at line 382 of file CPColor.j.

◆ checkerBoardColor()

+ (CPColor) checkerBoardColor
implementation

Provided by category CPColor(Debugging).

Definition at line 865 of file CPColor.j.

◆ clearColor()

+ (CPColor) clearColor
implementation

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

Definition at line 450 of file CPColor.j.

◆ colorUsingColorSpaceName:()

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

◆ colorWithAlphaComponent:()

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

◆ colorWithCalibratedHue:saturation:brightness:alpha:()

+ (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 200 of file CPColor.j.

◆ colorWithCalibratedRed:green:blue:alpha:()

+ (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 141 of file CPColor.j.

◆ colorWithCalibratedWhite:alpha:()

+ (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 172 of file CPColor.j.

◆ colorWithCSSString:()

+ (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 492 of file CPColor.j.

◆ colorWithHexString:()

+ (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 263 of file CPColor.j.

◆ colorWithHue:saturation:brightness:()

+ (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 190 of file CPColor.j.

◆ colorWithHue:saturation:brightness:alpha:()

+ (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 219 of file CPColor.j.

◆ colorWithPatternImage:()

+ (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 481 of file CPColor.j.

◆ colorWithRed:green:blue:alpha:()

+ (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 121 of file CPColor.j.

◆ colorWithSRGBRed:green:blue:alpha:()

+ (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 273 of file CPColor.j.

◆ colorWithWhite:alpha:()

+ (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 156 of file CPColor.j.

◆ components()

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

◆ cssString()

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

◆ cyanColor()

+ (CPColor) cyanColor
implementation

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

Definition at line 393 of file CPColor.j.

◆ darkGrayColor()

+ (CPColor) darkGrayColor
implementation

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

Definition at line 305 of file CPColor.j.

◆ defaultThemeClass()

+ (CPString) defaultThemeClass
implementation

Definition at line 89 of file CPColor.j.

◆ description()

- (CPString) description
implementation

Definition at line 791 of file CPColor.j.

◆ encodeWithCoder:()

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

◆ grayColor()

+ (CPColor) grayColor
implementation

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

Definition at line 316 of file CPColor.j.

◆ greenColor()

+ (CPColor) greenColor
implementation

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

Definition at line 327 of file CPColor.j.

◆ greenComponent()

- (float) greenComponent
implementation

Returns the green component of this color.

Definition at line 612 of file CPColor.j.

◆ hexString()

- (CPString) hexString
implementation

Returns a 6 character long hex string of this color.

Definition at line 763 of file CPColor.j.

◆ hsbComponents()

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

◆ hueComponent()

- (float) hueComponent
implementation

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

Definition at line 725 of file CPColor.j.

◆ initWithCoder:()

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

◆ isEqual:()

- (BOOL) isEqual: (CPColor aColor
implementation

Definition at line 768 of file CPColor.j.

◆ lightGrayColor()

+ (CPColor) lightGrayColor
implementation

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

Definition at line 338 of file CPColor.j.

◆ magentaColor()

+ (CPColor) magentaColor
implementation

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

Definition at line 404 of file CPColor.j.

◆ orangeColor()

+ (CPColor) orangeColor
implementation

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

Definition at line 415 of file CPColor.j.

◆ patternImage()

- (CPImage) patternImage
implementation

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

Definition at line 588 of file CPColor.j.

◆ purpleColor()

+ (CPColor) purpleColor
implementation

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

Definition at line 426 of file CPColor.j.

◆ randomColor()

+ (CPColor) randomColor
implementation

Provided by category CPColor(Debugging).

Definition at line 860 of file CPColor.j.

◆ redColor()

+ (CPColor) redColor
implementation

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

Definition at line 349 of file CPColor.j.

◆ redComponent()

- (float) redComponent
implementation

Return the red component of this color.

Definition at line 620 of file CPColor.j.

◆ saturationComponent()

- (float) saturationComponent
implementation

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

Definition at line 733 of file CPColor.j.

◆ secondarySelectedControlColor()

+ (CPColor) secondarySelectedControlColor
implementation

Definition at line 471 of file CPColor.j.

◆ selectedTextBackgroundColor()

+ (CPColor) selectedTextBackgroundColor
implementation

Definition at line 497 of file CPColor.j.

◆ set()

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

◆ setFill()

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

◆ setStroke()

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

◆ shadowColor()

+ (CPColor) shadowColor
implementation

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

Definition at line 438 of file CPColor.j.

◆ themeAttributes()

+ (CPDictionary) themeAttributes
implementation

Definition at line 94 of file CPColor.j.

◆ whiteColor()

+ (CPColor) whiteColor
implementation

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

Definition at line 360 of file CPColor.j.

◆ yellowColor()

+ (CPColor) yellowColor
implementation

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

Definition at line 371 of file CPColor.j.


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