color.hpp

Go to the documentation of this file.
00001 /*
00002 **    TP 4ETI CPE Lyon
00003 **    Copyright (C) 2011 Damien Rohmer
00004 **
00005 **    This program is free software: you can redistribute it and/or modify
00006 **    it under the terms of the GNU General Public License as published by
00007 **    the Free Software Foundation, either version 3 of the License, or
00008 **    (at your option) any later version.
00009 **
00010 **   This program is distributed in the hope that it will be useful,
00011 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **    GNU General Public License for more details.
00014 **
00015 **    You should have received a copy of the GNU General Public License
00016 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #ifndef _COLOR_RGB_HPP_
00020 #define _COLOR_RGB_HPP_
00021 
00022 #include <iostream>
00023 #include <exception_cpe.hpp>
00024 
00025 namespace cpe
00026 {
00028     class color
00029     {
00030     public:
00031 
00032 
00033         // ********************************************* //
00034         // ********************************************* //
00035         //  CONSTRUCTORS
00036         // ********************************************* //
00037         // ********************************************* //
00038 
00040         color();
00042         color(const unsigned char& gray);
00044         color(const unsigned char& r,const unsigned char& g,const unsigned char& b);
00045 
00046         // ********************************************* //
00047         // ********************************************* //
00048         //  ACCESS COLOR VALUE
00049         // ********************************************* //
00050         // ********************************************* //
00051 
00053         void set(const unsigned char& r,const unsigned char& g,const unsigned char& b);
00055         void get(unsigned char* r,unsigned char* g,unsigned char *b) const;
00056 
00058         const unsigned char& r() const;
00060         unsigned char& r();
00062         const unsigned char& g() const;
00064         unsigned char& g();
00066         const unsigned char& b() const;
00068         unsigned char& b();
00069 
00070         // ********************************************* //
00071         // ********************************************* //
00072         //  COLOR INTERPOLATION
00073         // ********************************************* //
00074         // ********************************************* //
00075 
00077         static color interpolate_linear(const color& c1,const color& c2,double alpha);
00078 
00079         // ********************************************* //
00080         // ********************************************* //
00081         //  I/O
00082         // ********************************************* //
00083         // ********************************************* //
00084 
00086         friend std::ostream& operator<<(std::ostream& stream,const color& c);
00087 
00088 
00089     private:
00090 
00091         // ********************************************* //
00092         // ********************************************* //
00093         //  INTERNAL STORAGE
00094         // ********************************************* //
00095         // ********************************************* //
00096 
00098         unsigned char internal_r;
00100         unsigned char internal_g;
00102         unsigned char internal_b;
00103 
00104     };
00105 
00107     class exception_color: public exception_cpe
00108     {
00109     public:
00111         exception_color():exception_cpe(){}
00113         exception_color(const std::string& msg,const std::string& file,const std::string& caller,const int& line):exception_cpe(msg,file,caller,line){}
00114     };
00115 }
00116 
00117 #endif
Generated on Mon Apr 18 20:43:30 2011 by  doxygen 1.6.3