xsi_color4f.h

Go to the documentation of this file.
00001 //*****************************************************************************
00011 //*****************************************************************************
00012 
00013 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00014 #pragma once
00015 #endif
00016 
00017 #ifndef __XSICOLOR4F_H__
00018 #define __XSICOLOR4F_H__
00019 
00020 #include "sicppsdk.h"
00021 #include <math.h>
00022 
00023 namespace XSI {
00024 
00025 namespace MATH {
00026 
00027 //*****************************************************************************
00032 //*****************************************************************************
00033 class CColor4f
00034 {
00035 public:
00038     enum Type
00039     {
00040         siRGBA,
00041         siHSVA,
00042         siHLSA,
00043     };
00044 
00051     SICPPSDK_INLINE CColor4f(float in_R = 0, float in_G = 0, float in_B = 0, float in_A = 0);
00052 
00060     SICPPSDK_INLINE CColor4f(float in_Arg1, float in_Arg2, float in_Arg3, float in_A, Type in_eColorType );
00061 
00065     SICPPSDK_INLINE CColor4f( const CColor4f& in_color );
00066 
00068     ~CColor4f() {};
00069 
00076     SICPPSDK_INLINE void Set(float in_R,float in_G,float in_B,float in_A);
00077 
00085     SICPPSDK_INLINE void Set( float in_Arg1, float in_Arg2, float in_Arg3, float in_A, Type in_eColorType );
00086 
00091     SICPPSDK_INLINE float& PutR( const float in_R );
00092 
00097     SICPPSDK_INLINE float& PutG( const float in_G );
00098 
00103     SICPPSDK_INLINE float& PutB( const float in_B );
00104 
00109     SICPPSDK_INLINE float& PutA( const float in_A );
00110 
00117     SICPPSDK_INLINE void GetAsRGBA( float &out_R, float &out_G, float &out_B, float &out_A ) const;
00118 
00125     SICPPSDK_INLINE void GetAsHLSA( float &out_H, float &out_L, float &out_S, float &out_A ) const;
00126 
00133     SICPPSDK_INLINE void GetAsHSVA( float &out_H, float &out_S, float &out_V, float &out_A) const;
00134 
00138     SICPPSDK_INLINE float GetH() const;
00139 
00143     SICPPSDK_INLINE float GetL() const;
00144 
00148     SICPPSDK_INLINE float GetS_HSVA() const;
00149 
00153     SICPPSDK_INLINE float GetS_HLSA() const;
00154 
00158     SICPPSDK_INLINE float GetV() const;
00159 
00163     SICPPSDK_INLINE float& GetR();
00164 
00168     SICPPSDK_INLINE float& GetG();
00169 
00173     SICPPSDK_INLINE float& GetB();
00174 
00178     SICPPSDK_INLINE float& GetA();
00179 
00183     SICPPSDK_INLINE float* GetRGBA();
00184 
00188     SICPPSDK_INLINE const float& GetR()const;
00189 
00193     SICPPSDK_INLINE const float& GetG()const;
00194 
00198     SICPPSDK_INLINE const float& GetB()const;
00199 
00203     SICPPSDK_INLINE const float& GetA()const;
00204 
00208     SICPPSDK_INLINE const float* GetRGBA()const;
00209 
00213     SICPPSDK_INLINE operator float*();
00214 
00218     SICPPSDK_INLINE bool operator==(const CColor4f& in_rColor4f )const;
00219 
00223     SICPPSDK_INLINE bool operator!=(const CColor4f& in_rColor4f )const ;
00224 
00232     SICPPSDK_INLINE bool operator < (const CColor4f& in_rColor4f )const;
00233 
00238     SICPPSDK_INLINE bool IsNull(float in_fEpsilon) const;
00239 
00244     SICPPSDK_INLINE CColor4f& Add(const CColor4f& in_col);
00245 
00250     SICPPSDK_INLINE CColor4f& Mul(float in_fFactor);
00251 
00256     SICPPSDK_INLINE CColor4f& Mul( const CColor4f& in_col );
00257 
00262     SICPPSDK_INLINE CColor4f& Sub( const CColor4f& in_col );
00263 
00267     SICPPSDK_INLINE CColor4f& Negate();
00268 
00272     SICPPSDK_INLINE void PutNull();
00273 
00277     SICPPSDK_INLINE float GetBrightness()const;
00278 
00282     SICPPSDK_INLINE float GetBrightnessWithAlpha()const;
00283 
00287     SICPPSDK_INLINE float GetGrayscale()const;
00288 
00292     SICPPSDK_INLINE float GetGrayscaleWithAlpha()const;
00293 
00297     SICPPSDK_INLINE CColor4f& InverseRGB();
00298 
00299     private:
00300     SICPPSDK_INLINE LONG RoundDown(float a) const;
00301     SICPPSDK_INLINE void MinMax( float& out_fMin, float& out_fMax ) const;
00302     SICPPSDK_INLINE bool AreAlmostEqual(const CColor4f& in_c1,const CColor4f& in_c2,const float in_fEpsilon = MicroEPS);
00303 
00304     enum Component
00305     {
00306         R=0,G,B,A,N
00307     };
00308     float m_RGBA[4];
00309 };
00310 
00311 SICPPSDK_INLINE CColor4f::CColor4f(float in_R, float in_G, float in_B, float in_A)
00312 {
00313     m_RGBA[R] = in_R;
00314     m_RGBA[G] = in_G;
00315     m_RGBA[B] = in_B;
00316     m_RGBA[A] = in_A;
00317 }
00318 
00319 SICPPSDK_INLINE CColor4f::CColor4f(float in_Arg1, float in_Arg2, float in_Arg3, float in_A, Type in_eColorType )
00320 {
00321     Set( in_Arg1, in_Arg2, in_Arg3, in_A, in_eColorType );
00322 }
00323 
00324 SICPPSDK_INLINE CColor4f::CColor4f( const CColor4f& in_color )
00325 {
00326     const float* pRGBA = in_color.GetRGBA();
00327     if (pRGBA)
00328     {
00329         Set( pRGBA[R], pRGBA[G], pRGBA[B], pRGBA[A], siRGBA );
00330     }
00331 }
00332 
00333 SICPPSDK_INLINE void CColor4f::Set(float in_R,float in_G,float in_B,float in_A)
00334 {
00335     GetR()=in_R;
00336     GetG()=in_G;
00337     GetB()=in_B;
00338     GetA()=in_A;
00339 }
00340 
00341 SICPPSDK_INLINE float& CColor4f::PutR( const float in_R ){return m_RGBA[R] = in_R;}
00342 SICPPSDK_INLINE float& CColor4f::PutG( const float in_G ){return m_RGBA[G] = in_G;}
00343 SICPPSDK_INLINE float& CColor4f::PutB( const float in_B ){return m_RGBA[B] = in_B;}
00344 SICPPSDK_INLINE float& CColor4f::PutA( const float in_A ){return m_RGBA[A] = in_A;}
00345 
00346 SICPPSDK_INLINE void CColor4f::Set( float in_Arg1, float in_Arg2, float in_Arg3, float in_A, Type in_eColorType )
00347 {
00348     m_RGBA[A] = in_A;
00349 
00350     switch( in_eColorType )
00351     {
00352         case siRGBA:
00353         {
00354             m_RGBA[R] = in_Arg1;
00355             m_RGBA[G] = in_Arg2;
00356             m_RGBA[B] = in_Arg3;
00357             break;
00358         }
00359         case siHSVA:
00360         {
00361             if (in_Arg2 == 0.0)
00362             {
00363                 m_RGBA[R] = in_Arg3;
00364                 m_RGBA[G] = in_Arg3;
00365                 m_RGBA[B] = in_Arg3;
00366             }
00367             else
00368             {
00369                 in_Arg1 *= (float)( 360.0/60.0 );
00370 
00371                 ULONG  l_ulHueI = (ULONG)RoundDown(in_Arg1);
00372                 float l_fHueF = in_Arg1 - l_ulHueI;
00373 
00374                 float l_fP = in_Arg3 * (1.0f - in_Arg2);
00375                 float l_fQ = in_Arg3 * (1.0f - (in_Arg2*l_fHueF));
00376                 float l_fT = in_Arg3 * (1.0f - (in_Arg2*(1.0f-l_fHueF)));
00377 
00378                 switch (l_ulHueI)
00379                 {
00380                     case 0 :
00381                     case 6 : m_RGBA[R] = in_Arg3; m_RGBA[G] = l_fT; m_RGBA[B] = l_fP;
00382                         break;
00383                     case 1 : m_RGBA[R] = l_fQ; m_RGBA[G] = in_Arg3; m_RGBA[B] = l_fP;
00384                         break;
00385                     case 2 : m_RGBA[R] = l_fP; m_RGBA[G] = in_Arg3; m_RGBA[B] = l_fT;
00386                         break;
00387                     case 3 : m_RGBA[R] = l_fP; m_RGBA[G] = l_fQ; m_RGBA[B] = in_Arg3;
00388                         break;
00389                     case 4 : m_RGBA[R] = l_fT; m_RGBA[G] = l_fP; m_RGBA[B] = in_Arg3;
00390                         break;
00391                     case 5 : m_RGBA[R] = in_Arg3; m_RGBA[G] = l_fP; m_RGBA[B] = l_fQ;
00392                         break;
00393                 }
00394             }
00395 
00396             break;
00397         }
00398         case siHLSA:
00399         {
00400             float l_fMax;
00401 
00402             if (in_Arg2 <= 0.5)
00403                 l_fMax = in_Arg2 * (1.0f + in_Arg3);
00404             else
00405                 l_fMax = in_Arg2 + in_Arg3 - (in_Arg2 * in_Arg3);
00406 
00407             if (l_fMax == 0.0f)
00408             {
00409                 m_RGBA[R] = m_RGBA[G] = m_RGBA[B] = 0.0f;
00410             }
00411             else
00412             {
00413                 in_Arg1 *= (float)( 360.0/60.0 );
00414 
00415                 ULONG l_ulHueI = (ULONG)RoundDown(in_Arg1);
00416                 float l_fHueF = in_Arg1 - l_ulHueI;
00417 
00418                 float l_fMin  = 2.0f*in_Arg2 - l_fMax;
00419                 float l_fQ    = l_fMax - ((l_fMax-l_fMin)*l_fHueF);
00420                 float l_fT    = l_fMin + ((l_fMax-l_fMin)*l_fHueF);
00421 
00422                 switch (l_ulHueI)
00423                 {
00424                     case 0 :
00425                     case 6 : m_RGBA[R] = l_fMax; m_RGBA[G] = l_fT; m_RGBA[B] = l_fMin;
00426                         break;
00427                     case 1 : m_RGBA[R] = l_fQ; m_RGBA[G] = l_fMax; m_RGBA[B] = l_fMin;
00428                         break;
00429                     case 2 : m_RGBA[R] = l_fMin; m_RGBA[G] = l_fMax; m_RGBA[B] = l_fT;
00430                         break;
00431                     case 3 : m_RGBA[R] = l_fMin; m_RGBA[G] = l_fQ; m_RGBA[B] = l_fMax;
00432                         break;
00433                     case 4 : m_RGBA[R] = l_fT; m_RGBA[G] = l_fMin; m_RGBA[B] = l_fMax;
00434                         break;
00435                     case 5 : m_RGBA[R] = l_fMax; m_RGBA[G] = l_fMin; m_RGBA[B] = l_fQ;
00436                         break;
00437                 }
00438             }
00439             break;
00440         }
00441         default:
00442             assert( false );
00443     }
00444 }
00445 
00446 SICPPSDK_INLINE void CColor4f::GetAsRGBA( float &out_fRed, float &out_fGreen, float &out_fBlue, float &out_fAlpha ) const
00447 {
00448     out_fRed = m_RGBA[R]; out_fGreen = m_RGBA[G]; out_fBlue = m_RGBA[B]; out_fAlpha = m_RGBA[A];
00449 }
00450 
00451 SICPPSDK_INLINE void CColor4f::GetAsHLSA( float &out_fHue, float &out_fLuminance, float &out_fSaturation, float &out_fAlpha ) const
00452 {
00453     out_fAlpha = m_RGBA[A];
00454 
00455     float l_fMax , l_fMin;
00456     MinMax( l_fMin, l_fMax );
00457     float l_fDelta = l_fMax - l_fMin;
00458 
00459     out_fLuminance = (l_fMin + l_fMax) / 2.0f;
00460 
00461     if (l_fDelta == 0.0)
00462         out_fSaturation = 0.0;
00463     else
00464     {
00465         if (out_fLuminance <= 0.5f)
00466             out_fSaturation = l_fDelta / (l_fMin + l_fMax);
00467         else
00468             out_fSaturation = l_fDelta / (2.0f - (l_fMin + l_fMax));
00469     }
00470 
00471     if (out_fSaturation == 0.0f)
00472         out_fHue = 0;
00473     else
00474     {
00475         if (m_RGBA[R] == l_fMax)
00476             out_fHue = (m_RGBA[G]-m_RGBA[B])/l_fDelta;
00477         else if (m_RGBA[G] == l_fMax)
00478             out_fHue = 2+(m_RGBA[B]-m_RGBA[R])/l_fDelta;
00479         else
00480             out_fHue = 4+(m_RGBA[R]-m_RGBA[G])/l_fDelta;
00481 
00482         out_fHue *= 60;
00483 
00484         if (out_fHue < 0)
00485             out_fHue += 360.0;
00486 
00487         out_fHue = out_fHue / 360.0f;
00488     }
00489 }
00490 
00491 SICPPSDK_INLINE void CColor4f::GetAsHSVA( float &out_fHue, float &out_fSaturation, float &out_fValue, float &out_fAlpha ) const
00492 {
00493     out_fAlpha = m_RGBA[A];
00494 
00495     float l_fMax , l_fMin;
00496     MinMax( l_fMin, l_fMax );
00497     float l_fDelta = l_fMax - l_fMin;
00498 
00499     out_fValue = l_fMax;
00500 
00501     if (l_fMax == 0.0)
00502         out_fSaturation = 0.0;
00503     else
00504         out_fSaturation = l_fDelta/l_fMax;
00505 
00506     if (out_fSaturation == 0.0)
00507     {
00508         out_fHue = 0;
00509     }
00510     else
00511     {
00512         if (m_RGBA[R] == l_fMax)
00513             out_fHue = (m_RGBA[G]-m_RGBA[B])/l_fDelta;
00514         else if (m_RGBA[G] == l_fMax)
00515             out_fHue = 2+(m_RGBA[B]-m_RGBA[R])/l_fDelta;
00516         else
00517             out_fHue = 4+(m_RGBA[R]-m_RGBA[G])/l_fDelta;
00518 
00519         out_fHue *= 60;
00520 
00521         if (out_fHue < 0)
00522             out_fHue += 360.0;
00523 
00524         out_fHue = out_fHue / 360.0f;
00525     }
00526 
00527 }
00528 
00529 SICPPSDK_INLINE float CColor4f::GetH() const
00530 {
00531     float l_fMax , l_fMin;
00532     MinMax( l_fMin, l_fMax );
00533     float l_fDelta = l_fMax - l_fMin;
00534 
00535     if (l_fMax == 0.0f || l_fDelta == 0.0f)
00536     {
00537         return 0.0f;
00538     }
00539     else
00540     {
00541         float l_fHue;
00542         if (m_RGBA[R] == l_fMax)
00543             l_fHue = (m_RGBA[G]-m_RGBA[B])/l_fDelta;
00544         else if (m_RGBA[G] == l_fMax)
00545             l_fHue = 2+(m_RGBA[B]-m_RGBA[R])/l_fDelta;
00546         else
00547             l_fHue = 4+(m_RGBA[R]-m_RGBA[G])/l_fDelta;
00548 
00549         l_fHue *= 60;
00550 
00551         if (l_fHue < 0)
00552             l_fHue += 360.0;
00553 
00554         l_fHue = l_fHue / 360.0f;
00555 
00556         return l_fHue;
00557     }
00558 }
00559 
00560 SICPPSDK_INLINE float CColor4f::GetL() const
00561 {
00562     float l_fMax , l_fMin;
00563     MinMax( l_fMin, l_fMax );
00564 
00565     return (l_fMin + l_fMax) / 2.0f;
00566 }
00567 
00568 SICPPSDK_INLINE float CColor4f::GetS_HSVA() const
00569 {
00570     float l_fMax , l_fMin;
00571     MinMax( l_fMin, l_fMax );
00572     float l_fDelta = l_fMax - l_fMin;
00573 
00574     // calculate Saturation
00575     if (l_fMax == 0.0)
00576         return 0.0;
00577     else
00578         return l_fDelta / l_fMax;
00579 }
00580 
00581 SICPPSDK_INLINE float CColor4f::GetS_HLSA() const
00582 {
00583     float l_fMax , l_fMin;
00584     MinMax( l_fMin, l_fMax );
00585     float l_fDelta = l_fMax - l_fMin;
00586 
00587     // calculate Saturation
00588     if (l_fDelta == 0.0)
00589         return 0.0;
00590     else
00591     {
00592         float l_fSumMinMax = l_fMin + l_fMax ;
00593         if ( l_fSumMinMax <= 1.0f )
00594             return l_fDelta / l_fSumMinMax;
00595         else
00596             return l_fDelta / (2.0f - l_fSumMinMax);
00597     }
00598 }
00599 
00600 SICPPSDK_INLINE float CColor4f::GetV() const
00601 {
00602     if( m_RGBA[R] > m_RGBA[G] )
00603     {
00604         if( m_RGBA[R] > m_RGBA[B] )
00605             return m_RGBA[R];
00606         else
00607             return m_RGBA[B];
00608     }
00609     else
00610     {
00611         if( m_RGBA[G] > m_RGBA[B] )
00612             return m_RGBA[G];
00613         else
00614             return m_RGBA[B];
00615     }
00616 }
00617 
00618 SICPPSDK_INLINE float& CColor4f::GetR(){return m_RGBA[R];}
00619 SICPPSDK_INLINE float& CColor4f::GetG(){return m_RGBA[G];}
00620 SICPPSDK_INLINE float& CColor4f::GetB(){return m_RGBA[B];}
00621 SICPPSDK_INLINE float& CColor4f::GetA(){return m_RGBA[A];}
00622 
00623 SICPPSDK_INLINE float* CColor4f::GetRGBA(){return m_RGBA;}
00624 
00625 SICPPSDK_INLINE const float& CColor4f::GetR()const{return m_RGBA[R];}
00626 SICPPSDK_INLINE const float& CColor4f::GetG()const{return m_RGBA[G];}
00627 SICPPSDK_INLINE const float& CColor4f::GetB()const{return m_RGBA[B];}
00628 SICPPSDK_INLINE const float& CColor4f::GetA()const{return m_RGBA[A];}
00629 
00630 SICPPSDK_INLINE const float* CColor4f::GetRGBA()const{return m_RGBA;}
00631 
00632 SICPPSDK_INLINE CColor4f::operator float*(){return &(m_RGBA[0]);}
00633 
00634 SICPPSDK_INLINE bool CColor4f::operator==(const CColor4f& in_rColor4f )const
00635 {
00636     return  (m_RGBA[R] == in_rColor4f.m_RGBA[R]) &&
00637             (m_RGBA[G] == in_rColor4f.m_RGBA[G]) &&
00638             (m_RGBA[B] == in_rColor4f.m_RGBA[B]) &&
00639             (m_RGBA[A] == in_rColor4f.m_RGBA[A]);
00640 }
00641 
00642 SICPPSDK_INLINE bool CColor4f::operator!=(const CColor4f& in_rColor4f )const
00643 {
00644     return !(   (m_RGBA[R] == in_rColor4f.m_RGBA[R]) &&
00645                 (m_RGBA[G] == in_rColor4f.m_RGBA[G]) &&
00646                 (m_RGBA[B] == in_rColor4f.m_RGBA[B]) &&
00647                 (m_RGBA[A] == in_rColor4f.m_RGBA[A]));
00648 }
00649 
00650 SICPPSDK_INLINE bool CColor4f::operator < (const CColor4f& in_rColor4f )const
00651 {
00652     if (m_RGBA[A] != in_rColor4f.m_RGBA[A]) return m_RGBA[A] < in_rColor4f.m_RGBA[A];
00653     if (m_RGBA[B] != in_rColor4f.m_RGBA[B]) return m_RGBA[B] < in_rColor4f.m_RGBA[B];
00654     if (m_RGBA[G] != in_rColor4f.m_RGBA[G]) return m_RGBA[G] < in_rColor4f.m_RGBA[G];
00655     if (m_RGBA[R] != in_rColor4f.m_RGBA[R]) return m_RGBA[R] < in_rColor4f.m_RGBA[R];
00656     return false;
00657 }
00658 
00659 SICPPSDK_INLINE bool CColor4f::IsNull(float in_fEpsilon) const
00660 {
00661     return  fabsf( GetR() ) <= in_fEpsilon &&
00662             fabsf( GetG() ) <= in_fEpsilon &&
00663             fabsf( GetB() ) <= in_fEpsilon &&
00664             fabsf( GetA() ) <= in_fEpsilon;}
00665 
00666 SICPPSDK_INLINE CColor4f& CColor4f::Add(const CColor4f& in_col)
00667 {
00668     GetR() += in_col.GetR();
00669     GetG() += in_col.GetG();
00670     GetB() += in_col.GetB();
00671     GetA() += in_col.GetA();
00672     return *this;
00673 }
00674 
00675 SICPPSDK_INLINE CColor4f& CColor4f::Mul(float in_fFactor)
00676 {
00677     GetR()*=in_fFactor;
00678     GetB()*=in_fFactor;
00679     GetG()*=in_fFactor;
00680     GetA()*=in_fFactor;
00681     return *this;
00682 }
00683 
00684 SICPPSDK_INLINE CColor4f& CColor4f::Sub( const CColor4f& in_col )
00685 {
00686     GetR() -= in_col.GetR();
00687     GetG() -= in_col.GetG();
00688     GetB() -= in_col.GetB();
00689     GetA() -= in_col.GetA();
00690     return *this;
00691 }
00692 
00693 SICPPSDK_INLINE CColor4f& CColor4f::Mul( const CColor4f& in_col )
00694 {
00695     GetR() *= in_col.GetR();
00696     GetG() *= in_col.GetG();
00697     GetB() *= in_col.GetB();
00698     GetA() *= in_col.GetA();
00699     return *this;
00700 }
00701 
00702 SICPPSDK_INLINE CColor4f& CColor4f::Negate()
00703 {
00704     GetR()=-GetR();
00705     GetG()=-GetG();
00706     GetB()=-GetB();
00707     GetA()=-GetA();
00708     return *this;
00709 }
00710 
00711 SICPPSDK_INLINE void CColor4f::PutNull()
00712 {
00713     GetR()=0;
00714     GetG()=0;
00715     GetB()=0;
00716     GetA()=0;
00717 }
00718 
00719 SICPPSDK_INLINE float CColor4f::GetBrightness()const
00720 {
00721     return (GetR()+GetG()+GetB())*(1.0f/3.0f);
00722 }
00723 
00724 SICPPSDK_INLINE float CColor4f::GetBrightnessWithAlpha()const
00725 {
00726     return GetBrightness()*GetA();
00727 }
00728 
00729 SICPPSDK_INLINE float CColor4f::GetGrayscale()const
00730 {
00731     return GetR()*0.3f+GetG()*0.59f+GetB()*0.11f;
00732 }
00733 
00734 SICPPSDK_INLINE float CColor4f::GetGrayscaleWithAlpha()const
00735 {
00736     return GetGrayscale()*GetA();
00737 }
00738 
00739 SICPPSDK_INLINE CColor4f& CColor4f::InverseRGB()
00740 {
00741     GetR()=1.0f-GetR();
00742     GetG()=1.0f-GetG();
00743     GetB()=1.0f-GetB();
00744     return *this;
00745 }
00746 
00747 SICPPSDK_INLINE LONG CColor4f::RoundDown(float a) const
00748 {
00749     return (((a)<0) ? (((a)==(LONG)(a))?((LONG)(a)):((LONG)((a)-1))) : ((LONG)(a)));
00750 }
00751 
00752 SICPPSDK_INLINE void CColor4f::MinMax( float& out_fMin, float& out_fMax ) const
00753 {
00754     if( m_RGBA[R] > m_RGBA[G] )
00755     {
00756         if( m_RGBA[R] > m_RGBA[B] )
00757         {
00758             out_fMax = m_RGBA[R];
00759 
00760             if( m_RGBA[B] > m_RGBA[G] )
00761                 out_fMin = m_RGBA[G];
00762             else
00763                 out_fMin = m_RGBA[B];
00764         }
00765         else
00766         {
00767             out_fMax = m_RGBA[B];
00768             out_fMin = m_RGBA[G];
00769         }
00770     }
00771     else
00772     {
00773         if( m_RGBA[G] > m_RGBA[B] )
00774         {
00775             out_fMax = m_RGBA[G];
00776 
00777             if( m_RGBA[B] > m_RGBA[R] )
00778                 out_fMin = m_RGBA[R];
00779             else
00780                 out_fMin = m_RGBA[B];
00781         }
00782         else
00783         {
00784             out_fMax = m_RGBA[B];
00785             out_fMin = m_RGBA[R];
00786         }
00787     }
00788 }
00789 
00790 SICPPSDK_INLINE bool CColor4f::AreAlmostEqual
00791 (
00792     const CColor4f& in_c1,
00793     const CColor4f& in_c2,
00794     const float in_fEpsilon
00795 )
00796 {
00797     return  fabs( in_c1.GetR()-in_c2.GetR()) <= in_fEpsilon &&
00798             fabs( in_c1.GetG()-in_c2.GetG()) <= in_fEpsilon &&
00799             fabs(in_c1.GetB()-in_c2.GetB()) <= in_fEpsilon &&
00800             fabs(in_c1.GetA()-in_c2.GetA()) <= in_fEpsilon;
00801 }
00802 
00803 };
00804 };
00805 
00806 #endif // __XSICOLOR4F_H__