00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VRS_COLOR_H
00021 #define VRS_COLOR_H
00022
00023 #include <vrs/vertexdata.h>
00024
00025 namespace VRS {
00026
00033 class VRS_CORE_API Color : public VertexData<4, float> {
00034
00035 public:
00036 explicit Color(float grey = 0.0f);
00037 explicit Color(double grey);
00039 Color(float red, float green, float blue, float alpha = 1.0f);
00040 Color(double red, double green, double blue, double alpha = 1.0);
00042
00043 bool operator==(const Color& other) const;
00045 bool operator!=(const Color& other) const;
00047 bool operator<(const Color& other) const;
00049
00050 float& operator[](unsigned int i);
00052 float operator[](unsigned int i) const;
00054
00055 Color& operator+=(const Color& col);
00057
00060 Color& operator-=(const Color& col);
00062
00065 Color& operator*=(float coef);
00066 Color& operator*=(double coef);
00068
00071 Color& operator/=(float coef);
00072 Color& operator/=(double coef);
00074
00078 Color operator+(const Color& col) const;
00080
00083 Color operator-(const Color& col) const;
00085
00088 Color operator*(float coef) const;
00089 Color operator*(double coef) const;
00091
00094 Color operator/(float coef) const;
00095 Color operator/(double coef) const;
00097
00101 static Color hsv(float hue, float saturation, float value, float alpha = 1.0f);
00102 static Color hsv(double hue, double saturation, double value, double alpha = 1.0);
00104
00110 float hue() const;
00112 float saturation() const;
00114 float value() const;
00116
00117 float luminance() const;
00119
00122 static const Color aquamarine;
00123 static const Color black;
00124 static const Color blue;
00125 static const Color blue_violet;
00126 static const Color brilliant_red;
00127 static const Color brown;
00128 static const Color cadet_blue;
00129 static const Color coral;
00130 static const Color cornflower_blue;
00131 static const Color cyan;
00132 static const Color dk_brown;
00133 static const Color dk_gray;
00134 static const Color dk_green;
00135 static const Color dk_olive_green;
00136 static const Color dk_orchid;
00137 static const Color dk_plum;
00138 static const Color dk_slate_blue;
00139 static const Color dk_slate_gray;
00140 static const Color dk_tan;
00141 static const Color dk_turquoise;
00142 static const Color dim_brown;
00143 static const Color dim_gray;
00144 static const Color firebrick;
00145 static const Color forest_green;
00146 static const Color gold;
00147 static const Color goldenrod;
00148 static const Color gray;
00149 static const Color green;
00150 static const Color green_yellow;
00151 static const Color grey;
00152 static const Color indian_red;
00153 static const Color khaki;
00154 static const Color lt_blue;
00155 static const Color lt_gray;
00156 static const Color lt_sky_blue;
00157 static const Color lt_steel_blue;
00158 static const Color lime_green;
00159 static const Color magenta;
00160 static const Color maroon;
00161 static const Color med_aquamarine;
00162 static const Color med_blue;
00163 static const Color med_brown;
00164 static const Color med_forest_green;
00165 static const Color med_goldenrod;
00166 static const Color med_gray;
00167 static const Color med_grey;
00168 static const Color med_orchid;
00169 static const Color med_plum;
00170 static const Color med_sea_green;
00171 static const Color med_slate_blue;
00172 static const Color med_spring_green;
00173 static const Color med_turquoise;
00174 static const Color med_violet_red;
00175 static const Color midnight_blue;
00176 static const Color navy;
00177 static const Color navy_blue;
00178 static const Color orange;
00179 static const Color orange_red;
00180 static const Color orchid;
00181 static const Color pale_green;
00182 static const Color pink;
00183 static const Color plum;
00184 static const Color red;
00185 static const Color salmon;
00186 static const Color sea_green;
00187 static const Color sienna;
00188 static const Color silver;
00189 static const Color sky_blue;
00190 static const Color slate_blue;
00191 static const Color slate_gray;
00192 static const Color spring_green;
00193 static const Color steel_blue;
00194 static const Color med_tan;
00195 static const Color thistle;
00196 static const Color turquoise;
00197 static const Color violet;
00198 static const Color violet_red;
00199 static const Color wheat;
00200 static const Color white;
00201 static const Color yellow;
00202 static const Color yellow_green;
00203
00204 private:
00205 typedef VertexData<4, float> BASE;
00206 };
00207
00208 inline bool Color::operator==(const Color& c) const { return BASE::operator==(c); }
00209 inline bool Color::operator!=(const Color& c) const { return BASE::operator!=(c); }
00210 inline bool Color::operator< (const Color& c) const { return BASE::operator< (c); }
00211
00212 inline float& Color::operator[](unsigned int i) { return BASE::operator[](i); }
00213 inline float Color::operator[](unsigned int i) const { return BASE::operator[](i); }
00214
00215 inline Color operator*(float coef, const Color& col) { return (col * coef); }
00216 inline Color operator*(double coef, const Color& col) { return (col * coef); }
00217 inline Color Color::operator/(float d) const { return operator*(1.0f / d); }
00218 inline Color Color::operator/(double d) const { return operator*(1.0 / d); }
00219
00220 inline Color& Color::operator/=(float d) { return operator*=(1.0f / d); }
00221 inline Color& Color::operator/=(double d) { return operator*=(1.0 / d); }
00222
00223 inline Color Color::operator+(const Color& c) const {
00224 return Color(data_[0]+c.data_[0], data_[1]+c.data_[1], data_[2]+c.data_[2], data_[3]);
00225 }
00226
00227 inline Color Color::operator-(const Color& c) const {
00228 return Color(data_[0]-c.data_[0], data_[1]-c.data_[1], data_[2]-c.data_[2], data_[3]);
00229 }
00230
00231 inline Color Color::operator*(float c) const {
00232 return Color(data_[0]*c, data_[1]*c, data_[2]*c, data_[3]);
00233 }
00234 inline Color Color::operator*(double c) const {
00235 return (*this * static_cast<float>(c));
00236 }
00237
00238 extern VRS_CORE_API std::ostream& operator<<(std::ostream&, const Color&);
00239 extern VRS_CORE_API std::istream& operator>>(std::istream&, Color&);
00240
00241 }
00242
00243 #endif // VRS_COLOR_H