lemon/color.h
changeset 139 701c529ba737
parent 129 e99385bca9fe
child 157 2ccc1afc2c52
equal deleted inserted replaced
1:b5ceb18b71c7 2:9a54dbddea83
   109     std::vector<Color> colors;
   109     std::vector<Color> colors;
   110   public:
   110   public:
   111     ///Constructor
   111     ///Constructor
   112 
   112 
   113     ///Constructor 
   113     ///Constructor 
       
   114     ///\param have_white indicates whether white is amongst the
       
   115     ///provided initial colors (\c true) or not (\c false). If it is true,
       
   116     ///white will be assigned to \c 0.
   114     ///\param num the number of the allocated colors. If it is \c -1,
   117     ///\param num the number of the allocated colors. If it is \c -1,
   115     ///the default color configuration is set up (26 color plus the
   118     ///the default color configuration is set up (26 color plus optionaly the
   116     ///white).  If \c num is less then 26/27 then the default color
   119     ///white).  If \c num is less then 26/27 then the default color
   117     ///list is cut. Otherwise the color list is filled repeatedly with
   120     ///list is cut. Otherwise the color list is filled repeatedly with
   118     ///the default color list.  (The colors can be changed later on.)
   121     ///the default color list.  (The colors can be changed later on.)
   119     ///\param have_white indicates whether white is amongst the
       
   120     ///provided color (\c true) or not (\c false). If it is true,
       
   121     ///white will be assigned to \c 0.
       
   122     Palette(bool have_white=false,int num=-1)
   122     Palette(bool have_white=false,int num=-1)
   123     {
   123     {
   124       if (num==0) return;
   124       if (num==0) return;
   125       do {
   125       do {
   126         if(have_white) colors.push_back(Color(1,1,1));
   126         if(have_white) colors.push_back(Color(1,1,1));
   171     ///\e
   171     ///\e
   172     void set(int i,const Color &c)
   172     void set(int i,const Color &c)
   173     {
   173     {
   174       colors[i%colors.size()]=c;
   174       colors[i%colors.size()]=c;
   175     }
   175     }
   176     ///\e
   176     ///Add a new color to the end of the color list.
   177     void add(const Color &c) 
   177     void add(const Color &c) 
   178     {
   178     {
   179       colors.push_back(c);
   179       colors.push_back(c);
   180     }
   180     }
   181 
   181 
   183     void resize(int s) { colors.resize(s);}
   183     void resize(int s) { colors.resize(s);}
   184     ///Returns the number of the existing colors.
   184     ///Returns the number of the existing colors.
   185     int size() const { return int(colors.size());}
   185     int size() const { return int(colors.size());}
   186   };
   186   };
   187 
   187 
   188   ///Returns a visible distinct \ref Color
   188   ///Returns a visibly distinct \ref Color
   189 
   189 
   190   ///Returns a \ref Color which is as different from the given parameter
   190   ///Returns a \ref Color which is as different from the given parameter
   191   ///as it is possible.
   191   ///as it is possible.
   192   inline Color distantColor(const Color &c) 
   192   inline Color distantColor(const Color &c) 
   193   {
   193   {