28 #include <boost/operators.hpp>
33 namespace ost {
namespace gfx {
53 private boost::additive<Color>,
54 private boost::additive<Color, float>,
55 private boost::multiplicative<Color, float>{
62 void SetRGB(
float r,
float g,
float b);
80 void SetHSV(
float h,
float s,
float v);
114 operator const float* ()
const;
131 Color(
float r,
float g,
float b,
float a=1.0);
134 float Red()
const {
return GetRed();}
136 float Green()
const {
return GetGreen();}
138 float Blue()
const {
return GetBlue();}
140 float Alpha()
const {
return GetAlpha();}
144 unsigned char b,
unsigned char a = 0xff) {
145 static float f=1.0/255.0;
146 return Color(f*
static_cast<float>(r),f*
static_cast<float>(g),
147 f*
static_cast<float>(b),f*
static_cast<float>(a));
156 mutable float rgba_[4];
157 mutable float hsv_[3];
158 mutable bool rgb_dirty_;
159 mutable bool hsv_dirty_;
Three dimensional vector class, using Real precision.
float Blue() const
DEPRECATED.
Color & operator/=(float rhs)
void SetGreen(float)
set green
void SetVal(float)
set value
Color & operator*=(float rhs)
Color()
initialize to white
float GetRed() const
retrieve red
void SetBlue(float)
set blue
static Color FromRGB(unsigned char r, unsigned char g, unsigned char b, unsigned char a=0xff)
DEPRECATED.
float Green() const
DEPRECATED.
Color(float r, float g, float b, float a=1.0)
DEPRECATED.
float Red() const
DEPRECATED.
Color & operator+=(float rhs)
geom::Vec4 GetHSVA() const
convenience to get HSVA as Vec4
void SetHSV(float h, float s, float v)
convenience to set HSV triplet (ranges 0-1)
float GetVal() const
retrieve value
geom::Vec3 GetHSV() const
convenience to get HSV triplet as Vec3
float GetSat() const
retrieve saturatuin
void SetHue(float)
set hue
void SetSat(float)
set saturation
float GetAlpha() const
retrieve alpha
geom::Vec3 ToHSV() const
DEPRECATED.
geom::Vec3 GetRGB() const
convenience to get RGB triplet as Vec3
float GetHue() const
retrieve hue
void SetRed(float)
set red
void SetRGB(float r, float g, float b)
convenience to set RGB triplet (ranges 0-1)
float GetBlue() const
retrieve blue
float Alpha() const
DEPRECATED.
Color & operator-=(float rhs)
geom::Vec4 GetRGBA() const
convenience to get RGBA as Vec4
Color & operator+=(const Color &rhs)
Color & operator-=(const Color &rhs)
float GetGreen() const
retrieve green
void SetAlpha(float)
set alpha
#define DLLEXPORT_OST_GFX
Color DLLEXPORT_OST_GFX HSVAi(int h, int s, int v, int a)
HSVA color spec from integers.
Color DLLEXPORT_OST_GFX RGBi(unsigned int r, unsigned int g, unsigned int b)
RGB color spec from integers (0-65535)
Color DLLEXPORT_OST_GFX RGB(float r, float g, float b)
RGB color spec from floats (0.0-1.0)
Color DLLEXPORT_OST_GFX RGBA(float r, float g, float b, float a)
RGBA color spec from floats (0.0-1.0)
DLLEXPORT_OST_GFX std::ostream & operator<<(std::ostream &, const Color &c)
string form
Color DLLEXPORT_OST_GFX HSVi(int h, int s, int v)
HSV color spec from integers.
Color DLLEXPORT_OST_GFX HSV(float h, float s, float v)
HSV color spec from floats.
Color DLLEXPORT_OST_GFX RGBAb(uchar r, uchar g, uchar b, uchar a)
RGBA color spec from bytes (0-255)
Color DLLEXPORT_OST_GFX RGBAi(unsigned int r, unsigned int g, unsigned int b, unsigned int a)
RGBA color spec from integers (0-65535)
Color DLLEXPORT_OST_GFX HSVA(float h, float s, float v, float a)
HSVA color spec from floats.
Color DLLEXPORT_OST_GFX RGBb(uchar r, uchar g, uchar b)
RGB color spec from bytes (0-255)