|
OpenStructure
|
#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 * () | |
| Color & | operator*= (float rhs) |
| Color & | operator+= (float rhs) |
| Color & | operator+= (const Color &rhs) |
| Color & | operator-= (const Color &rhs) |
| Color & | operator-= (float rhs) |
| Color & | operator/= (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) |
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
| Color | ( | ) |
initialize to white
| Color | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float | a = 1.0 |
||
| ) |
DEPRECATED.
|
inlinestatic |
| 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
| 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+= | ( | float | rhs | ) |
| Color & operator-= | ( | float | rhs | ) |
| Color & operator/= | ( | float | rhs | ) |
| 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
|
inline |