Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

cscolor.h

00001 /*
00002     Copyright (C) 1998-2001 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000