1.1 --- a/lemon/graph_to_eps.h Mon Feb 20 06:38:18 2006 +0000
1.2 +++ b/lemon/graph_to_eps.h Mon Feb 20 06:41:12 2006 +0000
1.3 @@ -33,6 +33,7 @@
1.4 #include<lemon/invalid.h>
1.5 #include<lemon/xy.h>
1.6 #include<lemon/maps.h>
1.7 +#include<lemon/color.h>
1.8 #include<lemon/bezier.h>
1.9
1.10
1.11 @@ -44,133 +45,6 @@
1.12
1.13 namespace lemon {
1.14
1.15 -///Data structure representing RGB colors.
1.16 -
1.17 -///Data structure representing RGB colors.
1.18 -///\ingroup misc
1.19 -class Color
1.20 -{
1.21 - double _r,_g,_b;
1.22 -public:
1.23 - ///Default constructor
1.24 - Color() {}
1.25 - ///Constructor
1.26 - Color(double r,double g,double b) :_r(r),_g(g),_b(b) {};
1.27 - ///Returns the red component
1.28 - double & red() {return _r;}
1.29 - ///Returns the red component
1.30 - const double & red() const {return _r;}
1.31 - ///Returns the green component
1.32 - double & green() {return _g;}
1.33 - ///Returns the green component
1.34 - const double & green() const {return _g;}
1.35 - ///Returns the blue component
1.36 - double & blue() {return _b;}
1.37 - ///Returns the blue component
1.38 - const double & blue() const {return _b;}
1.39 - ///Set the color components
1.40 - void set(double r,double g,double b) { _r=r;_g=g;_b=b; };
1.41 -};
1.42 -
1.43 -///Maps <tt>int</tt>s to different \ref Color "Color"s
1.44 -
1.45 -///This map assigns one of the predefined \ref Color "Color"s
1.46 -///to each <tt>int</tt>. It is possible to change the colors as well as their
1.47 -///number. The integer range is cyclically mapped to the provided set of colors.
1.48 -///
1.49 -///This is a true \ref concept::ReferenceMap "reference map", so you can also
1.50 -///change the actual colors.
1.51 -
1.52 -class ColorSet : public MapBase<int,Color>
1.53 -{
1.54 - std::vector<Color> colors;
1.55 -public:
1.56 - ///Constructor
1.57 -
1.58 - ///Constructor
1.59 - ///\param have_white indicates whether white is
1.60 - ///amongst the provided color (\c true) or not (\c false). If it is true,
1.61 - ///white will be assigned to \c 0.
1.62 - ///\param num the number of the allocated colors. If it is \c 0
1.63 - ///the default color configuration is set up (26 color plus the while).
1.64 - ///If \c num is less then 26/27 then the default color list is cut. Otherwise
1.65 - ///the color list is filled repeatedly with the default color list.
1.66 - ///(The colors can be changed later on.)
1.67 - ColorSet(bool have_white=false,int num=0)
1.68 - {
1.69 - do {
1.70 - if(have_white) colors.push_back(Color(1,1,1));
1.71 -
1.72 - colors.push_back(Color(0,0,0));
1.73 - colors.push_back(Color(1,0,0));
1.74 - colors.push_back(Color(0,1,0));
1.75 - colors.push_back(Color(0,0,1));
1.76 - colors.push_back(Color(1,1,0));
1.77 - colors.push_back(Color(1,0,1));
1.78 - colors.push_back(Color(0,1,1));
1.79 -
1.80 - colors.push_back(Color(.5,0,0));
1.81 - colors.push_back(Color(0,.5,0));
1.82 - colors.push_back(Color(0,0,.5));
1.83 - colors.push_back(Color(.5,.5,0));
1.84 - colors.push_back(Color(.5,0,.5));
1.85 - colors.push_back(Color(0,.5,.5));
1.86 -
1.87 - colors.push_back(Color(.5,.5,.5));
1.88 - colors.push_back(Color(1,.5,.5));
1.89 - colors.push_back(Color(.5,1,.5));
1.90 - colors.push_back(Color(.5,.5,1));
1.91 - colors.push_back(Color(1,1,.5));
1.92 - colors.push_back(Color(1,.5,1));
1.93 - colors.push_back(Color(.5,1,1));
1.94 -
1.95 - colors.push_back(Color(1,.5,0));
1.96 - colors.push_back(Color(.5,1,0));
1.97 - colors.push_back(Color(1,0,.5));
1.98 - colors.push_back(Color(0,1,.5));
1.99 - colors.push_back(Color(0,.5,1));
1.100 - colors.push_back(Color(.5,0,1));
1.101 - } while(int(colors.size())<num);
1.102 - // colors.push_back(Color(1,1,1));
1.103 - if(num>0) colors.resize(num);
1.104 - }
1.105 - ///\e
1.106 - Color &operator[](int i)
1.107 - {
1.108 - return colors[i%colors.size()];
1.109 - }
1.110 - ///\e
1.111 - const Color &operator[](int i) const
1.112 - {
1.113 - return colors[i%colors.size()];
1.114 - }
1.115 - ///\e
1.116 - void set(int i,const Color &c)
1.117 - {
1.118 - colors[i%colors.size()]=c;
1.119 - }
1.120 - ///Sets the number of the exiting colors.
1.121 - void resize(int s) { colors.resize(s);}
1.122 - ///Returns the number of the existing colors.
1.123 - std::size_t size() const { return colors.size();}
1.124 -};
1.125 -
1.126 -///Returns a visible distinct \ref Color
1.127 -
1.128 -///Returns a \ref Color which is as different from the given parameter
1.129 -///as it is possible.
1.130 -inline Color distantColor(const Color &c)
1.131 -{
1.132 - return Color(c.red()<.5?1:0,c.green()<.5?1:0,c.blue()<.5?1:0);
1.133 -}
1.134 -///Returns black for light colors and white for the dark ones.
1.135 -
1.136 -///Returns black for light colors and white for the dark ones.
1.137 -inline Color distantBW(const Color &c){
1.138 - double v=(.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5?1:0;
1.139 - return Color(v,v,v);
1.140 -}
1.141 -
1.142 template<class MT>
1.143 class _NegY {
1.144 public: