Main Page | File List

RGB.h

Go to the documentation of this file.
00001 /**
00002  *\file         RGB.h
00003  *
00004  *\brief        RGB class wrapping pixel color-triple: red, green, and blue. 
00005  *
00006  *              Each rgb component is of a float value in [<b><var>0.0, 1.0</var></b>].
00007  *
00008  */
00009 
00010 
00011 #ifndef _RGB_H
00012 #define _RGB_H
00013 
00014 
00015 
00016 namespace columbia
00017 {
00018   class RGB
00019   {
00020       float rgb[3];
00021 
00022   public:
00023       RGB(float r=0., float b=0., float g=0.)  { rgb[0] = r; rgb[1] = g; rgb[2] = b; }
00024 
00025       float& operator[](int idx)               { return *(rgb+idx); }   //non const method: return lvalue
00026       float operator[](int idx) const          { return *(rgb+idx); }   //const method: return rvalue
00027 
00028       RGB& operator*=(float scale)             { for(int i=0; i<3; i++) rgb[i] *= scale; return *this; }
00029       RGB operator*(float scale) const         { RGB ret(*this); return ret *= scale; }
00030   };
00031 
00032 
00033 
00034 }//end namespace columbia
00035 
00036 
00037 #endif

Generated on Mon Jul 5 16:47:12 2004 by doxygen 1.3.6