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