Emergency 20 Dokumentation  4.1.0
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
qsf::Color4 Class Reference

Color class with red, green, blue and alpha component. More...

#include <Color4.h>

Collaboration diagram for qsf::Color4:
Collaboration graph
[legend]

Public Member Functions

 Color4 ()
 Default constructor (all components are set to 0.0) More...
 
 Color4 (const Color3 &rgb, float alpha=1.0f)
 Constructor from RGB color, adding alpha value of 1.0f. More...
 
 Color4 (float r, float g, float b, float a=1.0f)
 Constructor. More...
 
 Color4 (uint8 r, uint8 g, uint8 b, uint8 a=255)
 Constructor. More...
 
 Color4 (const float rgba[])
 Constructor. More...
 
 Color4 (const uint8 rgba[])
 Constructor. More...
 
 Color4 (float luminance)
 Constructor. More...
 
 Color4 (uint8 luminance)
 Constructor. More...
 
 Color4 (const Color4 &source)
 Copy constructor. More...
 
 ~Color4 ()
 Destructor. More...
 
uint32 toUInt32 () const
 Maps this RGBA floating point channels (0.0f to 1.0f range) to uint32. More...
 
uint32 toRGBAUInt32 () const
 
uint32 toARGBUInt32 () const
 
uint32 toRGBUInt32 () const
 
std::string toHexColor () const
 Get a hex color string representation (including '#' at the beginning) from a "qsf::Color4". More...
 
void fromUInt32 (uint32 packedColor)
 Maps from a uint32 to RGBA floating point channels (0.0f to 1.0f range) More...
 
void getRGBA (float &r, float &g, float &b, float &a) const
 Get the color component as float values. More...
 
void getRGBA (uint8 &r, uint8 &g, uint8 &b, uint8 &a) const
 Get the color component as integer values. More...
 
void setRGBA (float r, float g, float b, float a)
 Set the color components by using float values. More...
 
void setRGBA (uint8 r, uint8 g, uint8 b, uint8 a)
 Set the color components by using integer values. More...
 
void getRGBA (float rgba[]) const
 Get the color component as array of float values. More...
 
void getRGBA (uint8 rgba[]) const
 Get the color component as array of integer values. More...
 
void setRGBA (const float rgba[])
 Set the color components by using a reference to float values. More...
 
void setRGBA (const uint8 rgba[])
 Set the color components by using a reference to integer values. More...
 
void setRGBA (float value)
 Set all color component to the same float value. More...
 
void setRGBA (uint8 value)
 Set all color component to the same integer value. More...
 
void saturate ()
 Clamps the color values between 0.0 and 1.0. More...
 
Color4operator= (const Color4 &otherColor)
 
Color4operator= (const float rgba[])
 
Color4operator= (float value)
 
 operator float * ()
 
 operator const float * () const
 
bool operator== (const Color4 &otherColor) const
 
bool operator!= (const Color4 &otherColor) const
 
bool operator== (float value) const
 
bool operator!= (float value) const
 
Color4 operator+ (const Color4 &otherColor) const
 
Color4 operator+ (float value) const
 
Color4operator+= (const Color4 &otherColor)
 
Color4operator+= (float value)
 
Color4 operator- () const
 
Color4 operator- (const Color4 &otherColor) const
 
Color4 operator- (float value) const
 
Color4operator-= (const Color4 &otherColor)
 
Color4operator-= (float value)
 
Color4 operator* (const Color4 &otherColor) const
 
Color4 operator* (float value) const
 
Color4operator*= (const Color4 &otherColor)
 
Color4operator*= (float value)
 
Color4 operator/ (const Color4 &otherColor) const
 
Color4 operator/ (float value) const
 
Color4operator/= (const Color4 &otherColor)
 
Color4operator/= (float value)
 
float & operator[] (int index)
 

Static Public Member Functions

static Color4 interpolate (const Color4 &color1, const Color4 &color2, float factor)
 Interpolate between two RGBA colors. More...
 

Public Attributes

union {
   float   color [4]
 
   struct {
      float   r
 
      float   g
 
      float   b
 
      float   a
 
   } 
 
}; 
 

Static Public Attributes

static const Color4 TRANSPARENT
 0.0, 0.0, 0.0, 0.0 More...
 
static const Color4 BLACK
 Black (sRGB="0 0 0", Hex="#000000") More...
 
static const Color4 WHITE
 White (sRGB="255 255 255", Hex="#FFFFFF") More...
 
static const Color4 RED
 Red (sRGB="255 0 0", Hex="#FF0000") More...
 
static const Color4 YELLOW
 Yellow (sRGB="255 255 0", Hex="#FFFF00") More...
 
static const Color4 GREEN
 Green (sRGB="0 255 0", Hex="#00FF00") More...
 
static const Color4 CYAN
 Cyan (sRGB="0 255 255", Hex="#00FFFF") More...
 
static const Color4 BLUE
 Blue (sRGB="0 0 255", Hex="#0000FF") More...
 
static const Color4 PINK
 Pink (sRGB="255 0 255", Hex="#FF00FF") More...
 
static const Color4 ORANGE
 Orange(sRGB="255 127 0", Hex="#FF7F00") More...
 
static const Color4 FUCHSIA
 Fuchsia, also called full magenta, bright pink or vivid pink (sRGB="255 0 255", Hex="#FF00FF") More...
 
static const Color4 MAROON
 Maroon, dark brownish-red color (sRGB="128 0 0", Hex="#800000") More...
 
static const Color4 OLIVE
 Olive, dark green/brown color (sRGB="128 128 0", Hex="#808000") More...
 
static const Color4 NAVY
 Navy, also called navy blue, very dark shade of the color blue (sRGB="0 0 128", Hex="#000080") More...
 
static const Color4 PURPLE
 Purple, color intermediate to red and blue (sRGB="128 0 128", Hex="#800080") More...
 
static const Color4 TEAL
 Teal, also called teal blue, greenish dark-blue color (sRGB="0 128 128", Hex="#008080") More...
 
static const Color4 GRAY
 Gray (sRGB="128 128 128", Hex="#808080") More...
 
static const Color4 SILVER
 Silver (sRGB="192 192 192", Hex="#C0C0C0") More...
 
static const Color4 LIME
 Lime, actually corresponds to the green primary of an RGB display (sRGB="0 255 0", Hex="#00FF00") More...
 

Detailed Description

Color class with red, green, blue and alpha component.

Constructor & Destructor Documentation

qsf::Color4::Color4 ( )
inline

Default constructor (all components are set to 0.0)

qsf::Color4::Color4 ( const Color3 rgb,
float  alpha = 1.0f 
)

Constructor from RGB color, adding alpha value of 1.0f.

Note
  • Not explicit by intent
qsf::Color4::Color4 ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Constructor.

Parameters
[in]rRed color component (0.0-1.0)
[in]gGreen color component (0.0-1.0)
[in]bBlue color component (0.0-1.0)
[in]aAlpha color component (0.0-1.0)
qsf::Color4::Color4 ( uint8  r,
uint8  g,
uint8  b,
uint8  a = 255 
)
inline

Constructor.

Parameters
[in]rRed color component (0-255)
[in]gGreen color component (0-255)
[in]bBlue color component (0-255)
[in]aAlpha color component (0-255)
qsf::Color4::Color4 ( const float  rgba[])
inline

Constructor.

Parameters
[in]rgbaFloat array holding the color, must have 4 elements! (0.0-1.0)
qsf::Color4::Color4 ( const uint8  rgba[])
inline

Constructor.

Parameters
[in]rgbauint8 array holding the color, must have 4 elements! (0-255)
qsf::Color4::Color4 ( float  luminance)
inline

Constructor.

Parameters
[in]luminanceValue for all four color components (0.0-1.0)
qsf::Color4::Color4 ( uint8  luminance)
inline

Constructor.

Parameters
[in]luminanceValue for all four color components (0-255)
qsf::Color4::Color4 ( const Color4 source)
inlineexplicit

Copy constructor.

Parameters
[in]sourceSource color
qsf::Color4::~Color4 ( )
inline

Destructor.

Note
  • Not virtual by intent

Member Function Documentation

void qsf::Color4::fromUInt32 ( uint32  packedColor)
inline

Maps from a uint32 to RGBA floating point channels (0.0f to 1.0f range)

Parameters
[in]packedColorColor4 as uint32
void qsf::Color4::getRGBA ( float &  r,
float &  g,
float &  b,
float &  a 
) const
inline

Get the color component as float values.

Parameters
[out]rWill receive the red color component (0.0-1.0)
[out]gWill receive the green color component (0.0-1.0)
[out]bWill receive the blue color component (0.0-1.0)
[out]aWill receive the alpha color component (0.0-1.0)
void qsf::Color4::getRGBA ( uint8 r,
uint8 g,
uint8 b,
uint8 a 
) const
inline

Get the color component as integer values.

Parameters
[out]rWill receive the red color component (0-255)
[out]gWill receive the green color component (0-255)
[out]bWill receive the blue color component (0-255)
[out]aWill receive the alpha color component (0-255)
void qsf::Color4::getRGBA ( float  rgba[]) const
inline

Get the color component as array of float values.

Parameters
[out]rgbaReference to float array receiving the color values, must have 4 elements! (0.0-1.0)
void qsf::Color4::getRGBA ( uint8  rgba[]) const
inline

Get the color component as array of integer values.

Parameters
[out]rgbaReference to uint8 array receiving the color values, must have 4 elements! (0-255)
Color4 qsf::Color4::interpolate ( const Color4 color1,
const Color4 color2,
float  factor 
)
inlinestatic

Interpolate between two RGBA colors.

Parameters
[in]color1First color; this is returned with interpolation factor 0.0f
[in]color2Second color; this is returned with interpolation factor 1.0f
[in]factorInterpolation factor between 0.0f and 1.0f
Returns
Interpolated RGBA color
Note
  • This is a component-wise interpolation without special handling for the alpha channel
qsf::Color4::operator const float * ( ) const
inline
qsf::Color4::operator float * ( )
inline
bool qsf::Color4::operator!= ( const Color4 otherColor) const
inline
bool qsf::Color4::operator!= ( float  value) const
inline
Color4 qsf::Color4::operator* ( const Color4 otherColor) const
inline
Color4 qsf::Color4::operator* ( float  value) const
inline
Color4 & qsf::Color4::operator*= ( const Color4 otherColor)
inline
Color4 & qsf::Color4::operator*= ( float  value)
inline
Color4 qsf::Color4::operator+ ( const Color4 otherColor) const
inline
Color4 qsf::Color4::operator+ ( float  value) const
inline
Color4 & qsf::Color4::operator+= ( const Color4 otherColor)
inline
Color4 & qsf::Color4::operator+= ( float  value)
inline
Color4 qsf::Color4::operator- ( ) const
inline
Color4 qsf::Color4::operator- ( const Color4 otherColor) const
inline
Color4 qsf::Color4::operator- ( float  value) const
inline
Color4 & qsf::Color4::operator-= ( const Color4 otherColor)
inline
Color4 & qsf::Color4::operator-= ( float  value)
inline
Color4 qsf::Color4::operator/ ( const Color4 otherColor) const
inline
Color4 qsf::Color4::operator/ ( float  value) const
inline
Color4 & qsf::Color4::operator/= ( const Color4 otherColor)
inline
Color4 & qsf::Color4::operator/= ( float  value)
inline
Color4 & qsf::Color4::operator= ( const Color4 otherColor)
inline
Color4 & qsf::Color4::operator= ( const float  rgba[])
inline
Color4 & qsf::Color4::operator= ( float  value)
inline
bool qsf::Color4::operator== ( const Color4 otherColor) const
inline
bool qsf::Color4::operator== ( float  value) const
inline
float & qsf::Color4::operator[] ( int  index)
inline
void qsf::Color4::saturate ( )
inline

Clamps the color values between 0.0 and 1.0.

void qsf::Color4::setRGBA ( float  r,
float  g,
float  b,
float  a 
)
inline

Set the color components by using float values.

Parameters
[in]rRed color component (0.0-1.0)
[in]gGreen color component (0.0-1.0)
[in]bBlue color component (0.0-1.0)
[in]aAlpha color component (0.0-1.0)
void qsf::Color4::setRGBA ( uint8  r,
uint8  g,
uint8  b,
uint8  a 
)
inline

Set the color components by using integer values.

Parameters
[in]rRed color component (0-255)
[in]gGreen color component (0-255)
[in]bBlue color component (0-255)
[in]aAlpha color component (0-255)
void qsf::Color4::setRGBA ( const float  rgba[])
inline

Set the color components by using a reference to float values.

Parameters
[in]rgbaReference to float array containing the color value, must have 4 elements! (0.0-1.0)
void qsf::Color4::setRGBA ( const uint8  rgba[])
inline

Set the color components by using a reference to integer values.

Parameters
[in]rgbaReference to uint8 array containing the color value, must have 4 elements! (0-255)
void qsf::Color4::setRGBA ( float  value)
inline

Set all color component to the same float value.

Parameters
[in]valueValue for all four color component (0.0-1.0)
void qsf::Color4::setRGBA ( uint8  value)
inline

Set all color component to the same integer value.

Parameters
[in]valueValue for all four color component (0-255)
uint32 qsf::Color4::toARGBUInt32 ( ) const
inline
std::string qsf::Color4::toHexColor ( ) const

Get a hex color string representation (including '#' at the beginning) from a "qsf::Color4".

uint32 qsf::Color4::toRGBAUInt32 ( ) const
inline
uint32 qsf::Color4::toRGBUInt32 ( ) const
inline
uint32 qsf::Color4::toUInt32 ( ) const
inline

Maps this RGBA floating point channels (0.0f to 1.0f range) to uint32.

Returns
This color as uint32 (ARGB)

Member Data Documentation

union { ... }
float qsf::Color4::a
float qsf::Color4::b
const Color4 qsf::Color4::BLACK
static

Black (sRGB="0 0 0", Hex="#000000")

const Color4 qsf::Color4::BLUE
static

Blue (sRGB="0 0 255", Hex="#0000FF")

float qsf::Color4::color[4]
const Color4 qsf::Color4::CYAN
static

Cyan (sRGB="0 255 255", Hex="#00FFFF")

const Color4 qsf::Color4::FUCHSIA
static

Fuchsia, also called full magenta, bright pink or vivid pink (sRGB="255 0 255", Hex="#FF00FF")

float qsf::Color4::g
const Color4 qsf::Color4::GRAY
static

Gray (sRGB="128 128 128", Hex="#808080")

const Color4 qsf::Color4::GREEN
static

Green (sRGB="0 255 0", Hex="#00FF00")

const Color4 qsf::Color4::LIME
static

Lime, actually corresponds to the green primary of an RGB display (sRGB="0 255 0", Hex="#00FF00")

const Color4 qsf::Color4::MAROON
static

Maroon, dark brownish-red color (sRGB="128 0 0", Hex="#800000")

const Color4 qsf::Color4::NAVY
static

Navy, also called navy blue, very dark shade of the color blue (sRGB="0 0 128", Hex="#000080")

const Color4 qsf::Color4::OLIVE
static

Olive, dark green/brown color (sRGB="128 128 0", Hex="#808000")

const Color4 qsf::Color4::ORANGE
static

Orange(sRGB="255 127 0", Hex="#FF7F00")

const Color4 qsf::Color4::PINK
static

Pink (sRGB="255 0 255", Hex="#FF00FF")

const Color4 qsf::Color4::PURPLE
static

Purple, color intermediate to red and blue (sRGB="128 0 128", Hex="#800080")

float qsf::Color4::r
const Color4 qsf::Color4::RED
static

Red (sRGB="255 0 0", Hex="#FF0000")

const Color4 qsf::Color4::SILVER
static

Silver (sRGB="192 192 192", Hex="#C0C0C0")

const Color4 qsf::Color4::TEAL
static

Teal, also called teal blue, greenish dark-blue color (sRGB="0 128 128", Hex="#008080")

const Color4 qsf::Color4::TRANSPARENT
static

0.0, 0.0, 0.0, 0.0

const Color4 qsf::Color4::WHITE
static

White (sRGB="255 255 255", Hex="#FFFFFF")

const Color4 qsf::Color4::YELLOW
static

Yellow (sRGB="255 255 0", Hex="#FFFF00")


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