00001 #ifndef COIN_SBCOLOR4F_H
00002 #define COIN_SBCOLOR4F_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <Inventor/system/inttypes.h>
00028 #include <Inventor/SbColor.h>
00029
00030 class SbVec4f;
00031
00032 class COIN_DLL_API SbColor4f {
00033 public:
00034 SbColor4f(void);
00035 SbColor4f(const SbColor &rgb, const float alpha);
00036 SbColor4f(const SbVec4f& v);
00037 SbColor4f(const float* const rgba);
00038 SbColor4f(const float r, const float g, const float b, const float a = 1.0f);
00039
00040 void setValue(const float r, const float g, const float b,
00041 const float a = 1.0f);
00042 void setValue(const float col[4]);
00043 const float *getValue() const;
00044 void getValue(float &r, float &g, float &b, float &a);
00045
00046
00047 SbColor4f& setRGB(const SbColor &col);
00048 void getRGB(SbColor &color);
00049 SbColor4f& setHSVValue(float h, float s, float v, float a = 1.0f);
00050 SbColor4f& setHSVValue(const float hsv[3], float alpha = 1.0f);
00051 void getHSVValue(float &h, float &s, float &v) const;
00052 void getHSVValue(float hsv[3]) const;
00053 SbColor4f& setPackedValue(const uint32_t rgba);
00054 uint32_t getPackedValue() const;
00055
00056 float operator[](const int idx) const;
00057 float &operator[](const int idx);
00058
00059 SbColor4f &operator*=(const float d);
00060 SbColor4f &operator/=(const float d);
00061 SbColor4f &operator+=(const SbColor4f &c);
00062 SbColor4f &operator-=(const SbColor4f &c);
00063
00064 friend COIN_DLL_API SbColor4f operator *(const SbColor4f &c, const float d);
00065 friend COIN_DLL_API SbColor4f operator *(const float d, const SbColor4f &c);
00066 friend COIN_DLL_API SbColor4f operator /(const SbColor4f &c, const float d);
00067 friend COIN_DLL_API SbColor4f operator +(const SbColor4f &v1, const SbColor4f &v2);
00068 friend COIN_DLL_API SbColor4f operator -(const SbColor4f &v1, const SbColor4f &v2);
00069 friend COIN_DLL_API int operator ==(const SbColor4f &v1, const SbColor4f &v2);
00070 friend COIN_DLL_API int operator !=(const SbColor4f &v1, const SbColor4f &v2);
00071
00072 private:
00073 float vec[4];
00074 float red() const { return this->vec[0]; }
00075 float green() const { return this->vec[1]; }
00076 float blue() const { return this->vec[2]; }
00077 float alpha() const { return this->vec[3]; }
00078 };
00079
00080 COIN_DLL_API SbColor4f operator *(const SbColor4f &c, const float d);
00081 COIN_DLL_API SbColor4f operator *(const float d, const SbColor4f &c);
00082 COIN_DLL_API SbColor4f operator /(const SbColor4f &c, const float d);
00083 COIN_DLL_API SbColor4f operator +(const SbColor4f &v1, const SbColor4f &v2);
00084 COIN_DLL_API SbColor4f operator -(const SbColor4f &v1, const SbColor4f &v2);
00085 COIN_DLL_API int operator ==(const SbColor4f &v1, const SbColor4f &v2);
00086 COIN_DLL_API int operator !=(const SbColor4f &v1, const SbColor4f &v2);
00087
00088 #endif // !COIN_SBCOLOR4F_H