D:/Zythum/DinoKod/Common/Color.h

00001 #ifndef __COLOR_H__
00002 #define __COLOR_H__
00003 
00004 #include "Common/CommonDll.h"
00005 
00006 typedef u32                                     KCOLOR;
00007 #define KRGB(r, g, b)           ((KCOLOR) (((255) << 24) | ((r) << 16) | ((g) << 8) | (b)))
00008 #define KRGBA(r, g, b, a)       ((KCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
00009 #define KRGBA2INT( x )          KRGBA( x.r, x.g, x.b, x.a )
00010 #define KGETA(color)            ((u8) ((color & 0xFF000000) >> 24 ))
00011 #define KGETR(color)            ((u8) ((color & 0x00FF0000) >> 16 ))
00012 #define KGETG(color)            ((u8) ((color & 0x0000FF00) >> 8 ))
00013 #define KGETB(color)            ((u8) ((color & 0x000000FF) ))
00014 #define KSETA(color,a)          (color = (color & 0x00FFFFFF) | ((a & 0xFF) << 24))
00015 #define KSETR(color,r)          (color = (color & 0xFF00FFFF) | ((r & 0xFF) << 16))
00016 #define KSETG(color,g)          (color = (color & 0xFFFF00FF) | ((g & 0xFF) << 8))
00017 #define KSETB(color,b)          (color = (color & 0xFFFFFF00) | ((b & 0xFF))
00018 
00019 #define KRGB_WHITE                      ((KCOLOR)0xFFFFFFFF)
00020 #define KRGB_BLACK                      ((KCOLOR)0xFF000000)
00021 
00022 //---------------------------------------------------------------------------------------------------------------------
00023 class COMMON_API KRgb
00024 {
00025 public:
00026         u8              r;
00027         u8              g;
00028         u8              b;
00029 
00030         inline KRgb()
00031         {
00032 /*              r = 0;
00033                 g = 0;
00034                 b = 0;*/
00035         }
00036 
00037         inline KRgb( u8 r, u8 g, u8 b )
00038         {
00039                 this->r = r;
00040                 this->g = g;
00041                 this->b = b;
00042         }
00043 
00044         inline void Swap()
00045         {
00046                 u8      tmp = this->r;
00047                 this->r = this->b;
00048                 this->b = tmp;
00049         }
00050 
00051         KCOLOR GetColor()
00052         {
00053                 return KRGB( r, g, b );
00054         }
00055 };
00056 
00057 //---------------------------------------------------------------------------------------------------------------------
00058 class COMMON_API KRgba
00059 {
00060 public:
00061         u8              r;
00062         u8              g;
00063         u8              b;
00064         u8              a;
00065 
00066         inline KRgba()
00067         {
00068 /*              r = 0;
00069                 g = 0;
00070                 b = 0;
00071                 a = 0;*/
00072         }
00073 
00074         inline KRgba( u8 r, u8 g, u8 b, u8 a )
00075         {
00076                 this->r = r;
00077                 this->g = g;
00078                 this->b = b;
00079                 this->a = a;
00080         }
00081 
00082         inline void Swap()
00083         {
00084                 KRgba   Color = *this;
00085 
00086                 this->r = Color.b;
00087                 this->g = Color.g;
00088                 this->b = Color.r;
00089                 this->a = Color.a;
00090         }
00091 
00092         KCOLOR GetColor()
00093         {
00094                 return KRGBA( r, g, b, a );
00095         }
00096 };
00097 
00098 //---------------------------------------------------------------------------------------------------------------------
00099 class COMMON_API KFRgb
00100 {
00101 public:
00102         float           r;
00103         float           g;
00104         float           b;
00105 
00106         inline KFRgb()
00107         {
00108         }
00109 
00110         inline KFRgb( float r, float g, float b )
00111         {
00112                 this->r = r;
00113                 this->g = g;
00114                 this->b = b;
00115         }
00116 
00117         inline void Swap()
00118         {
00119                 KFRgb   Color = *this;
00120 
00121                 this->r = Color.b;
00122                 this->g = Color.g;
00123                 this->b = Color.r;
00124         }
00125 /*
00126         operator =( KFRgba& Rgba )
00127         {
00128                 this->r = Rgba.b;
00129                 this->g = Rgba.g;
00130                 this->b = Rgba.r;
00131         }*/
00132 };
00133 
00134 //---------------------------------------------------------------------------------------------------------------------
00135 class COMMON_API KFRgba
00136 {
00137 public:
00138         float           r;
00139         float           g;
00140         float           b;
00141         float           a;
00142 
00143         inline KFRgba()
00144         {
00145         }
00146 
00147         inline KFRgba( float r, float g, float b, float a )
00148         {
00149                 this->r = r;
00150                 this->g = g;
00151                 this->b = b;
00152                 this->a = a;
00153         }
00154 
00155         inline void Swap()
00156         {
00157                 KFRgba  Color = *this;
00158 
00159                 this->r = Color.b;
00160                 this->g = Color.g;
00161                 this->b = Color.r;
00162                 this->a = Color.a;
00163         }
00164 
00165         void operator =( KFRgb& Rgb )
00166         {
00167                 this->r = Rgb.b;
00168                 this->g = Rgb.g;
00169                 this->b = Rgb.r;
00170                 this->a = 1.0f;
00171         }
00172 };
00173 
00174 #endif //       __COLOR_H__

Generated on Sun Mar 25 20:02:10 2007 for Zythum Project by  doxygen 1.5.1-p1