CColor.h Source File

Chapitre 2

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CColor.h

00001 
00007 #ifndef __CCOLOR_H__
00008 #define __CCOLOR_H__
00009 
00010 class CColor
00011 {
00012         public:
00013                 float mR, mG, mB;       // Les trois composantes de la couleur
00014 
00015                 // constructeurs et destructeur
00016                 CColor() : mR(0), mG(0), mB(0) {};
00017                 CColor(float r, float g, float b) : mR(r), mG(g), mB(b) {};
00018                 virtual ~CColor() {};
00019 
00020                 // operateurs
00021                 __forceinline friend CColor operator* (const CColor& c1, const CColor& c2)
00022                 { return CColor(c1.mR*c2.mR, c1.mG*c2.mG, c1.mB*c2.mB); };
00023                 
00024                 __forceinline friend CColor operator* (const CColor& c1, const float multiple)
00025                 { return CColor(c1.mR*multiple, c1.mG*multiple, c1.mB*multiple); };
00026 
00027                 __forceinline friend CColor operator+ (const CColor& c1, const CColor& c2)
00028                 { return CColor(c1.mR+c2.mR, c1.mG+c2.mG, c1.mB+c2.mB); };
00029 
00030                 __forceinline friend void operator+= (CColor& c1, const CColor& c2)
00031                 { c1.mR += c2.mR; c1.mG += c2.mG; c1.mB += c2.mB; };
00032 
00033                 __forceinline friend CColor operator/ (const CColor& c1, float multiple)
00034                 { return CColor(c1.mR/multiple, c1.mG/multiple, c1.mB/multiple); }
00035 
00036                 __forceinline friend void operator/= (CColor& c1, float multiple)
00037                 { c1.mR /= multiple; c1.mG /= multiple; c1.mB /= multiple; }
00038 
00039                 // main methods
00040                 __forceinline void NormalizeColor()     { if (mR>1.0f) mR = 1.0f; if (mG>1.0f) mG = 1.0f; if (mB>1.0f) mB = 1.0f; }
00041 };
00042 
00043 #endif /* #ifndef __CCOLOR_H__ */

Generated on Fri Apr 19 16:19:33 2002 by doxygen1.2.15