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);
72 float GetGreen()
const;
76 float GetBlue()
const;
80 void SetHSV(
float h,
float s,
float v);
98 float GetAlpha()
const;
100 void SetAlpha(
float);
114 operator const float* ()
const;
117 Color& operator*=(
float rhs);
118 Color& operator+=(
float rhs);
122 Color& operator-=(
float rhs);
123 Color& operator/=(
float rhs);
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_;
Color DLLEXPORT_OST_GFX HSV(float h, float s, float v)
HSV color spec from floats.
Color DLLEXPORT_OST_GFX RGBi(unsigned int r, unsigned int g, unsigned int b)
RGB color spec from integers (0-65535)
float Blue() const
DEPRECATED.
geom::Vec3 ToHSV() const
DEPRECATED.
Color DLLEXPORT_OST_GFX HSVA(float h, float s, float v, float a)
HSVA color spec from floats.
float Green() const
DEPRECATED.
Color DLLEXPORT_OST_GFX RGB(float r, float g, float b)
RGB color spec from floats (0.0-1.0)
#define DLLEXPORT_OST_GFX
float Alpha() const
DEPRECATED.
Color DLLEXPORT_OST_GFX HSVAi(int h, int s, int v, int a)
HSVA color spec from integers.
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 RGBA(float r, float g, float b, float a)
RGBA color spec from floats (0.0-1.0)
Color DLLEXPORT_OST_GFX RGBAb(uchar r, uchar g, uchar b, uchar a)
RGBA color spec from bytes (0-255)
Three dimensional vector class, using Real precision.
Color DLLEXPORT_OST_GFX RGBb(uchar r, uchar g, uchar b)
RGB color spec from bytes (0-255)
Color DLLEXPORT_OST_GFX HSVi(int h, int s, int v)
HSV color spec from integers.
static Color FromRGB(unsigned char r, unsigned char g, unsigned char b, unsigned char a=0xff)
DEPRECATED.
float Red() const
DEPRECATED.
DLLEXPORT_OST_GFX std::ostream & operator<<(std::ostream &, const Color &c)
string form