AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzColour.h
Go to the documentation of this file.
00001 // 
00002 //
00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine
00004 //
00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk
00006 //
00007 // For updates, tutorials and more details check out www.appeasymobile.com
00008 //
00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin.
00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support
00011 //
00012 //
00013 
00014 #if !defined(_CCZ_COLOUR_H_)
00015 #define _CCZ_COLOUR_H_
00016 
00017 #include "CzUtil.h"
00018 
00019 /**
00020  @addtogroup Core
00021  @{
00022  */
00023  
00024 /**
00025  @struct    CzColour
00026 
00027  @brief Structure used to represent colour.
00028 
00029  */
00030 
00031 struct CzColour
00032 {
00033     // Properties
00034 public:
00035     uint8   r;  ///< Red component
00036     uint8   g;  ///< Green component
00037     uint8   b;  ///< Blue component
00038     uint8   a;  ///< Alpha component
00039     // Properties End
00040 public:
00041     CzColour()
00042     {
00043         r = g = b = a = 0;
00044     }
00045     CzColour(uint8 r, uint8 g, uint8 b, uint8 a)
00046     {
00047         this->r = r;
00048         this->g = g;
00049         this->b = b;
00050         this->a = a;
00051     }
00052     CzColour(uint32 rgba)
00053     {
00054 #ifdef CZ_LITTLE_ENDIAN
00055         r = rgba >> 24;
00056         g = (rgba >> 16) & 0xff;
00057         b = (rgba >> 8) & 0xff;
00058         a = rgba & 0xff;
00059 #else
00060         r = rgba & 0xff;
00061         g = (rgba >> 8) & 0xff;
00062         b = (rgba >> 16) & 0xff;
00063         a = (rgba >> 24) & 0xff;
00064 #endif
00065     }
00066     
00067     void set(const CzColour& c)
00068     {
00069         r = c.r;
00070         g = c.g;
00071         b = c.b;
00072         a = c.a;
00073     }
00074     void set(uint8 r, uint8 g, uint8 b, uint8 a)
00075     {
00076         this->r = r;
00077         this->g = g;
00078         this->b = b;
00079         this->a = a;
00080     }
00081 
00082     void set(uint32 rgba)
00083     {
00084 #ifdef CZ_LITTLE_ENDIAN
00085         r = rgba >> 24;
00086         g = (rgba >> 16) & 0xff;
00087         b = (rgba >> 8) & 0xff;
00088         a = rgba & 0xff;
00089 #else
00090         r = rgba & 0xff;
00091         g = (rgba >> 8) & 0xff;
00092         b = (rgba >> 16) & 0xff;
00093         a = (rgba >> 24) & 0xff;
00094 #endif
00095     }
00096 
00097     uint32 get() const
00098     {
00099 #ifdef CZ_LITTLE_ENDIAN
00100         return  (uint32)a | ((uint32)b << 8) | ((uint32)g << 16) | ((uint32)r << 24);
00101 #else
00102         return  (uint32)r | ((uint32)g << 8) | ((uint32)b << 16) | ((uint32)a << 24);
00103 #endif
00104     }
00105 
00106 
00107 };
00108 
00109 /// @}
00110 
00111 #endif  // _CCZ_COLOUR_H_