#ifndef __COLOR_H__ #define __COLOR_H__ #include // @@@@@@@@@@@@@@@@@@@@@ Color3 class @@@@@@@@@@@@@@@@ class Color3 { // holds an red,green,blue 3-tuple public: float red, green, blue; Color3(){red = green = blue = 0;} Color3(float r, float g, float b){red = r; green = g; blue = b;} Color3(Color3& c){red = c.red; green = c.green; blue = c.blue;} void set(float r, float g, float b){red = r; green = g; blue = b;} void set(Color3& c) {red = c.red; green = c.green; blue = c.blue;} void add(float r, float g, float b) {red += r; green += g; blue += b;} void add(Color3& src, Color3& refl) { // add the product of source color and reflection coefficient red += src.red * refl.red; green += src.green * refl.green; blue += src.blue * refl.blue; } void add(Color3& colr) { // add colr to this color red += colr.red ; green += colr.green; blue += colr.blue;} void build4tuple(float v[]) {// load 4-tuple with this color: v[3] = 1 for homogeneous v[0] = red; v[1] = green; v[2] = blue; v[3] = 1.0f; } // I/O methods friend istream& operator>>(istream& in, Color3& c) { in >> c.red >> c.green >> c.blue; return in; } friend ostream& operator<<(ostream& out, const Color3& c) { out << c.red << " " << c.green << " " << c.blue << " "; return out; } }; #endif