CPObjectCPColor
@implementation CPColor : CPObject
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.
The class does not have a set:
method
like NextStep based frameworks to change the color of
the current context. To change the color of the current
context, use
Method Summary | |
---|---|
+(CPColor) | blackColor Returns a black color object. |
+(CPColor) | blueColor Returns a blue color object. |
+(CPColor) | colorWithCSSString:(CPString)aString Creates a CPColor from a valid CSS RGB string. |
+(CPColor) | colorWithCalibratedRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha Creates a color in the RGB color space, with an alpha value. |
+(CPColor) | colorWithCalibratedWhite:(float)white alpha:(float)alpha Creates a new color object with white for the RGB components. |
+(CPColor) | colorWithHexString:(string)hex Creates an RGB color from a hexadecimal string. |
+(CPColor) | colorWithHue:(float)hue saturation:(float)saturation brightness:(float)brightness Creates a new color in HSB space. |
+(CPColor) | colorWithPatternImage:(CPImage)anImage Creates a color using a tile pattern with anImage . |
+(CPColor) | darkGrayColor Returns a dark gray color object. |
+(CPColor) | grayColor Returns a gray color object. |
+(CPColor) | greenColor Returns a green color object. |
+(CPColor) | lightGrayColor Returns a light gray color object (RGBA=[0. |
+(CPColor) | redColor Returns a red color object (RGBA=[1. |
+(CPColor) | shadowColor Returns a shadow looking color (RGBA=[0. |
+(CPColor) | whiteColor Returns a white color object (RGBA=[1. |
+(CPColor) | yellowColor Returns a yellow color object (RGBA=[1. |
-(id) | initWithCoder:(CPCoder)aCoder Initializes this color from the data archived in a coder. |
-(float) | alphaComponent Returns the alpha component of this color. |
-(float) | blueComponent Returns the blue component of this color. |
-(CPColor) | colorWithAlphaComponent:(float)anAlphaComponent Returns a new color with the same RGB as the receiver but a new alpha component. |
-(CPArray) | components Returns the RGBA components of this color in an array. |
-(CPString) | cssString Returns the CSS representation of this color. |
-(void) | encodeWithCoder:(CPCoder)aCoder Archives this color into a coder. |
-(float) | greenComponent Returns the green component of this color. |
-(CPString) | hexString Returns a 6 character long hex string of this color. |
-(CPArray) | hsbComponents Returns an array with the HSB values for this color. |
-(CPImage) | patternImage Returns the image being used as the pattern for the tile in this color. |
-(float) | redComponent Return the red component of this color. |
Method Detail |
---|
+(CPColor)blackColor
+(CPColor)blueColor
+(CPColor)colorWithCSSString:(CPString)aString
CPColor
from a valid CSS RGB string. Example, "rgb(32,64,129)".aString
- a CSS color string+(CPColor)colorWithCalibratedRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha
red
- the red component of the colorgreen
- the green component of the colorblue
- the blue component of the coloralpha
- the alpha component+(CPColor)colorWithCalibratedWhite:(float)white alpha:(float)alpha
white
for the RGB components.
For the alpha component, a value of 1.0 is opaque, and 0.0 means completely transparent.white
- a float between 0.0 and 1.0alpha
- the alpha component between 0.0 and 1.0+(CPColor)colorWithHexString:(string)hex
hex
- a 6 character long string of hex+(CPColor)colorWithHue:(float)hue saturation:(float)saturation brightness:(float)brightness
hue
- the hue valuesaturation
- the saturation valuebrightness
- the brightness value+(CPColor)colorWithPatternImage:(CPImage)anImage
anImage
anImage
+(CPColor)darkGrayColor
+(CPColor)grayColor
+(CPColor)greenColor
+(CPColor)lightGrayColor
+(CPColor)redColor
+(CPColor)shadowColor
+(CPColor)whiteColor
+(CPColor)yellowColor
-(id)initWithCoder:(CPCoder)aCoder
aCoder
- the coder from which the color will be loaded-(float)alphaComponent
-(float)blueComponent
-(CPColor)colorWithAlphaComponent:(float)anAlphaComponent
anAlphaComponent
- the alpha component for the new color-(CPArray)components
Index Component 0 Red 1 Green 2 Blue 3 Alpha
-(CPString)cssString
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
-(void)encodeWithCoder:(CPCoder)aCoder
aCoder
- the coder into which the color will be archived.-(float)greenComponent
-(CPString)hexString
-(CPArray)hsbComponents
Index Component 0 Hue 1 Saturation 2 Brightness
-(CPImage)patternImage
-(float)redComponent
Created on Sat Sep 13 14:15:43 PDT 2008