UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
types.h
Go to the documentation of this file.
1 #ifndef HORUSEYE_FRAMEWORK_TYPES_H_
2 #define HORUSEYE_FRAMEWORK_TYPES_H_
3 
4 #include <stdint.h>
5 
6 #ifdef SWIG
7 #pragma SWIG nowarn=312
8 #endif
9 
10 namespace ugdk {
11 
12 typedef uint8_t uint8;
13 typedef uint16_t uint16;
14 typedef uint32_t uint32;
15 typedef uint64_t uint64;
16 typedef int8_t int8;
17 typedef int16_t int16;
18 typedef int32_t int32;
19 typedef int64_t int64;
20 
21 typedef uint8 Mirror;
22 static const Mirror MIRROR_NONE = 0;
23 static const Mirror MIRROR_HFLIP = 1;
24 static const Mirror MIRROR_VFLIP = 2;
25 static const Mirror MIRROR_HVFLIP = 3;
26 
27 namespace enums {
28 namespace mirroraxis {
29 enum MirrorAxis {
30  HORZ = 0,
31  DIAG_UP = 45,
32  VERT = 90,
33  DIAG_DOWN = 135
34 };
35 }
36 }
37 
38 typedef struct Color {
39  Color() : r(1.0), g(1.0), b(1.0), a(1.0) {}
40  explicit Color(double _r, double _g, double _b, double _a = 1.0)
41  : r(_r), g(_g), b(_b), a(_a) {}
42  explicit Color(uint32 hex_val, double _a = 1.0) :
43  r(((hex_val & 0xFF0000) >> 16) / 255.0),
44  g(((hex_val & 0x00FF00) >> 8) / 255.0),
45  b(((hex_val & 0x0000FF) ) / 255.0),
46  a(_a) {}
47 
48  union {
49  struct { double r, g, b, a; };
50  struct { double val[4]; };
51  };
52 
53  void Compose(const Color& rhs) {
54  r *= rhs.r;
55  g *= rhs.g;
56  b *= rhs.b;
57  a *= rhs.a;
58  }
59 
60  Color& operator*=(const Color& rhs) { Compose(rhs); return *this; }
61  Color operator*(const Color& rhs) const {
62  Color result(rhs);
63  result *= *this;
64  return result;
65  }
66 
67  double get_r() const { return r; }
68  double get_g() const { return g; }
69  double get_b() const { return b; }
70  double get_a() const { return a; }
71 
72  void set_r(double r_) { r = r_; }
73  void set_g(double g_) { g = g_; }
74  void set_b(double b_) { b = b_; }
75  void set_a(double a_) { a = a_; }
76 
77 } Color;
78 
79 //static Color BLACK = {0.0, 0.0, 0.0};
80 #ifndef SWIG
81 static const Color WHITE(1.0, 1.0, 1.0);
82 #endif
83 
84 } // namespace ugdk
85 
86 #endif /* HORUSEYE_FRAMEWORK_TYPES_H_ */