pike.git / lib / modules / Colors.pmod

version» Context lines:

pike.git/lib/modules/Colors.pmod:87:   {    return Image.Color.cmyk(@cmyk)->rgb();   }      //! 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   //! default value (or black if none is provided) if it failes.   //!   array(3:int(0..255)) parse_color(string|zero name, -  void|array(3:int(0..255)) def) +  array(3:int(0..255)) def=({ 0,0,0 }))   {    Image.Color.Color color; -  if(!name || !sizeof(name)) return def||({ 0,0,0 }); // Odd color... +  if(!name || !sizeof(name)) return def; // Odd color...       if(color=Image.Color.guess(name)) return color->rgb();       name = replace(lower_case(name), "gray", "grey");    if(color=Image.Color.guess(name)) return color->rgb();       // Lets call it black and be happy..... :-) -  return def||({ 0,0,0 }); +  return def;   }      //! Tries to find a name to color described by the provided RGB   //! values. Partially an inverse function to @[Colors.parse_color()],   //! although it can not find all the names that @[Colors.parse_color()]   //! can find RGB values for. Returns the colors rgb hex value prepended   //! with "#" upon failure.   //!   string color_name(array(3:int(0..255))|zero rgb)   {    if(!arrayp(rgb) || sizeof(rgb)!=3) return "-";    string name = Image.Color(@rgb)->name();    return name;   }