OpenStructure
Public Member Functions | Static Public Member Functions
Color Class Reference

#include <color.hh>

Inherits additive< Color >, additive< Color, float >, and multiplicative< Color, float >.

Public Member Functions

 Color ()
 
void SetRGB (float r, float g, float b)
 
geom::Vec3 GetRGB () const
 
geom::Vec4 GetRGBA () const
 
float GetRed () const
 
void SetRed (float)
 
float GetGreen () const
 
void SetGreen (float)
 
float GetBlue () const
 
void SetBlue (float)
 
void SetHSV (float h, float s, float v)
 
geom::Vec3 GetHSV () const
 
geom::Vec4 GetHSVA () const
 
float GetHue () const
 
void SetHue (float)
 
float GetSat () const
 
void SetSat (float)
 
float GetVal () const
 
void SetVal (float)
 
float GetAlpha () const
 
void SetAlpha (float)
 
 operator const float * () const
 
 operator float * ()
 
Coloroperator*= (float rhs)
 
Coloroperator+= (float rhs)
 
Coloroperator+= (const Color &rhs)
 
Coloroperator-= (const Color &rhs)
 
Coloroperator-= (float rhs)
 
Coloroperator/= (float rhs)
 
geom::Vec3 ToHSV () const
 
 Color (float r, float g, float b, float a=1.0)
 
float Red () const
 
float Green () const
 
float Blue () const
 
float Alpha () const
 

Static Public Member Functions

static Color FromRGB (unsigned char r, unsigned char g, unsigned char b, unsigned char a=0xff)
 

Detailed Description

A color is defined in both RGB as well as HSV space, with an additional A component. To initialize a color use the factory functions RGB(r,g,b), RGBA(r,g,b,a), HSV(h,s,v) and HSVA(h,s,v,a)

All values are defined in the range of 0.0 to 1.0, but are not clamped on reading or writing, except when updating cross-domain, i.e. changes to R,G or B cause HSV to be updated accordingly, and vice versa. This may cause previously out-of-bounds values to become clamped or wrapped to the defined domain. An out-of-bounds H will be wrapped to be between 0 and 1, all others will be clamped.

For interaction with OpenGL, an operator float* method exists that return a pointer to a float[4], in the order RGBA

Operator overloading works on the RGB components, i.e. C1+C2, C+s, C*s

Definition at line 52 of file color.hh.

Constructor & Destructor Documentation

◆ Color() [1/2]

Color ( )

initialize to white

◆ Color() [2/2]

Color ( float  r,
float  g,
float  b,
float  a = 1.0 
)

DEPRECATED.

Member Function Documentation

◆ Alpha()

float Alpha ( ) const
inline

DEPRECATED.

Definition at line 140 of file color.hh.

◆ Blue()

float Blue ( ) const
inline

DEPRECATED.

Definition at line 138 of file color.hh.

◆ FromRGB()

static Color FromRGB ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 0xff 
)
inlinestatic

DEPRECATED.

Definition at line 143 of file color.hh.

◆ GetAlpha()

float GetAlpha ( ) const

retrieve alpha

◆ GetBlue()

float GetBlue ( ) const

retrieve blue

◆ GetGreen()

float GetGreen ( ) const

retrieve green

◆ GetHSV()

geom::Vec3 GetHSV ( ) const

convenience to get HSV triplet as Vec3

◆ GetHSVA()

geom::Vec4 GetHSVA ( ) const

convenience to get HSVA as Vec4

◆ GetHue()

float GetHue ( ) const

retrieve hue

◆ GetRed()

float GetRed ( ) const

retrieve red

◆ GetRGB()

geom::Vec3 GetRGB ( ) const

convenience to get RGB triplet as Vec3

◆ GetRGBA()

geom::Vec4 GetRGBA ( ) const

convenience to get RGBA as Vec4

◆ GetSat()

float GetSat ( ) const

retrieve saturatuin

◆ GetVal()

float GetVal ( ) const

retrieve value

◆ Green()

float Green ( ) const
inline

DEPRECATED.

Definition at line 136 of file color.hh.

◆ operator const float *()

operator const float * ( ) const

direct access to RGBA components

In the context of a OpenGL call that requires a pointer to an RGB or RGBA float triplet or quadruplet, this will do the automatic casting from a Color object, i.e. glColor3fv(my_color);

This will also allow access to the RGBA values via the array notation, i.e. my_color[0]

◆ operator float *()

operator float * ( )

◆ operator*=()

Color& operator*= ( float  rhs)

◆ operator+=() [1/2]

Color& operator+= ( const Color rhs)

◆ operator+=() [2/2]

Color& operator+= ( float  rhs)

◆ operator-=() [1/2]

Color& operator-= ( const Color rhs)

◆ operator-=() [2/2]

Color& operator-= ( float  rhs)

◆ operator/=()

Color& operator/= ( float  rhs)

◆ Red()

float Red ( ) const
inline

DEPRECATED.

Definition at line 134 of file color.hh.

◆ SetAlpha()

void SetAlpha ( float  )

set alpha

◆ SetBlue()

void SetBlue ( float  )

set blue

◆ SetGreen()

void SetGreen ( float  )

set green

◆ SetHSV()

void SetHSV ( float  h,
float  s,
float  v 
)

convenience to set HSV triplet (ranges 0-1)

◆ SetHue()

void SetHue ( float  )

set hue

◆ SetRed()

void SetRed ( float  )

set red

◆ SetRGB()

void SetRGB ( float  r,
float  g,
float  b 
)

convenience to set RGB triplet (ranges 0-1)

◆ SetSat()

void SetSat ( float  )

set saturation

◆ SetVal()

void SetVal ( float  )

set value

◆ ToHSV()

geom::Vec3 ToHSV ( ) const
inline

DEPRECATED.

Definition at line 128 of file color.hh.


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