Emergency 2017 Dokumentation  v3.0.1
qsf::Color4 Class Reference

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

#include <Color4.h>

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.

Definition at line 39 of file Color4.h.

Constructor & Destructor Documentation

qsf::Color4::Color4 ( )
inline

Default constructor (all components are set to 0.0)

Definition at line 32 of file Color4-inl.h.

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)

Definition at line 41 of file Color4-inl.h.

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)

Definition at line 50 of file Color4-inl.h.

qsf::Color4::Color4 ( const float  rgba[])
inline

Constructor.

Parameters
[in]rgbaFloat array holding the color, must have 4 elements! (0.0-1.0)

Definition at line 59 of file Color4-inl.h.

qsf::Color4::Color4 ( const uint8  rgba[])
inline

Constructor.

Parameters
[in]rgbauint8 array holding the color, must have 4 elements! (0-255)

Definition at line 68 of file Color4-inl.h.

qsf::Color4::Color4 ( float  luminance)
inline

Constructor.

Parameters
[in]luminanceValue for all four color components (0.0-1.0)

Definition at line 77 of file Color4-inl.h.

qsf::Color4::Color4 ( uint8  luminance)
inline

Constructor.

Parameters
[in]luminanceValue for all four color components (0-255)

Definition at line 86 of file Color4-inl.h.

qsf::Color4::Color4 ( const Color4 source)
inlineexplicit

Copy constructor.

Parameters
[in]sourceSource color

Definition at line 95 of file Color4-inl.h.

qsf::Color4::~Color4 ( )
inline

Destructor.

Note
  • Not virtual by intent

Definition at line 104 of file Color4-inl.h.

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

Definition at line 139 of file Color4-inl.h.

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)

Definition at line 147 of file Color4-inl.h.

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)

Definition at line 155 of file Color4-inl.h.

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)

Definition at line 179 of file Color4-inl.h.

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)

Definition at line 187 of file Color4-inl.h.

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

Definition at line 23 of file Color4-inl.h.

qsf::Color4::operator const float * ( ) const
inline

Definition at line 283 of file Color4-inl.h.

qsf::Color4::operator float * ( )
inline

Definition at line 278 of file Color4-inl.h.

bool qsf::Color4::operator!= ( const Color4 otherColor) const
inline

Definition at line 297 of file Color4-inl.h.

bool qsf::Color4::operator!= ( float  value) const
inline

Definition at line 307 of file Color4-inl.h.

Color4 qsf::Color4::operator* ( const Color4 otherColor) const
inline

Definition at line 381 of file Color4-inl.h.

Color4 qsf::Color4::operator* ( float  value) const
inline

Definition at line 386 of file Color4-inl.h.

Color4 & qsf::Color4::operator*= ( const Color4 otherColor)
inline

Definition at line 391 of file Color4-inl.h.

Color4 & qsf::Color4::operator*= ( float  value)
inline

Definition at line 401 of file Color4-inl.h.

Color4 qsf::Color4::operator+ ( const Color4 otherColor) const
inline

Definition at line 316 of file Color4-inl.h.

Color4 qsf::Color4::operator+ ( float  value) const
inline

Definition at line 321 of file Color4-inl.h.

Color4 & qsf::Color4::operator+= ( const Color4 otherColor)
inline

Definition at line 326 of file Color4-inl.h.

Color4 & qsf::Color4::operator+= ( float  value)
inline

Definition at line 336 of file Color4-inl.h.

Color4 qsf::Color4::operator- ( ) const
inline

Definition at line 346 of file Color4-inl.h.

Color4 qsf::Color4::operator- ( const Color4 otherColor) const
inline

Definition at line 351 of file Color4-inl.h.

Color4 qsf::Color4::operator- ( float  value) const
inline

Definition at line 356 of file Color4-inl.h.

Color4 & qsf::Color4::operator-= ( const Color4 otherColor)
inline

Definition at line 361 of file Color4-inl.h.

Color4 & qsf::Color4::operator-= ( float  value)
inline

Definition at line 371 of file Color4-inl.h.

Color4 qsf::Color4::operator/ ( const Color4 otherColor) const
inline

Definition at line 411 of file Color4-inl.h.

Color4 qsf::Color4::operator/ ( float  value) const
inline

Definition at line 416 of file Color4-inl.h.

Color4 & qsf::Color4::operator/= ( const Color4 otherColor)
inline

Definition at line 421 of file Color4-inl.h.

Color4 & qsf::Color4::operator/= ( float  value)
inline

Definition at line 431 of file Color4-inl.h.

Color4 & qsf::Color4::operator= ( const Color4 otherColor)
inline

Definition at line 251 of file Color4-inl.h.

Color4 & qsf::Color4::operator= ( const float  rgba[])
inline

Definition at line 261 of file Color4-inl.h.

Color4 & qsf::Color4::operator= ( float  value)
inline

Definition at line 271 of file Color4-inl.h.

bool qsf::Color4::operator== ( const Color4 otherColor) const
inline

Definition at line 292 of file Color4-inl.h.

bool qsf::Color4::operator== ( float  value) const
inline

Definition at line 302 of file Color4-inl.h.

float & qsf::Color4::operator[] ( int  index)
inline

Definition at line 441 of file Color4-inl.h.

void qsf::Color4::saturate ( )
inline

Clamps the color values between 0.0 and 1.0.

Definition at line 227 of file Color4-inl.h.

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)

Definition at line 163 of file Color4-inl.h.

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)

Definition at line 171 of file Color4-inl.h.

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)

Definition at line 195 of file Color4-inl.h.

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)

Definition at line 203 of file Color4-inl.h.

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)

Definition at line 211 of file Color4-inl.h.

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)

Definition at line 219 of file Color4-inl.h.

uint32 qsf::Color4::toARGBUInt32 ( ) const
inline

Definition at line 114 of file Color4-inl.h.

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

Definition at line 122 of file Color4-inl.h.

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

Definition at line 130 of file Color4-inl.h.

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)

Definition at line 109 of file Color4-inl.h.

Member Data Documentation

union { ... }
float qsf::Color4::a

Definition at line 104 of file Color4.h.

float qsf::Color4::b

Definition at line 104 of file Color4.h.

const Color4 qsf::Color4::BLACK
static

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

Definition at line 49 of file Color4.h.

const Color4 qsf::Color4::BLUE
static

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

Definition at line 55 of file Color4.h.

float qsf::Color4::color[4]

Definition at line 101 of file Color4.h.

const Color4 qsf::Color4::CYAN
static

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

Definition at line 54 of file Color4.h.

const Color4 qsf::Color4::FUCHSIA
static

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

Definition at line 60 of file Color4.h.

float qsf::Color4::g

Definition at line 104 of file Color4.h.

const Color4 qsf::Color4::GRAY
static

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

Definition at line 66 of file Color4.h.

const Color4 qsf::Color4::GREEN
static

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

Definition at line 53 of file Color4.h.

const Color4 qsf::Color4::LIME
static

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

Definition at line 68 of file Color4.h.

const Color4 qsf::Color4::MAROON
static

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

Definition at line 61 of file Color4.h.

const Color4 qsf::Color4::NAVY
static

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

Definition at line 63 of file Color4.h.

const Color4 qsf::Color4::OLIVE
static

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

Definition at line 62 of file Color4.h.

const Color4 qsf::Color4::ORANGE
static

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

Definition at line 57 of file Color4.h.

const Color4 qsf::Color4::PINK
static

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

Definition at line 56 of file Color4.h.

const Color4 qsf::Color4::PURPLE
static

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

Definition at line 64 of file Color4.h.

float qsf::Color4::r

Definition at line 104 of file Color4.h.

const Color4 qsf::Color4::RED
static

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

Definition at line 51 of file Color4.h.

const Color4 qsf::Color4::SILVER
static

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

Definition at line 67 of file Color4.h.

const Color4 qsf::Color4::TEAL
static

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

Definition at line 65 of file Color4.h.

const Color4 qsf::Color4::TRANSPARENT
static

0.0, 0.0, 0.0, 0.0

Definition at line 48 of file Color4.h.

const Color4 qsf::Color4::WHITE
static

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

Definition at line 50 of file Color4.h.

const Color4 qsf::Color4::YELLOW
static

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

Definition at line 52 of file Color4.h.


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