32 #ifndef PLANCK_COLOUR_H 33 #define PLANCK_COLOUR_H 37 template<
typename T>
class RGB_tuple
43 RGB_tuple (T rv, T gv, T bv)
44 : r (rv), g (gv), b (bv) {}
45 template<
typename T2>
explicit RGB_tuple (
const RGB_tuple<T2> &orig)
46 : r(orig.r), g(orig.g), b(orig.b) {}
48 const RGB_tuple &operator= (
const RGB_tuple &Col2)
49 { r=Col2.r; g=Col2.g; b=Col2.b;
return *
this; }
50 const RGB_tuple &operator+= (
const RGB_tuple &Col2)
51 { r+=Col2.r; g+=Col2.g; b+=Col2.b;
return *
this; }
52 const RGB_tuple &operator*= (T fac)
53 { r*=fac; g*=fac; b*=fac;
return *
this; }
54 RGB_tuple operator+ (
const RGB_tuple &Col2)
const 55 {
return RGB_tuple (r+Col2.r, g+Col2.g, b+Col2.b); }
56 RGB_tuple operator- (
const RGB_tuple &Col2)
const 57 {
return RGB_tuple (r-Col2.r, g-Col2.g, b-Col2.b); }
58 template<
typename T2> RGB_tuple operator* (T2 factor)
const 59 {
return RGB_tuple (r*factor, g*factor, b*factor); }
60 template<
typename T2>
friend inline RGB_tuple operator* (T2 factor,
62 {
return RGB_tuple (Col.r*factor, Col.g*factor, Col.b*factor); }
64 void Set (T r2, T g2, T b2)
67 friend std::ostream &operator<< (std::ostream &os,
const RGB_tuple &c)
69 os <<
"(" << c.r <<
", " << c.g <<
", " << c.b <<
")";
74 typedef RGB_tuple<float> Colour;