Branch: Tag:

2001-01-03

2001-01-03 19:48:43 by Martin Nilsson <mani@lysator.liu.se>

Removed roxen specific code, since it will not be run. Added rgb_to_cmyk and cmyk_to_rgb. Increased the fuzzyness of the dwim in parse_color by using Image.Color.guess.

Rev: lib/modules/Colors.pmod:1.8

455:   COLOR(yellowgreen,154,205,50);       - #ifdef ROXEN - mapping (string:string) html_32_colors = -  ([ "green":"#008000", "maroon":"#800000", "purple":"#800080" ]); - #endif -  -  +    array(int) rgb_to_hsv(array(int)|int ri, int|void gi, int|void bi)   {    if(arrayp(ri)) return Image.Color(@ri)->hsv();
473:    return Image.Color(sprintf("@%d,%d,%d", hv,sv,vv))->rgb();   }    + array(int) rgb_to_cmyk(array(int)|int ri, int|void gi, int|void bi) + { +  if(arrayp(ri)) return Image.Color(@ri)->cmyk(); +  return Image.Color(ri,gi,bi)->cmyk(); + } +  + array(int) cmyk_to_rgb(array(int)|int c, int|void m, int|void y, int|void k) + { +  if(arrayp(c)) return Image.Color(sprintf("%%%d,%d,%d,%d", @c))->rgb(); +  return Image.Color(sprintf("%%%d,%d,%d,%d", c,m,y,k))->rgb(); + } +    array(int) parse_color(string from)   {    object color;    if(!from || !strlen(from)) return ({ 0,0,0 }); // Odd color...    -  from = lower_case(from-" "); +  if(color=Image.Color.guess(from)) return color->rgb();    - #ifdef ROXEN -  if(html_32_colors[from]) from = html_32_colors[from]; - #endif +  from = replace(lower_case(from), "gray", "grey"); +  if(color=Image.Color.guess(from)) return color->rgb();    -  if(color=Image.Color(from)) return color->rgb(); -  -  from = replace(from, "gray", "grey"); -  if(color=Image.Color(from)) return color->rgb(); -  -  from = "#" + from; -  if(color=Image.Color(from)) return color->rgb(); -  +     // Lets call it black and be happy..... :-)    return ({ 0,0,0 });   }