OSDN Git Service

update package.
[meshio/meshio.git] / include / color.h
index 443aa09..ca07f1b 100644 (file)
@@ -7,10 +7,10 @@ namespace color {
 //! Byte\95Û\8e\9d\82ÌGBA
 struct bRGBA
 {
-       char r;
-       char g;
-       char b;
-       char a;
+       int r;
+       int g;
+       int b;
+       int a;
 
        bRGBA()
        {}
@@ -29,11 +29,14 @@ struct bRGBA
                        );
        }
 };
+#ifndef SWIG
 inline std::ostream &operator<<(std::ostream &os, const bRGBA &rhs)
 {
        return os
                << '[' << rhs.r << ',' << rhs.g << ',' << rhs.b << ',' << rhs.a << ']';
 }
+#endif
+
 
 //! Float\95Û\8e\9d\82ÌRGBA
 struct fRGBA
@@ -42,12 +45,31 @@ struct fRGBA
        float g;
        float b;
        float a;
+
+       fRGBA()
+       {}
+
+       fRGBA(float _r, float _g, float _b, float _a)
+               : r(_r), g(_g), b(_b), a(_a)
+       {}
+
+       static fRGBA createFromUInt(unsigned int uint)
+       {
+               return fRGBA(
+                       (uint & 0x000000FF) / 255.0f,
+                       (uint & 0x0000FF00 >> 8) / 255.0f,
+                       (uint & 0x00FF0000 >> 16) / 255.0f,
+                       (uint & 0xFF000000 >> 24) / 255.0f
+                       );
+       }
 };
+#ifndef SWIG
 inline std::ostream &operator<<(std::ostream &os, const fRGBA &rhs)
 {
        return os
                << '[' << rhs.r << ',' << rhs.g << ',' << rhs.b << ',' << rhs.a << ']';
 }
+#endif
 
 
 //! Float\95Û\8e\9d\82ÌRGB
@@ -57,11 +79,13 @@ struct fRGB
        float g;
        float b;
 };
+#ifndef SWIG
 inline std::ostream &operator<<(std::ostream &os, const fRGB &rhs)
 {
        return os
                << '[' << rhs.r << ',' << rhs.g << ',' << rhs.b << ',' << ']';
 }
+#endif
 
 
 } // namespace color