OSDN Git Service

ca07f1b6552c1575ccc0f27ab6afd7d8cf7c646a
[meshio/meshio.git] / src / color.h
1 #ifndef MESH_IO_COLOR_H_INCLUDED
2 #define MESH_IO_COLOR_H_INCLUDED
3
4 namespace meshio {
5 namespace color {
6
7 //! Byte\95Û\8e\9d\82ÌGBA
8 struct bRGBA
9 {
10         int r;
11         int g;
12         int b;
13         int a;
14
15         bRGBA()
16         {}
17
18         bRGBA(int _r, int _g, int _b, int _a)
19                 : r(_r), g(_g), b(_b), a(_a)
20         {}
21
22         static bRGBA createFromUInt(unsigned int uint)
23         {
24                 return bRGBA(
25                         uint & 0x000000FF,
26                         uint & 0x0000FF00 >> 8,
27                         uint & 0x00FF0000 >> 16,
28                         uint & 0xFF000000 >> 24
29                         );
30         }
31 };
32 #ifndef SWIG
33 inline std::ostream &operator<<(std::ostream &os, const bRGBA &rhs)
34 {
35         return os
36                 << '[' << rhs.r << ',' << rhs.g << ',' << rhs.b << ',' << rhs.a << ']';
37 }
38 #endif
39
40
41 //! Float\95Û\8e\9d\82ÌRGBA
42 struct fRGBA
43 {
44         float r;
45         float g;
46         float b;
47         float a;
48
49         fRGBA()
50         {}
51
52         fRGBA(float _r, float _g, float _b, float _a)
53                 : r(_r), g(_g), b(_b), a(_a)
54         {}
55
56         static fRGBA createFromUInt(unsigned int uint)
57         {
58                 return fRGBA(
59                         (uint & 0x000000FF) / 255.0f,
60                         (uint & 0x0000FF00 >> 8) / 255.0f,
61                         (uint & 0x00FF0000 >> 16) / 255.0f,
62                         (uint & 0xFF000000 >> 24) / 255.0f
63                         );
64         }
65 };
66 #ifndef SWIG
67 inline std::ostream &operator<<(std::ostream &os, const fRGBA &rhs)
68 {
69         return os
70                 << '[' << rhs.r << ',' << rhs.g << ',' << rhs.b << ',' << rhs.a << ']';
71 }
72 #endif
73
74
75 //! Float\95Û\8e\9d\82ÌRGB
76 struct fRGB
77 {
78         float r;
79         float g;
80         float b;
81 };
82 #ifndef SWIG
83 inline std::ostream &operator<<(std::ostream &os, const fRGB &rhs)
84 {
85         return os
86                 << '[' << rhs.r << ',' << rhs.g << ',' << rhs.b << ',' << ']';
87 }
88 #endif
89
90
91 } // namespace color
92 } // namespace meshio
93
94 #endif // MESH_IO_COLOR_H_INCLUDED