UGDK
src/ugdk/base/types.h
Go to the documentation of this file.
00001 #ifndef HORUSEYE_FRAMEWORK_TYPES_H_
00002 #define HORUSEYE_FRAMEWORK_TYPES_H_
00003 
00004 #include <stdint.h>
00005 
00006 #ifdef SWIG
00007 #pragma SWIG nowarn=312
00008 #endif
00009 
00010 namespace ugdk {
00011 
00012 typedef uint8_t uint8;
00013 typedef uint16_t uint16;
00014 typedef uint32_t uint32;
00015 typedef uint64_t uint64;
00016 typedef int8_t int8;
00017 typedef int16_t int16;
00018 typedef int32_t int32;
00019 typedef int64_t int64;
00020 
00021 typedef uint8 Mirror;
00022 static const Mirror MIRROR_NONE     = 0;
00023 static const Mirror MIRROR_HFLIP    = 1;
00024 static const Mirror MIRROR_VFLIP    = 2;
00025 static const Mirror MIRROR_HVFLIP   = 3;
00026 
00027 namespace enums {
00028 namespace mirroraxis {
00029 enum MirrorAxis {
00030     HORZ = 0,
00031     DIAG_UP = 45,
00032     VERT = 90,
00033     DIAG_DOWN = 135
00034 };
00035 }
00036 }
00037 
00038 typedef struct Color {
00039     Color() : r(1.0), g(1.0), b(1.0), a(1.0) {}
00040     explicit Color(double _r, double _g, double _b, double _a = 1.0)
00041           : r(_r), g(_g), b(_b), a(_a) {}
00042     explicit Color(uint32 hex_val, double _a = 1.0) :
00043         r(((hex_val & 0xFF0000) >> 16) / 255.0),
00044         g(((hex_val & 0x00FF00) >>  8) / 255.0),
00045         b(((hex_val & 0x0000FF)      ) / 255.0),
00046         a(_a) {}
00047 
00048     union {
00049         struct { double r, g, b, a; };
00050         struct { double val[4];  };
00051     };
00052 
00053     void Compose(const Color& rhs) {
00054         r *= rhs.r;
00055         g *= rhs.g;
00056         b *= rhs.b;
00057         a *= rhs.a;
00058     }
00059 
00060     Color&  operator*=(const Color& rhs) { Compose(rhs); return *this; }
00061     Color   operator*(const Color& rhs) const {
00062         Color result(rhs);
00063         result *= *this;
00064         return result;
00065     }
00066     
00067     double get_r() const { return r; }
00068     double get_g() const { return g; }
00069     double get_b() const { return b; }
00070     double get_a() const { return a; }
00071     
00072     void set_r(double r_)  { r = r_; }
00073     void set_g(double g_)  { g = g_; }
00074     void set_b(double b_)  { b = b_; }
00075     void set_a(double a_)  { a = a_; }
00076     
00077 } Color;
00078 
00079 //static Color BLACK = {0.0, 0.0, 0.0};
00080 #ifndef SWIG
00081 static const Color WHITE(1.0, 1.0, 1.0);
00082 #endif
00083 
00084 }  // namespace ugdk
00085 
00086 #endif /* HORUSEYE_FRAMEWORK_TYPES_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines