Color Class Reference

#include <color.hh>

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 (  ) 

initialize to white

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

DEPRECATED.


Member Function Documentation

float Alpha (  )  const [inline]

DEPRECATED.

Definition at line 140 of file color.hh.

float Blue (  )  const [inline]

DEPRECATED.

Definition at line 138 of file color.hh.

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

DEPRECATED.

Definition at line 143 of file color.hh.

float GetAlpha (  )  const

retrieve alpha

float GetBlue (  )  const

retrieve blue

float GetGreen (  )  const

retrieve green

geom::Vec3 GetHSV (  )  const

convenience to get HSV triplet as Vec3

geom::Vec4 GetHSVA (  )  const

convenience to get HSVA as Vec4

float GetHue (  )  const

retrieve hue

float GetRed (  )  const

retrieve red

geom::Vec3 GetRGB (  )  const

convenience to get RGB triplet as Vec3

geom::Vec4 GetRGBA (  )  const

convenience to get RGBA as Vec4

float GetSat (  )  const

retrieve saturatuin

float GetVal (  )  const

retrieve value

float Green (  )  const [inline]

DEPRECATED.

Definition at line 136 of file color.hh.

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 * (  ) 
Color& operator*= ( float  rhs  ) 
Color& operator+= ( const Color rhs  ) 
Color& operator+= ( float  rhs  ) 
Color& operator-= ( float  rhs  ) 
Color& operator-= ( const Color rhs  ) 
Color& operator/= ( float  rhs  ) 
float Red (  )  const [inline]

DEPRECATED.

Definition at line 134 of file color.hh.

void SetAlpha ( float   ) 

set alpha

void SetBlue ( float   ) 

set blue

void SetGreen ( float   ) 

set green

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

convenience to set HSV triplet (ranges 0-1)

void SetHue ( float   ) 

set hue

void SetRed ( float   ) 

set red

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

convenience to set RGB triplet (ranges 0-1)

void SetSat ( float   ) 

set saturation

void SetVal ( float   ) 

set value

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:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated on 1 Mar 2018 for OpenStructure by  doxygen 1.6.1