Color.h

Go to the documentation of this file.
00001 #ifndef COLOR_H_
00002 #define COLOR_H_
00003 
00008 class Color {
00009         public:
00010                 typedef unsigned char ColorUnit;
00011                 static const ColorUnit maxChannelValue = 255;
00012 
00013                 Color(ColorUnit R, ColorUnit G, ColorUnit B, ColorUnit A = maxChannelValue) :
00014                         mR(R), mG(G), mB(B), mA(A) {}
00015 
00016                 void set(ColorUnit R, ColorUnit G, ColorUnit B, ColorUnit A) {
00017                         mR = R;
00018                         mG = G;
00019                         mB = B;
00020                         mA = A;
00021                 }
00022 
00023                 ColorUnit R() const { return mR; }
00024                 ColorUnit G() const { return mG; }
00025                 ColorUnit B() const { return mB; }
00026                 ColorUnit A() const { return mA; }
00027 
00028                 void setR(ColorUnit r) {mR = r;}
00029                 void setG(ColorUnit g) {mG = g;}
00030                 void setB(ColorUnit b) {mB = b;}
00031                 void setA(ColorUnit a) {mA = a;}
00032 
00033                 Color operator *=(float v) {
00034                 //precondition: 0 <= v <= 1
00035                         mR = ColorUnit( mR * v);
00036                         mG = ColorUnit( mG * v);
00037                         mB = ColorUnit( mB * v);
00038                         mA = ColorUnit( mA * v);
00039                         return *this;
00040                 }
00041 
00042                 Color operator*(float v) const {
00043                 //precondition: 0 <= v <= 1
00044                         Color r(*this);
00045                         return r *= v;
00046                 }
00047 
00048                 bool opaque() const { return mA == maxChannelValue; }
00049 
00050         private:
00051                 ColorUnit mR, mG, mB, mA;
00052 };
00053 
00054 #endif

Generated on Mon Jan 23 19:44:27 2006 for Visualization by  doxygen 1.4.6