00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CSCOLOR_H__
00020 #define __CSCOLOR_H__
00021
00027 class csColor
00028 {
00029 public:
00031 float red;
00033 float green;
00035 float blue;
00036
00037 public:
00039 csColor () { }
00041 csColor (float r, float g, float b)
00042 { red = r; green = g; blue = b; }
00044 csColor (const csColor& c)
00045 { red = c.red; green = c.green; blue = c.blue; }
00047 void Set (float r, float g, float b)
00048 { red = r; green = g; blue = b; }
00050 void Clamp (float r, float g, float b)
00051 {
00052 if (red > r) red = r;
00053 if (green > g) green = g;
00054 if (blue > b) blue = b;
00055 }
00057 void ClampDown ()
00058 {
00059 if (red < 0) red = 0;
00060 if (green < 0) green = 0;
00061 if (blue < 0) blue = 0;
00062 }
00064 csColor& operator= (const csColor& c)
00065 { red = c.red; green = c.green; blue = c.blue; return *this; }
00067 csColor& operator*= (float f)
00068 { red *= f; green *= f; blue *= f; return *this; }
00070 csColor& operator+= (const csColor& c)
00071 { red += c.red; green += c.green; blue += c.blue; return *this; }
00073 csColor& operator-= (const csColor& c)
00074 { red -= c.red; green -= c.green; blue -= c.blue; return *this; }
00076 void Add (float r, float g, float b)
00077 { red += r; green += g; blue += b; }
00079 void Subtract (float r, float g, float b)
00080 { red -= r; green -= g; blue -= b; }
00081 };
00082
00084 inline csColor operator* (const csColor& s, float f)
00085 { csColor c (s); c *= f; return c; }
00086
00088 inline csColor operator* (float f, const csColor& s)
00089 { csColor c (s); c *= f; return c; }
00090
00092 inline csColor operator+ (const csColor& s1, const csColor& s2)
00093 { csColor c (s1); c += s2; return c; }
00095 inline csColor operator- (const csColor& s1, const csColor& s2)
00096 { csColor c (s1); c -= s2; return c; }
00097
00098 #endif // __CSCOLOR_H__