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();}
143 static Color FromRGB(
unsigned char r,
unsigned char g,
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_;