All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
List of all members
rgb_color Struct Reference

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_colorset_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_coloroperator= (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.
 

Detailed Description

Structure representing a 32 bit RGBA color.

Since
BeOS R3

Member Function Documentation

◆ Brightness()

int32 rgb_color::Brightness ( ) const

Calculates a value representing the brightness of this color.

This method calculates the perceptual brightness of a color.

Returns
A value representing the brightness. (0-255)
Since
Haiku R1

Referenced by Contrast(), IsDark(), and IsLight().

◆ Contrast()

static int32 rgb_color::Contrast ( rgb_color  colorA,
rgb_color  colorB 
)
inlinestatic

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.

Returns
A value representing the Contrast. (0-255)
Since
Haiku R1

References Brightness().

◆ IsDark()

bool rgb_color::IsDark ( ) const
inline

Determines if the color is dark.

A color is considered 'dark' if its Brightness() is <= 127.

Since
Haiku R1

References Brightness().

◆ IsLight()

bool rgb_color::IsLight ( ) const
inline

Determines if the color is light.

A color is considered 'light' if its Brightness() is > 127.

Since
Haiku R1

References Brightness().

◆ operator!=()

bool rgb_color::operator!= ( const rgb_color other) const
inline

Comparison operator.

Parameters
otherThe other color to compare to.
Return values
trueThe colors are different.
falseThe colors match.
Since
Haiku R1

◆ operator=()

rgb_color & rgb_color::operator= ( const rgb_color other)
inline

Assign values from another color object.

Parameters
otherThe other color to copy.
Returns
A reference to this object.
Since
Haiku R1

References alpha, blue, green, red, and set_to().

◆ operator==()

bool rgb_color::operator== ( const rgb_color other) const
inline

Comparison operator.

Parameters
otherThe other color to compare to.
Return values
trueThe colors match.
falseThe colors are different.
Since
Haiku R1

◆ set_to()

rgb_color & rgb_color::set_to ( uint8  r,
uint8  g,
uint8  b,
uint8  a = 255 
)
inline

Helper method to set all values of the color.

Parameters
rRed value.
gGreen value.
bBlue value.
aAlpha value.
Returns
A reference to this object.
Since
Haiku R1

References alpha, blue, green, and red.

Referenced by operator=().

Member Data Documentation

◆ alpha

uint8 rgb_color::alpha

Alpha value for the color.

Since
BeOS R3

Referenced by BScreen::IndexForColor(), operator=(), set_to(), BView::SetHighColor(), BView::SetLowColor(), and BView::SetViewColor().

◆ blue

uint8 rgb_color::blue

◆ green

uint8 rgb_color::green

◆ red

uint8 rgb_color::red