- Inherits from:
- Object
- Conforms to:
- DParsable, DTextable
- Declared in:
- DColor.h
Object
|
+---DColor
Class Description
The color class implements a number of methods for using colors.
- Last modified:
- 12-Nov-2005 (DColor.h)
Instance Variables
- public unsigned char _red
- the red color 255 = full
- public unsigned char _green
- the green color 255 = full
- public unsigned char _blue
- the blue color 255 = full
- public unsigned char _alpha
- the alpha factor 255 = solid
- public int _text
- the (alternative) text color (DCLR_... or -1)
- Constructors
- - (DColor *) init
- Initialise an empty (black) color
- Returns:
- the object
- - (DColor *) init :(const char *) name
- Initialise to a solid named color
- Parameters:
- name - the color name
- Returns:
- the object
- - (DColor *) init :(unsigned char) red :(unsigned char) blue :(unsigned char) green
- Initialise to a solid rgb color
- Parameters:
- red - the red factor (0..255)
blue - the blue factor (0..255)
green - the green factor (0..255)
- Returns:
- the object
- - (DColor *) init :(unsigned char) red :(unsigned char) blue :(unsigned char) green :(unsigned char) alpha
- Initialise to a transparent rgb color
- Parameters:
- red - the red factor (0..255)
blue - the blue factor (0..255)
green - the green factor (0..255)
alpha - the alpha factor (0..255)
- Returns:
- the object
- Member methods
- - (unsigned char) alpha
- Get the alpha factor
- Returns:
- the solid factor
- - (DColor *) alpha :(unsigned char) alpha
- Set the alpha factor
- Parameters:
- alpha - the transparent factor (0..255)
- Returns:
- the object
- - (unsigned char) blue
- Get the blue factor
- Returns:
- the blue factor
- - (unsigned char) green
- Get the green factor
- Returns:
- the green factor
- - (unsigned char) red
- Get the red factor
- Returns:
- the red factor
- - (int) textColor
- Get the text color
- Returns:
- the text color
- - (DColor *) textColor :(int) color
- Set the text color
- Parameters:
- color - the text color (DCLR_..)
- Returns:
- the object
- Set the color
- - (BOOL) set :(const char *) name
- Set a color based on a name
(alpha is not changed)
- Parameters:
- name - the name of the color
- Returns:
- is the name found ?
- - (DColor *) set :(unsigned char) red :(unsigned char) green :(unsigned char) blue
- Set a color based on rgb
(alpha and text color are not changed)
- Parameters:
- red - the red color (0..255)
green - the green color (0..255)
blue - the blue color (0..255)
- Returns:
- the object
- - (DColor *) set :(unsigned char) red :(unsigned char) green :(unsigned char) blue :(unsigned char) alpha
- Set a transparent color based on rgb
(text color is not changed)
- Parameters:
- red - the red color (0..255)
green - the green color (0..255)
blue - the blue color (0..255)
alpha - the transparent factor (0..255)
- Returns:
- the object
- - (DColor *) set :(unsigned char) red :(unsigned char) green :(unsigned char) blue :(unsigned char) alpha :(int) color
- Set a transparent color based on rgb and a text color
- Parameters:
- red - the red color (0..255)
green - the green color (0..255)
blue - the blue color (0..255)
alpha - the transparent factor (0..255)
color - the text color (DCLR_..)
- Returns:
- the object
- Color manipulation
- - (DColor *) blend :(unsigned char) red :(unsigned char) green :(unsigned char) blue :(unsigned char) alpha
- Alpha blending with a color
- Parameters:
- red - the red factor of the color (0..255)
green - the green factor of the color (0..255)
blue - the blue factor of the color (0..255)
alpha - the alpha blending factor (0..255)
- Returns:
- the object
- - (DColor *) lighter :(double) factor
- Make the color lighter or darker
- Parameters:
- factor - the lighter (<1.0..>) or darker [0.0..1.0>) factor
- Returns:
- the object
- Color systems
- - (DColor *) fromCMY :(double) C :(double) M :(double) Y
- Convert from CMY
- Parameters:
- C - the C (0.0 .. 1.0)
M - the M (0.0 .. 1.0)
Y - the Y (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) fromHLS :(double) H :(double) L :(double) S
- Convert from HLS
- Parameters:
- H - the H (0.0 .. 359.9)
L - the L (0.0 .. 1.0)
S - the S (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) fromHSV :(double) H :(double) S :(double) V
- Convert from HSV
- Parameters:
- H - the H (0.0 .. 359.9)
S - the S (0.0 .. 1.0)
V - the V (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) fromRGB :(double) red :(double) green :(double) blue
- 'Convert' from RGB
- Parameters:
- red - the red color (0.0 .. 1.0)
green - the green color (0.0 .. 1.0)
blue - the blue color (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) fromYIQ :(double) Y :(double) I :(double) Q
- Convert from YIQ
- Parameters:
- Y - the Y (0.0 .. 1.0)
I - the I (0.0 .. 1.0)
Q - the Q (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) toCMY :(double *) C :(double *) M :(double *) Y
- Convert to CMY
(C = Cyan, M = Magenta, Y = Yellow)
- Parameters:
- C - the destination for C (0.0 .. 1.0)
M - the destination for M (0.0 .. 1.0)
Y - the destination for Y (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) toHLS :(double *) H :(double *) L :(double *) S
- Convert to HLS
(H = Hue, L=Lightness, S=Saturation)
- Parameters:
- H - the destination for H (0.0 .. 359.9)
L - the destination for L (0.0 .. 1.0)
S - the destination for S (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) toHSV :(double *) H :(double *) S :(double *) V
- Convert to HSV
(H = Hue, S=Saturation, Value)
- Parameters:
- H - the destination for H (0.0 .. 359.9)
S - the destination for S (0.0 .. 1.0)
V - the destination for V (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) toRGB :(double *) red :(double *) green :(double *) blue
- 'Convert' to RGB
- Parameters:
- red - the destination for red (0.0 .. 1.0)
green - the destination for green (0.0 .. 1.0)
blue - the destination for blue (0.0 .. 1.0)
- Returns:
- the object
- - (DColor *) toYIQ :(double *) Y :(double *) I :(double *) Q
- Convert to the composite video signals YIQ
(Y = grey level, I+Q color components)
- Parameters:
- Y - the destination for Y (0.0 .. 1.0)
I - the destination for I (0.0 .. 1.0)
Q - the destination for Q (0.0 .. 1.0)
- Returns:
- the object
- Textable protocol methods
- - (DText *) toText
- Convert to a text string (RGB coded in six hex digits,
if a text color is known, it is added to the six hex
digits)
- Returns:
- a (new) text string with the color
- Parsable protocol members
- - (int) fromString :(char **) cstr
- Parse a string to set a color object.
This method supports the following formats:
#RGB -- color is defined by three hex digits
#RRGGBB -- color is defined by six hex digits
R%,G%,B% -- color is defined by three percentage digits
R.R,G.G,B.B -- color is defined by three floats (0.0 .. 1.0)
R,G,B -- color is defined by three bytes (0 .. 255)
name -- color is defined by an internal name
the color can be followed by a comma and a text color name
Example: #8042AF,black
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- the result (0, ERANGE, ENODATA)
generated 08-Jan-2006 by ObjcDoc 3.0.0