Branch: Tag:

2003-02-06

2003-02-06 21:23:27 by Martin Nilsson <mani@lysator.liu.se>

Added default mechanism to parse_color.

Rev: lib/modules/Colors.pmod:1.14

78:   //! This function returns the RGB values that corresponds to the   //! color that is provided by name to the function. It is   //! essentially calling @[Image.Color.guess()], but returns the - //! value for black if it failes. + //! default value (or black if none is provided) if it failes.   //! - array(int(0..255)) parse_color(string name) + array(int(0..255)) parse_color(string name, void|array(int) def)   {    Image.Color.Color color; -  if(!name || !sizeof(name)) return ({ 0,0,0 }); // Odd color... +  if(!name || !sizeof(name)) return def||({ 0,0,0 }); // Odd color...       if(color=Image.Color.guess(name)) return color->rgb();   
91:    if(color=Image.Color.guess(name)) return color->rgb();       // Lets call it black and be happy..... :-) -  return ({ 0,0,0 }); +  return def||({ 0,0,0 });   }      //! Tries to find a name to color described by the provided RGB