SIBCColor.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Softimage 3D Games & 3D Bridge team
00004 //
00005 // (c) Copyright 1999-2002 Avid Technology, Inc. . All rights reserved.
00006 //
00007 // SIBCColor.h | Main header file for SIBCColor implementation
00008 //***************************************************************************************
00009 
00010 /****************************************************************************************
00011 THIS CODE IS PUBLISHED AS A SAMPLE ONLY AND IS PROVIDED "AS IS".
00012 IN NO EVENT SHALL SOFTIMAGE, AVID TECHNOLOGY, INC. AND/OR THEIR RESPECTIVE
00013 SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
00014 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00015 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00016 CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE .
00017 
00018 COPYRIGHT NOTICE. Copyright © 1999-2002 Avid Technology Inc. . All rights reserved. 
00019 
00020 SOFTIMAGE is a registered trademark of Avid Technology Inc. or its subsidiaries 
00021 or divisions. Windows NT is a registered trademark of Microsoft Corp. All other
00022 trademarks contained herein are the property of their respective owners. 
00023 ****************************************************************************************/
00024 
00025 //***************************************************************************************
00026 // Defines
00027 //***************************************************************************************
00028 #ifndef __CSIBCColor_H__
00029 #define __CSIBCColor_H__
00030 
00031 //***************************************************************************************
00032 // Includes
00033 //***************************************************************************************
00034 #include <math.h>
00035 #include <SIBCUtil.h>
00036 
00037 //***************************************************************************************
00038 // CSIBCColorf | 
00039 //***************************************************************************************
00040 
00042 
00048 class XSICOREEXPORT CSIBCColorf
00049 {
00050     public:
00051 
00055         CSIBCColorf();                              
00056 
00061         CSIBCColorf( const CSIBCColorf & i_Color);
00062 
00070         CSIBCColorf(    const SI_Float i_fR, 
00071                         const SI_Float i_fB, 
00072                         const SI_Float i_fG, 
00073                         const SI_Float i_fA = 1.0f );
00074 
00075         ~CSIBCColorf();
00076 
00077         // Comparison
00078 
00088         SI_Bool IsAlmostEqualTo(const CSIBCColorf& i_Color, const SI_Float i_Thresh) const;
00089 
00096         SI_Bool IsNull() const;
00097 
00104         SI_Bool IsNullAlpha() const;
00105 
00106         // Computed Info
00107 
00115         SI_Float GetDot(const CSIBCColorf& i_Color) const;
00116         
00124         SI_Float GetDotAlpha(const CSIBCColorf& i_Color) const;
00125 
00132         SI_Float GetDistanceFrom(const CSIBCColorf& i_Color) const;
00133 
00140         SI_Float GetDistanceFromAlpha(const CSIBCColorf& i_Color) const;
00141 
00147         SI_Float GetLength() const;
00148 
00154         SI_Float GetLengthAlpha() const;
00155 
00161         SI_Float GetSquaredLength() const;
00162 
00168         SI_Float GetSquaredLengthAlpha() const;
00169 
00177         SI_Float GetMaxComponent(SI_Int * i_pIndex) const;
00178 
00186         SI_Float GetMaxComponentAlpha(SI_Int * i_pIndex) const;
00187 
00195         SI_Float GetMinComponent(SI_Int * i_pIndex) const;
00196 
00204         SI_Float GetMinComponentAlpha(SI_Int * i_pIndex) const;
00205         
00206         // Components
00207 
00215         void Get(SI_Float* o_pR, SI_Float* o_pG, SI_Float* o_pB, SI_Float* o_pA) const;
00216 
00223         void Get(SI_Float* o_pR, SI_Float* o_pG, SI_Float* o_pB) const;
00224 
00233         CSIBCColorf& Set(SI_Float i_fR, SI_Float i_fG, SI_Float i_fB, SI_Float i_fA = 1.0f );
00234         
00235         // Operations
00236 
00241         CSIBCColorf& Normalize();
00242 
00247         CSIBCColorf& NormalizeAlpha();
00248 
00255         CSIBCColorf& SetNull( SI_Float alpha = 1.0f );
00256         
00264         CSIBCColorf& SetLength(const SI_Float in_dLength);
00265 
00273         CSIBCColorf& SetLengthAlpha(const SI_Float);
00274 
00279         CSIBCColorf& Negate();
00280 
00285         CSIBCColorf& NegateAlpha();
00286 
00293         CSIBCColorf& Add(const CSIBCColorf& i_Color);
00294 
00302         CSIBCColorf& AddAlpha(const CSIBCColorf& i_Color);
00303 
00310         CSIBCColorf& Sub(const CSIBCColorf& i_Color);
00311 
00318         CSIBCColorf& SubAlpha(const CSIBCColorf& i_Color);
00319 
00325         CSIBCColorf& Scale(const SI_Float i_fFactor);
00326 
00333         CSIBCColorf& ScaleAlpha(const SI_Float i_fFactor);
00334 
00341         CSIBCColorf& MulComp(const CSIBCColorf& i_Color);
00342 
00349         CSIBCColorf& DivComp(const CSIBCColorf& i_Color);
00350         
00351         // overloaded operators
00352 
00359         SI_Bool operator == (const CSIBCColorf& i_Color) const;
00360 
00367         SI_Bool operator != (const CSIBCColorf& i_Color) const;
00368 
00376         CSIBCColorf operator+(const CSIBCColorf & i_Color);
00377 
00384         CSIBCColorf operator*(const SI_Float i_fFactor);
00385 
00387         SI_Float    m_fR;
00388 
00390         SI_Float    m_fG;
00391         
00393         SI_Float    m_fB;
00394         
00396         SI_Float    m_fA;
00397 
00398 protected:
00399 
00400 
00401 private:
00402 
00403 
00404 };
00405 
00406 //***************************************************************************************
00407 // CSIBCColorb |
00408 //***************************************************************************************
00409 
00411 
00417 class XSICOREEXPORT CSIBCColorb
00418 {
00419     public:
00420 
00424         CSIBCColorb();
00425 
00430         CSIBCColorb( const CSIBCColorb & i_Color);
00431 
00439         CSIBCColorb(    const SI_UByte  i_bR, 
00440                         const SI_UByte  i_bG, 
00441                         const SI_UByte  i_bB, 
00442                         const SI_UByte  i_bA = 0 );
00443 
00444         ~CSIBCColorb();                             // Default Destructor
00445 
00446         // Comparison
00447 
00453         SI_Bool IsNull() const;
00454 
00460         SI_Bool IsNullAlpha() const;
00461 
00462         // Computed Info
00463 
00471         SI_UByte GetDot(const CSIBCColorb&) const;
00472 
00480         SI_UByte GetDotAlpha(const CSIBCColorb&) const;
00481 
00488         SI_Float GetDistanceFrom(const CSIBCColorb&) const;
00489 
00496         SI_Float GetDistanceFromAlpha(const CSIBCColorb&) const;
00497 
00503         SI_Float GetLength() const;
00504 
00510         SI_Float GetLengthAlpha() const;
00511 
00517         SI_Float GetSquaredLength() const;
00518 
00524         SI_Float GetSquaredLengthAlpha() const;
00525 
00533         SI_UByte GetMaxComponent(SI_Int * i_pIndex) const;
00534 
00542         SI_UByte GetMaxComponentAlpha(SI_Int * i_pIndex) const;
00543 
00551         SI_UByte GetMinComponent(SI_Int * i_pIndex) const;
00552 
00560         SI_UByte GetMinComponentAlpha(SI_Int * i_pIndex) const;
00561         
00562         // Components
00570         void Get(SI_UByte* o_pR, SI_UByte* o_pG, SI_UByte* o_pB, SI_UByte* o_pA) const; 
00571 
00572 
00579         void Get(SI_UByte* o_pR, SI_UByte* o_pG, SI_UByte* o_pB) const;
00580 
00581         
00590         CSIBCColorb& Set(SI_UByte i_bR, SI_UByte i_bG, SI_UByte i_bB, SI_UByte i_bA = 255 );
00591         
00592         // Operations
00593 
00598         CSIBCColorb& Normalize();
00599 
00604         CSIBCColorb& NormalizeAlpha();
00605 
00612         CSIBCColorb& SetNull( SI_UByte alpha = 0 );
00613 
00621         CSIBCColorb& SetLength(const SI_Float in_dLength);
00622 
00630         CSIBCColorb& SetLengthAlpha(const SI_Float in_dLength);
00631 
00636         CSIBCColorb& Negate();
00637 
00642         CSIBCColorb& NegateAlpha();
00643 
00650         CSIBCColorb& Add(const CSIBCColorb& i_Color);
00651 
00659         CSIBCColorb& AddAlpha(const CSIBCColorb& i_Color);
00660 
00667         CSIBCColorb& Sub(const CSIBCColorb& i_Color);
00668 
00675         CSIBCColorb& SubAlpha(const CSIBCColorb& i_Color);
00676 
00682         CSIBCColorb& Scale(const SI_Float i_fFactor);
00683 
00690         CSIBCColorb& ScaleAlpha(const SI_Float i_fFactor);
00691 
00698         CSIBCColorb& MulComp(const CSIBCColorb& i_Color);
00699 
00706         CSIBCColorb& DivComp(const CSIBCColorb& i_Color);
00707         
00708         // overloaded operators
00714         SI_Bool operator == (const CSIBCColorb& i_Color) const;
00715 
00721         SI_Bool operator != (const CSIBCColorb& i_Color) const;
00722 
00730         CSIBCColorb operator+(const CSIBCColorb & i_Color);
00731 
00733         SI_UByte    m_fR;
00734 
00736         SI_UByte    m_fG;
00737         
00739         SI_UByte    m_fB;
00740 
00742         SI_UByte    m_fA;
00743 
00744 protected:
00745 
00746 
00747 private:
00748 
00749 
00750 };
00751 
00752 
00753 
00754 
00755 #endif // CSIBCColor