Moved the gui to glemon/trunk.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
33 #include<lemon/bits/invalid.h>
35 #include<lemon/maps.h>
36 #include<lemon/bezier.h>
41 ///\brief Tools to manage RGB colors.
43 ///\author Alpar Juttner
47 ///Data structure representing RGB colors.
49 ///Data structure representing RGB colors.
55 ///Default constructor
58 Color(double r,double g,double b) :_r(r),_g(g),_b(b) {};
59 ///Returns the red component
60 double & red() {return _r;}
61 ///Returns the red component
62 const double & red() const {return _r;}
63 ///Returns the green component
64 double & green() {return _g;}
65 ///Returns the green component
66 const double & green() const {return _g;}
67 ///Returns the blue component
68 double & blue() {return _b;}
69 ///Returns the blue component
70 const double & blue() const {return _b;}
71 ///Set the color components
72 void set(double r,double g,double b) { _r=r;_g=g;_b=b; };
75 ///Maps <tt>int</tt>s to different \ref Color "Color"s
77 ///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
79 ///number. The integer range is cyclically mapped to the provided set of colors.
81 ///This is a true \ref concept::ReferenceMap "reference map", so you can also
82 ///change the actual colors.
84 class ColorSet : public MapBase<int,Color>
86 std::vector<Color> colors;
91 ///\param have_white indicates whether white is
92 ///amongst the provided color (\c true) or not (\c false). If it is true,
93 ///white will be assigned to \c 0.
94 ///\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).
96 ///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.
98 ///(The colors can be changed later on.)
99 ColorSet(bool have_white=false,int num=0)
102 if(have_white) colors.push_back(Color(1,1,1));
104 colors.push_back(Color(0,0,0));
105 colors.push_back(Color(1,0,0));
106 colors.push_back(Color(0,1,0));
107 colors.push_back(Color(0,0,1));
108 colors.push_back(Color(1,1,0));
109 colors.push_back(Color(1,0,1));
110 colors.push_back(Color(0,1,1));
112 colors.push_back(Color(.5,0,0));
113 colors.push_back(Color(0,.5,0));
114 colors.push_back(Color(0,0,.5));
115 colors.push_back(Color(.5,.5,0));
116 colors.push_back(Color(.5,0,.5));
117 colors.push_back(Color(0,.5,.5));
119 colors.push_back(Color(.5,.5,.5));
120 colors.push_back(Color(1,.5,.5));
121 colors.push_back(Color(.5,1,.5));
122 colors.push_back(Color(.5,.5,1));
123 colors.push_back(Color(1,1,.5));
124 colors.push_back(Color(1,.5,1));
125 colors.push_back(Color(.5,1,1));
127 colors.push_back(Color(1,.5,0));
128 colors.push_back(Color(.5,1,0));
129 colors.push_back(Color(1,0,.5));
130 colors.push_back(Color(0,1,.5));
131 colors.push_back(Color(0,.5,1));
132 colors.push_back(Color(.5,0,1));
133 } while(int(colors.size())<num);
134 // colors.push_back(Color(1,1,1));
135 if(num>0) colors.resize(num);
138 Color &operator[](int i)
140 return colors[i%colors.size()];
143 const Color &operator[](int i) const
145 return colors[i%colors.size()];
148 void set(int i,const Color &c)
150 colors[i%colors.size()]=c;
152 ///Sets the number of the exiting colors.
153 void resize(int s) { colors.resize(s);}
154 ///Returns the number of the existing colors.
155 std::size_t size() const { return colors.size();}
158 ///Returns a visible distinct \ref Color
160 ///Returns a \ref Color which is as different from the given parameter
161 ///as it is possible.
162 inline Color distantColor(const Color &c)
164 return Color(c.red()<.5?1:0,c.green()<.5?1:0,c.blue()<.5?1:0);
166 ///Returns black for light colors and white for the dark ones.
168 ///Returns black for light colors and white for the dark ones.
169 inline Color distantBW(const Color &c){
170 double v=(.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5?1:0;
174 } //END OF NAMESPACE LEMON
176 #endif // LEMON_COLOR_H