API  1.0.0
CPColor Class Reference

Instance Methods

(float) - alphaComponent
 
(DOMElement) - applyCSSColorForView:onDOMElement:styleNode:previousState:
 
(float) - blueComponent
 
(float) - brightnessComponent
 
(CPColor- colorUsingColorSpaceName:
 
(CPColor- colorWithAlphaComponent:
 
(CPArray) - components
 
(CPString- cssString
 
(CPString- description
 
(void) - encodeWithCoder:
 
(float) - greenComponent
 
(BOOL) - hasCSSAfterDictionary
 
(BOOL) - hasCSSBeforeDictionary
 
(BOOL) - hasCSSDictionary
 
(CPString- hexString
 
(CPArray) - hsbComponents
 
(float) - hueComponent
 
(id) - initWithCoder:
 
(BOOL) - isCSSBased
 
(BOOL) - isEqual:
 
(CPImage- patternImage
 
(float) - redComponent
 
(void) - restorePreviousCSSState:forDOMElement:
 
(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+ colorWithCSSDictionary:
 
(CPColor+ colorWithCSSDictionary:beforeDictionary:afterDictionary:
 
(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 597 of file CPColor.j.

◆ alternateSelectedControlColor()

+ (CPColor) alternateSelectedControlColor
implementation

Definition at line 467 of file CPColor.j.

◆ applyCSSColorForView:onDOMElement:styleNode:previousState:()

- (DOMElement) applyCSSColorForView: (CPView aView
onDOMElement: (DOMElement)  aDOMElement
styleNode: (DOMElement)  aStyleNode
previousState: (CPArrayRef)  aPreviousStateRef 
implementation

Provided by category CPColor(CSSTheming).

Definition at line 1001 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 284 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 295 of file CPColor.j.

◆ blueComponent()

- (float) blueComponent
implementation

Returns the blue component of this color.

Definition at line 605 of file CPColor.j.

◆ brightnessComponent()

- (float) brightnessComponent
implementation

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

Definition at line 742 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 383 of file CPColor.j.

◆ checkerBoardColor()

+ (CPColor) checkerBoardColor
implementation

Provided by category CPColor(Debugging).

Definition at line 866 of file CPColor.j.

◆ clearColor()

+ (CPColor) clearColor
implementation

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

Definition at line 451 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 661 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 649 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 201 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 142 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 173 of file CPColor.j.

◆ colorWithCSSDictionary:()

+ (CPColor) colorWithCSSDictionary: (CPDictionary aDictionary
implementation

Provided by category CPColor(CSSTheming).

Definition at line 940 of file CPColor.j.

◆ colorWithCSSDictionary:beforeDictionary:afterDictionary:()

+ (CPColor) colorWithCSSDictionary: (CPDictionary aDictionary
beforeDictionary: (CPDictionary beforeDictionary
afterDictionary: (CPDictionary afterDictionary 
implementation

Provided by category CPColor(CSSTheming).

Definition at line 945 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 493 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 264 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 191 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 220 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 482 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 122 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 274 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 157 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 637 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 756 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 394 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 306 of file CPColor.j.

◆ defaultThemeClass()

+ (CPString) defaultThemeClass
implementation

Definition at line 89 of file CPColor.j.

◆ description()

- (CPString) description
implementation

Definition at line 792 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 1117 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 317 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 328 of file CPColor.j.

◆ greenComponent()

- (float) greenComponent
implementation

Returns the green component of this color.

Definition at line 613 of file CPColor.j.

◆ hasCSSAfterDictionary()

- (BOOL) hasCSSAfterDictionary
implementation

Provided by category CPColor(CSSTheming).

Definition at line 984 of file CPColor.j.

◆ hasCSSBeforeDictionary()

- (BOOL) hasCSSBeforeDictionary
implementation

Provided by category CPColor(CSSTheming).

Definition at line 979 of file CPColor.j.

◆ hasCSSDictionary()

- (BOOL) hasCSSDictionary
implementation

Provided by category CPColor(CSSTheming).

Definition at line 974 of file CPColor.j.

◆ hexString()

- (CPString) hexString
implementation

Returns a 6 character long hex string of this color.

Definition at line 764 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 679 of file CPColor.j.

◆ hueComponent()

- (float) hueComponent
implementation

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

Definition at line 726 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 1097 of file CPColor.j.

◆ isCSSBased()

- (BOOL) isCSSBased
implementation

Provided by category CPColor(CSSTheming).

Definition at line 969 of file CPColor.j.

◆ isEqual:()

- (BOOL) isEqual: (CPColor aColor
implementation

Definition at line 769 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 339 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 405 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 416 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 589 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 427 of file CPColor.j.

◆ randomColor()

+ (CPColor) randomColor
implementation

Provided by category CPColor(Debugging).

Definition at line 861 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 350 of file CPColor.j.

◆ redComponent()

- (float) redComponent
implementation

Return the red component of this color.

Definition at line 621 of file CPColor.j.

◆ restorePreviousCSSState:forDOMElement:()

- (void) restorePreviousCSSState: (CPArrayRef)  aPreviousStateRef
forDOMElement: (DOMElement)  aDOMElement 
implementation

Provided by category CPColor(CSSTheming).

Definition at line 989 of file CPColor.j.

◆ saturationComponent()

- (float) saturationComponent
implementation

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

Definition at line 734 of file CPColor.j.

◆ secondarySelectedControlColor()

+ (CPColor) secondarySelectedControlColor
implementation

Definition at line 472 of file CPColor.j.

◆ selectedTextBackgroundColor()

+ (CPColor) selectedTextBackgroundColor
implementation

Definition at line 498 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 833 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 842 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 851 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 439 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 361 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 372 of file CPColor.j.


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