CColor.h Source File

Chapitre 1

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 m_r, m_g, m_b;    // Les trois composantes de la couleur
00014 
00015                 // constructeurs et destructeur
00016                 CColor() : m_r(0), m_g(0), m_b(0) {};
00017                 CColor(float r, float g, float b) : m_r(r), m_g(g), m_b(b) {};
00018                 virtual ~CColor() {};
00019 
00020                 // operateurs
00021                 __forceinline friend CColor operator* (const CColor& c1, const CColor& c2)
00022                 { return CColor(c1.m_r*c2.m_r, c1.m_g*c2.m_g, c1.m_b*c2.m_b); };
00023                 
00024                 __forceinline friend CColor operator* (const CColor& c1, const float multiple)
00025                 { return CColor(c1.m_r*multiple, c1.m_g*multiple, c1.m_b*multiple); };
00026 
00027                 __forceinline friend CColor operator+ (const CColor& c1, const CColor& c2)
00028                 { return CColor(c1.m_r+c2.m_r, c1.m_g+c2.m_g, c1.m_b+c2.m_b); };
00029 
00030                 __forceinline friend void operator+= (CColor& c1, const CColor& c2)
00031                 { c1.m_r += c2.m_r; c1.m_g += c2.m_g; c1.m_b += c2.m_b; };
00032 
00033                 __forceinline friend CColor operator/ (const CColor& c1, float multiple)
00034                 { return CColor(c1.m_r/multiple, c1.m_g/multiple, c1.m_r/multiple); }
00035 
00036                 __forceinline friend void operator/= (CColor& c1, float multiple)
00037                 { c1.m_r /= multiple; c1.m_g /= multiple; c1.m_b /= multiple; }
00038 
00039                 // main methods
00040                 __forceinline void NormalizeColor()     { if (m_r>1.0f) m_r = 1.0f; if (m_g>1.0f) m_g = 1.0f; if (m_b>1.0f) m_b = 1.0f; }
00041 };
00042 
00043 #endif /* #ifndef __CCOLOR_H__ */

Generated on Thu Apr 4 23:14:17 2002 by doxygen1.2.15