color.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _COLOR_RGB_HPP_
00020 #define _COLOR_RGB_HPP_
00021
00022 #include <iostream>
00023 #include <exception_cpe.hpp>
00024
00025 #include <vector>
00026
00027 namespace cpe
00028 {
00030 class color
00031 {
00032 public:
00033
00034
00035
00036
00037
00038
00039
00040
00042 color();
00044 color(const unsigned char& gray);
00046 color(const unsigned char& r,const unsigned char& g,const unsigned char& b);
00047
00048
00049
00050
00051
00052
00053
00055 void set(const unsigned char& r,const unsigned char& g,const unsigned char& b);
00057 void get(unsigned char* r,unsigned char* g,unsigned char *b) const;
00058
00060 const unsigned char& r() const;
00062 unsigned char& r();
00064 const unsigned char& g() const;
00066 unsigned char& g();
00068 const unsigned char& b() const;
00070 unsigned char& b();
00071
00072
00073
00074
00075
00076
00077
00079 static color interpolate_linear(const color& c1,const color& c2,double alpha);
00080
00086 static color interpolate_linear(const std::vector<color>& v_color,const std::vector<double>& weights);
00087
00088
00089
00090
00091
00092
00093
00094
00096 friend color operator+(const color& c0,const color& c1);
00098 color& operator+=(const color& c);
00099
00101 friend color operator*(const double& alpha,const color& c);
00103 friend color operator*(const color& c,const double& alpha);
00105 color& operator*=(const double& alpha);
00106
00107
00108
00109
00110
00111
00112
00113
00114
00116 friend std::ostream& operator<<(std::ostream& stream,const color& c);
00117
00118
00119 private:
00120
00121
00122
00123
00124
00125
00126
00128 unsigned char internal_r;
00130 unsigned char internal_g;
00132 unsigned char internal_b;
00133
00134 };
00135
00137 class exception_color: public exception_cpe
00138 {
00139 public:
00141 exception_color():exception_cpe(){}
00143 exception_color(const std::string& msg,const std::string& file,const std::string& caller,const int& line):exception_cpe(msg,file,caller,line){}
00144 };
00145 }
00146
00147 #endif