From 3e75e93bcc50498f34dc2d121bf2b7bc2f3316a9 Mon Sep 17 00:00:00 2001 From: Martin Nilsson <mani@lysator.liu.se> Date: Wed, 3 Jan 2001 20:48:43 +0100 Subject: [PATCH] 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 --- lib/modules/Colors.pmod | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/modules/Colors.pmod b/lib/modules/Colors.pmod index fc50c7f0d2..08e0d1541f 100644 --- a/lib/modules/Colors.pmod +++ b/lib/modules/Colors.pmod @@ -455,12 +455,6 @@ COLOR(yellow4,139,139,0); 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,24 +467,27 @@ array(int) hsv_to_rgb(array(int)|int hv, int|void sv, int|void vv) 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-" "); - -#ifdef ROXEN - if(html_32_colors[from]) from = html_32_colors[from]; -#endif - - if(color=Image.Color(from)) return color->rgb(); - - from = replace(from, "gray", "grey"); - if(color=Image.Color(from)) return color->rgb(); + if(color=Image.Color.guess(from)) return color->rgb(); - from = "#" + from; - if(color=Image.Color(from)) return color->rgb(); + from = replace(lower_case(from), "gray", "grey"); + if(color=Image.Color.guess(from)) return color->rgb(); // Lets call it black and be happy..... :-) return ({ 0,0,0 }); -- GitLab