00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef DrawingColor_INCLUDED
00030 #define DrawingColor_INCLUDED
00031
00032 #include <string>
00033 #include <sstream>
00034
00036
00037
00038
00040 class DrawingColor {
00041 public:
00042
00043
00044 DrawingColor(const std::string &name="white",unsigned char red=255,unsigned char green=255,unsigned char blue=255);
00045
00046 DrawingColor(const std::string &name,const std::string &postScriptOrHexTriplet);
00047
00048 DrawingColor(const std::string &name,double h,double s, double v);
00049
00050
00051 struct compare
00052 {
00053 bool operator()(const DrawingColor & c1, const DrawingColor & c2) const
00054 {
00055 return strcasecmp(c1._name.c_str(), c2._name.c_str() ) < 0;
00056 }
00057 };
00058
00059 void set(unsigned char red, unsigned char green, unsigned char blue);
00060 void set(const std::string &color);
00061 void setFromHSV(double h, double s, double v);
00062 std::string get(void) const;
00063 std::string getName(void) const;
00064 std::string getComplement(void) const;
00065 std::string getPostscript(void) const;
00066 bool useBlackInk(void) const;
00067
00068 static void setCutoffAdjustment(double value);
00069 static double getCutoffAdjustment(void);
00070
00071 double getHue(void) const {return _h;};
00072 double getSaturation(void) const {return _s;};
00073 double getValue(void) const {return _v;};
00074
00075
00076
00077 private:
00078
00079
00080
00081 std::string _name;
00082
00083 unsigned char _red;
00084 unsigned char _green;
00085 unsigned char _blue;
00086
00087
00088 double _h;
00089 double _s;
00090 double _v;
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 static int _cutoff[36];
00101
00102
00103
00104
00105
00106
00107
00108 static double _cutoffAdjustment;
00109
00110 void _setColorFromString(const std::string &color);
00111 void _calculateHSV(void);
00112
00113 unsigned char _hexCharacterToInt(const char digit);
00114 std::string _intToHexString(unsigned char v) const;
00115 };
00116
00117 std::ostream& operator<<(std::ostream& s, const DrawingColor& color);
00118
00119 #endif
00120