lemon/color.h
changeset 208 4317d277ba21
parent 157 2ccc1afc2c52
child 209 765619b7cbb2
equal deleted inserted replaced
3:9fa1545dc66a 4:b318b780a7e5
   106   {
   106   {
   107     std::vector<Color> colors;
   107     std::vector<Color> colors;
   108   public:
   108   public:
   109     ///Constructor
   109     ///Constructor
   110 
   110 
   111     ///Constructor 
   111     ///Constructor.
   112     ///\param have_white indicates whether white is amongst the
   112     ///\param have_white Indicates whether white is among the
   113     ///provided initial colors (\c true) or not (\c false). If it is true,
   113     ///provided initial colors (\c true) or not (\c false). If it is true,
   114     ///white will be assigned to \c 0.
   114     ///white will be assigned to \c 0.
   115     ///\param num the number of the allocated colors. If it is \c -1,
   115     ///\param num The number of the allocated colors. If it is \c -1,
   116     ///the default color configuration is set up (26 color plus optionaly the
   116     ///the default color configuration is set up (26 color plus optionaly the
   117     ///white).  If \c num is less then 26/27 then the default color
   117     ///white).  If \c num is less then 26/27 then the default color
   118     ///list is cut. Otherwise the color list is filled repeatedly with
   118     ///list is cut. Otherwise the color list is filled repeatedly with
   119     ///the default color list.  (The colors can be changed later on.)
   119     ///the default color list.  (The colors can be changed later on.)
   120     Palette(bool have_white=false,int num=-1)
   120     Palette(bool have_white=false,int num=-1)
   151         colors.push_back(Color(1,0,.5));
   151         colors.push_back(Color(1,0,.5));
   152         colors.push_back(Color(0,1,.5));
   152         colors.push_back(Color(0,1,.5));
   153         colors.push_back(Color(0,.5,1));
   153         colors.push_back(Color(0,.5,1));
   154         colors.push_back(Color(.5,0,1));
   154         colors.push_back(Color(.5,0,1));
   155       } while(int(colors.size())<num);
   155       } while(int(colors.size())<num);
   156       //    colors.push_back(Color(1,1,1));
       
   157       if(num>=0) colors.resize(num);
   156       if(num>=0) colors.resize(num);
   158     }
   157     }
   159     ///\e
   158     ///\e
   160     Color &operator[](int i)
   159     Color &operator[](int i)
   161     {
   160     {
   169     ///\e
   168     ///\e
   170     void set(int i,const Color &c)
   169     void set(int i,const Color &c)
   171     {
   170     {
   172       colors[i%colors.size()]=c;
   171       colors[i%colors.size()]=c;
   173     }
   172     }
   174     ///Add a new color to the end of the color list.
   173     ///Adds a new color to the end of the color list.
   175     void add(const Color &c) 
   174     void add(const Color &c) 
   176     {
   175     {
   177       colors.push_back(c);
   176       colors.push_back(c);
   178     }
   177     }
   179 
   178 
   180     ///Sets the number of the exiting colors.
   179     ///Sets the number of the existing colors.
   181     void resize(int s) { colors.resize(s);}
   180     void resize(int s) { colors.resize(s);}
   182     ///Returns the number of the existing colors.
   181     ///Returns the number of the existing colors.
   183     int size() const { return int(colors.size());}
   182     int size() const { return int(colors.size());}
   184   };
   183   };
   185 
   184