SIBCColor.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Crosswalk team
00004 //
00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.  
00006 // Use of this software is subject to the terms of the Autodesk license agreement 
00007 // provided at the time of installation or download, or which otherwise accompanies 
00008 // this software in either electronic or hard copy form.
00009 //
00010 //***************************************************************************************
00011 
00012 //***************************************************************************************
00013 // Defines
00014 //***************************************************************************************
00015 #ifndef __CSIBCColor_H__
00016 #define __CSIBCColor_H__
00017 
00018 //***************************************************************************************
00019 // Includes
00020 //***************************************************************************************
00021 #include <math.h>
00022 #include <SIBCUtil.h>
00023 
00024 //***************************************************************************************
00025 // CSIBCColorf | 
00026 //***************************************************************************************
00027 
00029 
00035 class XSICOREEXPORT CSIBCColorf
00036 {
00037     public:
00038 
00042         CSIBCColorf();                              
00043 
00048         CSIBCColorf( const CSIBCColorf & i_Color);
00049 
00057         CSIBCColorf(    const SI_Float i_fR, 
00058                         const SI_Float i_fB, 
00059                         const SI_Float i_fG, 
00060                         const SI_Float i_fA = 1.0f );
00061 
00062         ~CSIBCColorf();
00063 
00064         // Comparison
00065 
00075         SI_Bool IsAlmostEqualTo(const CSIBCColorf& i_Color, const SI_Float i_Thresh) const;
00076 
00083         SI_Bool IsNull() const;
00084 
00091         SI_Bool IsNullAlpha() const;
00092 
00093         // Computed Info
00094 
00102         SI_Float GetDot(const CSIBCColorf& i_Color) const;
00103         
00111         SI_Float GetDotAlpha(const CSIBCColorf& i_Color) const;
00112 
00119         SI_Float GetDistanceFrom(const CSIBCColorf& i_Color) const;
00120 
00127         SI_Float GetDistanceFromAlpha(const CSIBCColorf& i_Color) const;
00128 
00134         SI_Float GetLength() const;
00135 
00141         SI_Float GetLengthAlpha() const;
00142 
00148         SI_Float GetSquaredLength() const;
00149 
00155         SI_Float GetSquaredLengthAlpha() const;
00156 
00164         SI_Float GetMaxComponent(SI_Int * i_pIndex) const;
00165 
00173         SI_Float GetMaxComponentAlpha(SI_Int * i_pIndex) const;
00174 
00182         SI_Float GetMinComponent(SI_Int * i_pIndex) const;
00183 
00191         SI_Float GetMinComponentAlpha(SI_Int * i_pIndex) const;
00192         
00193         // Components
00194 
00202         void Get(SI_Float* o_pR, SI_Float* o_pG, SI_Float* o_pB, SI_Float* o_pA) const;
00203 
00210         void Get(SI_Float* o_pR, SI_Float* o_pG, SI_Float* o_pB) const;
00211 
00220         CSIBCColorf& Set(SI_Float i_fR, SI_Float i_fG, SI_Float i_fB, SI_Float i_fA = 1.0f );
00221         
00222         // Operations
00223 
00228         CSIBCColorf& Normalize();
00229 
00234         CSIBCColorf& NormalizeAlpha();
00235 
00242         CSIBCColorf& SetNull( SI_Float alpha = 1.0f );
00243         
00251         CSIBCColorf& SetLength(const SI_Float in_dLength);
00252 
00260         CSIBCColorf& SetLengthAlpha(const SI_Float);
00261 
00266         CSIBCColorf& Negate();
00267 
00272         CSIBCColorf& NegateAlpha();
00273 
00280         CSIBCColorf& Add(const CSIBCColorf& i_Color);
00281 
00289         CSIBCColorf& AddAlpha(const CSIBCColorf& i_Color);
00290 
00297         CSIBCColorf& Sub(const CSIBCColorf& i_Color);
00298 
00305         CSIBCColorf& SubAlpha(const CSIBCColorf& i_Color);
00306 
00312         CSIBCColorf& Scale(const SI_Float i_fFactor);
00313 
00320         CSIBCColorf& ScaleAlpha(const SI_Float i_fFactor);
00321 
00328         CSIBCColorf& MulComp(const CSIBCColorf& i_Color);
00329 
00336         CSIBCColorf& DivComp(const CSIBCColorf& i_Color);
00337         
00338         // overloaded operators
00339 
00346         SI_Bool operator == (const CSIBCColorf& i_Color) const;
00347 
00354         SI_Bool operator != (const CSIBCColorf& i_Color) const;
00355 
00363         CSIBCColorf operator+(const CSIBCColorf & i_Color);
00364 
00371         CSIBCColorf operator*(const SI_Float i_fFactor);
00372 
00374         SI_Float    m_fR;
00375 
00377         SI_Float    m_fG;
00378         
00380         SI_Float    m_fB;
00381         
00383         SI_Float    m_fA;
00384 
00385 protected:
00386 
00387 
00388 private:
00389 
00390 
00391 };
00392 
00393 //***************************************************************************************
00394 // CSIBCColorb |
00395 //***************************************************************************************
00396 
00398 
00404 class XSICOREEXPORT CSIBCColorb
00405 {
00406     public:
00407 
00411         CSIBCColorb();
00412 
00417         CSIBCColorb( const CSIBCColorb & i_Color);
00418 
00426         CSIBCColorb(    const SI_UByte  i_bR, 
00427                         const SI_UByte  i_bG, 
00428                         const SI_UByte  i_bB, 
00429                         const SI_UByte  i_bA = 0 );
00430 
00431         ~CSIBCColorb();                             // Default Destructor
00432 
00433         // Comparison
00434 
00440         SI_Bool IsNull() const;
00441 
00447         SI_Bool IsNullAlpha() const;
00448 
00449         // Computed Info
00450 
00458         SI_UByte GetDot(const CSIBCColorb&) const;
00459 
00467         SI_UByte GetDotAlpha(const CSIBCColorb&) const;
00468 
00475         SI_Float GetDistanceFrom(const CSIBCColorb&) const;
00476 
00483         SI_Float GetDistanceFromAlpha(const CSIBCColorb&) const;
00484 
00490         SI_Float GetLength() const;
00491 
00497         SI_Float GetLengthAlpha() const;
00498 
00504         SI_Float GetSquaredLength() const;
00505 
00511         SI_Float GetSquaredLengthAlpha() const;
00512 
00520         SI_UByte GetMaxComponent(SI_Int * i_pIndex) const;
00521 
00529         SI_UByte GetMaxComponentAlpha(SI_Int * i_pIndex) const;
00530 
00538         SI_UByte GetMinComponent(SI_Int * i_pIndex) const;
00539 
00547         SI_UByte GetMinComponentAlpha(SI_Int * i_pIndex) const;
00548         
00549         // Components
00557         void Get(SI_UByte* o_pR, SI_UByte* o_pG, SI_UByte* o_pB, SI_UByte* o_pA) const; 
00558 
00559 
00566         void Get(SI_UByte* o_pR, SI_UByte* o_pG, SI_UByte* o_pB) const;
00567 
00568         
00577         CSIBCColorb& Set(SI_UByte i_bR, SI_UByte i_bG, SI_UByte i_bB, SI_UByte i_bA = 255 );
00578         
00579         // Operations
00580 
00585         CSIBCColorb& Normalize();
00586 
00591         CSIBCColorb& NormalizeAlpha();
00592 
00599         CSIBCColorb& SetNull( SI_UByte alpha = 0 );
00600 
00608         CSIBCColorb& SetLength(const SI_Float in_dLength);
00609 
00617         CSIBCColorb& SetLengthAlpha(const SI_Float in_dLength);
00618 
00623         CSIBCColorb& Negate();
00624 
00629         CSIBCColorb& NegateAlpha();
00630 
00637         CSIBCColorb& Add(const CSIBCColorb& i_Color);
00638 
00646         CSIBCColorb& AddAlpha(const CSIBCColorb& i_Color);
00647 
00654         CSIBCColorb& Sub(const CSIBCColorb& i_Color);
00655 
00662         CSIBCColorb& SubAlpha(const CSIBCColorb& i_Color);
00663 
00669         CSIBCColorb& Scale(const SI_Float i_fFactor);
00670 
00677         CSIBCColorb& ScaleAlpha(const SI_Float i_fFactor);
00678 
00685         CSIBCColorb& MulComp(const CSIBCColorb& i_Color);
00686 
00693         CSIBCColorb& DivComp(const CSIBCColorb& i_Color);
00694         
00695         // overloaded operators
00701         SI_Bool operator == (const CSIBCColorb& i_Color) const;
00702 
00708         SI_Bool operator != (const CSIBCColorb& i_Color) const;
00709 
00717         CSIBCColorb operator+(const CSIBCColorb & i_Color);
00718 
00720         SI_UByte    m_fR;
00721 
00723         SI_UByte    m_fG;
00724         
00726         SI_UByte    m_fB;
00727 
00729         SI_UByte    m_fA;
00730 
00731 protected:
00732 
00733 
00734 private:
00735 
00736 
00737 };
00738 
00739 
00740 
00741 
00742 #endif // CSIBCColor