70 const double & blue() const {return _b;} |
73 const double & blue() const {return _b;} |
71 ///Set the color components |
74 ///Set the color components |
72 void set(double r,double g,double b) { _r=r;_g=g;_b=b; }; |
75 void set(double r,double g,double b) { _r=r;_g=g;_b=b; }; |
73 }; |
76 }; |
74 |
77 |
|
78 /// White color constant |
|
79 extern const Color WHITE; |
|
80 /// Black color constant |
|
81 extern const Color BLACK; |
|
82 /// Red color constant |
|
83 extern const Color RED; |
|
84 /// Green color constant |
|
85 extern const Color GREEN; |
|
86 /// Blue color constant |
|
87 extern const Color BLUE; |
|
88 /// Yellow color constant |
|
89 extern const Color YELLOW; |
|
90 /// Magenta color constant |
|
91 extern const Color MAGENTA; |
|
92 /// Cyan color constant |
|
93 extern const Color CYAN; |
|
94 /// Grey color constant |
|
95 extern const Color GREY; |
|
96 /// Dark red color constant |
|
97 extern const Color DARK_RED; |
|
98 /// Dark green color constant |
|
99 extern const Color DARK_GREEN; |
|
100 /// Drak blue color constant |
|
101 extern const Color DARK_BLUE; |
|
102 /// Dark yellow color constant |
|
103 extern const Color DARK_YELLOW; |
|
104 /// Dark magenta color constant |
|
105 extern const Color DARK_MAGENTA; |
|
106 /// Dark cyan color constant |
|
107 extern const Color DARK_CYAN; |
|
108 |
75 ///Maps <tt>int</tt>s to different \ref Color "Color"s |
109 ///Maps <tt>int</tt>s to different \ref Color "Color"s |
76 |
110 |
77 ///This map assigns one of the predefined \ref Color "Color"s |
111 ///This map assigns one of the predefined \ref Color "Color"s |
78 ///to each <tt>int</tt>. It is possible to change the colors as well as their |
112 ///to each <tt>int</tt>. It is possible to change the colors as well as their |
79 ///number. The integer range is cyclically mapped to the provided set of colors. |
113 ///number. The integer range is cyclically mapped to the provided set of colors. |
89 |
123 |
90 ///Constructor |
124 ///Constructor |
91 ///\param have_white indicates whether white is |
125 ///\param have_white indicates whether white is |
92 ///amongst the provided color (\c true) or not (\c false). If it is true, |
126 ///amongst the provided color (\c true) or not (\c false). If it is true, |
93 ///white will be assigned to \c 0. |
127 ///white will be assigned to \c 0. |
94 ///\param num the number of the allocated colors. If it is \c 0 |
128 ///\param num the number of the allocated colors. If it is \c 0, |
95 ///the default color configuration is set up (26 color plus the while). |
129 ///the default color configuration is set up (26 color plus the white). |
96 ///If \c num is less then 26/27 then the default color list is cut. Otherwise |
130 ///If \c num is less then 26/27 then the default color list is cut. Otherwise |
97 ///the color list is filled repeatedly with the default color list. |
131 ///the color list is filled repeatedly with the default color list. |
98 ///(The colors can be changed later on.) |
132 ///(The colors can be changed later on.) |
99 Palette(bool have_white=false,int num=0) |
133 Palette(bool have_white=false,int num=0) |
100 { |
134 { |
165 } |
199 } |
166 ///Returns black for light colors and white for the dark ones. |
200 ///Returns black for light colors and white for the dark ones. |
167 |
201 |
168 ///Returns black for light colors and white for the dark ones. |
202 ///Returns black for light colors and white for the dark ones. |
169 inline Color distantBW(const Color &c){ |
203 inline Color distantBW(const Color &c){ |
170 double v=(.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5?1:0; |
204 return (.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5 ? WHITE : BLACK; |
171 return Color(v,v,v); |
|
172 } |
205 } |
173 |
206 |
|
207 /// @} |
|
208 |
174 } //END OF NAMESPACE LEMON |
209 } //END OF NAMESPACE LEMON |
175 |
210 |
176 #endif // LEMON_COLOR_H |
211 #endif // LEMON_COLOR_H |