28 #include <boost/operators.hpp>
33 namespace ost {
namespace gfx {
37 private boost::additive<Color>,
38 private boost::additive<Color, float>,
39 private boost::multiplicative<Color, float>{
48 Color(
float r,
float g,
float b,
float a=1.0) {
55 float&
Red() {
return rgba[0];}
56 const float&
Red()
const {
return rgba[0];}
57 float&
Green() {
return rgba[1];}
58 const float&
Green()
const {
return rgba[1];}
59 float&
Blue() {
return rgba[2];}
60 const float&
Blue()
const {
return rgba[2];}
61 float&
Alpha() {
return rgba[3];}
62 const float&
Alpha()
const {
return rgba[3];}
64 static Color FromRGB(
unsigned char r,
unsigned char g,
65 unsigned char b,
unsigned char a = 0xff) {
66 static float f=1.0/255.0;
67 return Color(f*static_cast<float>(r),f*static_cast<float>(g),
68 f*static_cast<float>(b),f*static_cast<float>(a));
74 operator float* () {
return rgba;}
75 operator const float* ()
const {
return rgba;}
77 Color& operator*=(
float rhs);
78 Color& operator+=(
float rhs);
82 Color& operator-=(
float rhs);
83 Color& operator/=(
float rhs);