Structure representing a 32 bit RGBA color. More...
RGB Colors | |
uint8 | red |
Red value for the color. | |
uint8 | green |
Green value for the color. | |
uint8 | blue |
Blue value for the color. | |
uint8 | alpha |
Alpha value for the color. | |
rgb_color & | set_to (uint8 r, uint8 g, uint8 b, uint8 a=255) |
Helper method to set all values of the color. | |
int32 | Brightness () const |
Calculates a value representing the brightness of this color. | |
bool | IsDark () const |
Determines if the color is dark. | |
bool | IsLight () const |
Determines if the color is light. | |
bool | operator== (const rgb_color &other) const |
Comparison operator. | |
bool | operator!= (const rgb_color &other) const |
Comparison operator. | |
rgb_color & | operator= (const rgb_color &other) |
Assign values from another color object. | |
static int32 | Contrast (rgb_color colorA, rgb_color colorB) |
Calculates the contrast between two colors. | |
Structure representing a 32 bit RGBA color.
int32 rgb_color::Brightness | ( | ) | const |
Calculates a value representing the brightness of this color.
This method calculates the perceptual brightness of a color.
Referenced by Contrast(), IsDark(), and IsLight().
Calculates the contrast between two colors.
This method compares the Brightness of colorA and colorB and returns the Contrast that is between them.
For example this can used to make sure a color combination is legible on a specifc background.
References Brightness().
|
inline |
Determines if the color is dark.
A color is considered 'dark' if its Brightness() is <= 127.
References Brightness().
|
inline |
Determines if the color is light.
A color is considered 'light' if its Brightness() is > 127.
References Brightness().
|
inline |
Comparison operator.
other | The other color to compare to. |
true | The colors are different. |
false | The colors match. |
|
inline |
Comparison operator.
other | The other color to compare to. |
true | The colors match. |
false | The colors are different. |
Helper method to set all values of the color.
r | Red value. |
g | Green value. |
b | Blue value. |
a | Alpha value. |
References alpha, blue, green, and red.
Referenced by operator=().
uint8 rgb_color::alpha |
Alpha value for the color.
Referenced by BScreen::IndexForColor(), operator=(), set_to(), BView::SetHighColor(), BView::SetLowColor(), and BView::SetViewColor().
uint8 rgb_color::blue |
Blue value for the color.
Referenced by BScreen::IndexForColor(), operator=(), set_to(), BView::SetHighColor(), BView::SetLowColor(), BColorControl::SetValue(), and BView::SetViewColor().
uint8 rgb_color::green |
Green value for the color.
Referenced by BScreen::IndexForColor(), operator=(), set_to(), BView::SetHighColor(), BView::SetLowColor(), BColorControl::SetValue(), and BView::SetViewColor().
uint8 rgb_color::red |
Red value for the color.
Referenced by BScreen::IndexForColor(), operator=(), set_to(), BView::SetHighColor(), BView::SetLowColor(), BColorControl::SetValue(), and BView::SetViewColor().