3634861997-03-21Per Hedbor #define COLOR(C,R,G,B) constant C=({R,G,B})
a36d931997-05-16Per Hedbor COLOR(aliceblue,240,248,255); COLOR(antiquewhite,250,235,215); COLOR(antiquewhite1,255,239,219); COLOR(antiquewhite2,238,223,204); COLOR(antiquewhite3,205,192,176);
3634861997-03-21Per Hedbor COLOR(antiquewhite4,139,131,120);
a36d931997-05-16Per Hedbor COLOR(aquamarine,127,255,212); COLOR(aquamarine1,127,255,212); COLOR(aquamarine2,118,238,198); COLOR(aquamarine3,102,205,170); COLOR(aquamarine4,69,139,116); COLOR(azure,240,255,255); COLOR(azure1,240,255,255); COLOR(azure2,224,238,238); COLOR(azure3,193,205,205); COLOR(azure4,131,139,139); COLOR(beige,245,245,220);
3634861997-03-21Per Hedbor COLOR(bisque,255,228,196);
a36d931997-05-16Per Hedbor COLOR(bisque1,255,228,196); COLOR(bisque2,238,213,183); COLOR(bisque3,205,183,158); COLOR(bisque4,139,125,107); COLOR(black,0,0,0); COLOR(blanchedalmond,255,235,205); COLOR(blue,0,0,255);
3634861997-03-21Per Hedbor COLOR(blue1,0,0,255);
a36d931997-05-16Per Hedbor COLOR(blue2,0,0,238);
3634861997-03-21Per Hedbor COLOR(blue3,0,0,205);
a36d931997-05-16Per Hedbor COLOR(blue4,0,0,139); COLOR(blueviolet,138,43,226); COLOR(brown,165,42,42); COLOR(brown1,255,64,64);
3634861997-03-21Per Hedbor COLOR(brown2,238,59,59);
a36d931997-05-16Per Hedbor COLOR(brown3,205,51,51); COLOR(brown4,139,35,35); COLOR(burlywood,222,184,135); COLOR(burlywood1,255,211,155); COLOR(burlywood2,238,197,145); COLOR(burlywood3,205,170,125); COLOR(burlywood4,139,115,85); COLOR(cadetblue,95,158,160); COLOR(cadetblue1,152,245,255);
3634861997-03-21Per Hedbor COLOR(cadetblue2,142,229,238);
a36d931997-05-16Per Hedbor COLOR(cadetblue3,122,197,205); COLOR(cadetblue4,83,134,139); COLOR(chartreuse,127,255,0); COLOR(chartreuse1,127,255,0); COLOR(chartreuse2,118,238,0); COLOR(chartreuse3,102,205,0); COLOR(chartreuse4,69,139,0); COLOR(chocolate,210,105,30);
3634861997-03-21Per Hedbor COLOR(chocolate1,255,127,36);
a36d931997-05-16Per Hedbor COLOR(chocolate2,238,118,33);
3634861997-03-21Per Hedbor COLOR(chocolate3,205,102,29);
a36d931997-05-16Per Hedbor COLOR(chocolate4,139,69,19); COLOR(coral,255,127,80);
3634861997-03-21Per Hedbor COLOR(coral1,255,114,86);
a36d931997-05-16Per Hedbor COLOR(coral2,238,106,80); COLOR(coral3,205,91,69); COLOR(coral4,139,62,47); COLOR(cornflowerblue,100,149,237); COLOR(cornsilk,255,248,220); COLOR(cornsilk1,255,248,220); COLOR(cornsilk2,238,232,205); COLOR(cornsilk3,205,200,177); COLOR(cornsilk4,139,136,120); COLOR(cyan,0,255,255); COLOR(cyan1,0,255,255); COLOR(cyan2,0,238,238); COLOR(cyan3,0,205,205); COLOR(cyan4,0,139,139); COLOR(darkblue,0,0,139); COLOR(darkcyan,0,139,139); COLOR(darkgoldenrod,184,134,11); COLOR(darkgoldenrod1,255,185,15); COLOR(darkgoldenrod2,238,173,14); COLOR(darkgoldenrod3,205,149,12);
3634861997-03-21Per Hedbor COLOR(darkgoldenrod4,139,101,8);
a36d931997-05-16Per Hedbor COLOR(darkgreen,0,100,0); COLOR(darkgrey,169,169,169); COLOR(darkkhaki,189,183,107); COLOR(darkmagenta,139,0,139); COLOR(darkolivegreen,85,107,47); COLOR(darkolivegreen1,202,255,112); COLOR(darkolivegreen2,188,238,104); COLOR(darkolivegreen3,162,205,90); COLOR(darkolivegreen4,110,139,61); COLOR(darkorange,255,140,0); COLOR(darkorange1,255,127,0); COLOR(darkorange2,238,118,0); COLOR(darkorange3,205,102,0); COLOR(darkorange4,139,69,0);
3634861997-03-21Per Hedbor COLOR(darkorchid,153,50,204);
a36d931997-05-16Per Hedbor COLOR(darkorchid1,191,62,255); COLOR(darkorchid2,178,58,238); COLOR(darkorchid3,154,50,205); COLOR(darkorchid4,104,34,139); COLOR(darkred,139,0,0);
3634861997-03-21Per Hedbor COLOR(darksalmon,233,150,122);
a36d931997-05-16Per Hedbor COLOR(darkseagreen,143,188,143); COLOR(darkseagreen1,193,255,193); COLOR(darkseagreen2,180,238,180); COLOR(darkseagreen3,155,205,155); COLOR(darkseagreen4,105,139,105); COLOR(darkslateblue,72,61,139); COLOR(darkslategrey,47,79,79); COLOR(darkslategrey1,151,255,255); COLOR(darkslategrey2,141,238,238); COLOR(darkslategrey3,121,205,205); COLOR(darkslategrey4,82,139,139); COLOR(darkturquoise,0,206,209); COLOR(darkviolet,148,0,211); COLOR(deeppink,255,20,147); COLOR(deeppink1,255,20,147); COLOR(deeppink2,238,18,137); COLOR(deeppink3,205,16,118); COLOR(deeppink4,139,10,80); COLOR(deepskyblue,0,191,255); COLOR(deepskyblue1,0,191,255); COLOR(deepskyblue2,0,178,238); COLOR(deepskyblue3,0,154,205); COLOR(deepskyblue4,0,104,139); COLOR(dimgrey,105,105,105); COLOR(dodgerblue,30,144,255); COLOR(dodgerblue1,30,144,255); COLOR(dodgerblue2,28,134,238); COLOR(dodgerblue3,24,116,205); COLOR(dodgerblue4,16,78,139); COLOR(firebrick,178,34,34); COLOR(firebrick1,255,48,48);
3634861997-03-21Per Hedbor COLOR(firebrick2,238,44,44);
a36d931997-05-16Per Hedbor COLOR(firebrick3,205,38,38); COLOR(firebrick4,139,26,26); COLOR(floralwhite,255,250,240); COLOR(forestgreen,34,139,34); COLOR(gainsboro,220,220,220); COLOR(ghostwhite,248,248,255); COLOR(gold,255,215,0); COLOR(gold1,255,215,0); COLOR(gold2,238,201,0); COLOR(gold3,205,173,0); COLOR(gold4,139,117,0); COLOR(goldenrod,218,165,32);
3634861997-03-21Per Hedbor COLOR(goldenrod1,255,193,37);
a36d931997-05-16Per Hedbor COLOR(goldenrod2,238,180,34); COLOR(goldenrod3,205,155,29);
3634861997-03-21Per Hedbor COLOR(goldenrod4,139,105,20);
a36d931997-05-16Per Hedbor COLOR(green,0,255,0); COLOR(green1,0,255,0); COLOR(green2,0,238,0); COLOR(green3,0,205,0); COLOR(green4,0,139,0); COLOR(greenyellow,173,255,47); COLOR(grey,190,190,190); COLOR(honeydew,240,255,240); COLOR(honeydew1,240,255,240); COLOR(honeydew2,224,238,224); COLOR(honeydew3,193,205,193); COLOR(honeydew4,131,139,131); COLOR(hotpink,255,105,180); COLOR(hotpink1,255,110,180); COLOR(hotpink2,238,106,167); COLOR(hotpink3,205,96,144); COLOR(hotpink4,139,58,98); COLOR(indianred,205,92,92); COLOR(indianred1,255,106,106); COLOR(indianred2,238,99,99); COLOR(indianred3,205,85,85); COLOR(indianred4,139,58,58); COLOR(ivory,255,255,240); COLOR(ivory1,255,255,240); COLOR(ivory2,238,238,224); COLOR(ivory3,205,205,193); COLOR(ivory4,139,139,131); COLOR(khaki,240,230,140); COLOR(khaki1,255,246,143); COLOR(khaki2,238,230,133); COLOR(khaki3,205,198,115); COLOR(khaki4,139,134,78); COLOR(lavender,230,230,250); COLOR(lavenderblush,255,240,245); COLOR(lavenderblush1,255,240,245); COLOR(lavenderblush2,238,224,229); COLOR(lavenderblush3,205,193,197); COLOR(lavenderblush4,139,131,134);
3634861997-03-21Per Hedbor COLOR(lawngreen,124,252,0);
a36d931997-05-16Per Hedbor COLOR(lemonchiffon,255,250,205); COLOR(lemonchiffon1,255,250,205); COLOR(lemonchiffon2,238,233,191); COLOR(lemonchiffon3,205,201,165);
3634861997-03-21Per Hedbor COLOR(lemonchiffon4,139,137,112);
a36d931997-05-16Per Hedbor COLOR(lightblue,173,216,230); COLOR(lightblue1,191,239,255); COLOR(lightblue2,178,223,238); COLOR(lightblue3,154,192,205); COLOR(lightblue4,104,131,139); COLOR(lightcoral,240,128,128); COLOR(lightcyan,224,255,255); COLOR(lightcyan1,224,255,255); COLOR(lightcyan2,209,238,238); COLOR(lightcyan3,180,205,205); COLOR(lightcyan4,122,139,139); COLOR(lightgoldenrod,238,221,130); COLOR(lightgoldenrod1,255,236,139); COLOR(lightgoldenrod2,238,220,130); COLOR(lightgoldenrod3,205,190,112); COLOR(lightgoldenrod4,139,129,76); COLOR(lightgoldenrodyellow,250,250,210); COLOR(lightgreen,144,238,144); COLOR(lightgrey,211,211,211); COLOR(lightpink,255,182,193); COLOR(lightpink1,255,174,185); COLOR(lightpink2,238,162,173); COLOR(lightpink3,205,140,149); COLOR(lightpink4,139,95,101);
3634861997-03-21Per Hedbor COLOR(lightsalmon,255,160,122);
a36d931997-05-16Per Hedbor COLOR(lightsalmon1,255,160,122); COLOR(lightsalmon2,238,149,114); COLOR(lightsalmon3,205,129,98); COLOR(lightsalmon4,139,87,66); COLOR(lightseagreen,32,178,170); COLOR(lightskyblue,135,206,250); COLOR(lightskyblue1,176,226,255); COLOR(lightskyblue2,164,211,238); COLOR(lightskyblue3,141,182,205);
3634861997-03-21Per Hedbor COLOR(lightskyblue4,96,123,139); COLOR(lightslateblue,132,112,255);
a36d931997-05-16Per Hedbor COLOR(lightslategrey,119,136,153); COLOR(lightsteelblue,176,196,222); COLOR(lightsteelblue1,202,225,255); COLOR(lightsteelblue2,188,210,238); COLOR(lightsteelblue3,162,181,205); COLOR(lightsteelblue4,110,123,139); COLOR(lightyellow,255,255,224); COLOR(lightyellow1,255,255,224); COLOR(lightyellow2,238,238,209); COLOR(lightyellow3,205,205,180); COLOR(lightyellow4,139,139,122); COLOR(limegreen,50,205,50); COLOR(linen,250,240,230); COLOR(magenta,255,0,255); COLOR(magenta1,255,0,255); COLOR(magenta2,238,0,238); COLOR(magenta3,205,0,205); COLOR(magenta4,139,0,139);
3634861997-03-21Per Hedbor COLOR(maroon,176,48,96);
a36d931997-05-16Per Hedbor COLOR(maroon1,255,52,179); COLOR(maroon2,238,48,167); COLOR(maroon3,205,41,144); COLOR(maroon4,139,28,98); COLOR(mediumaquamarine,102,205,170); COLOR(mediumblue,0,0,205); COLOR(mediumorchid,186,85,211); COLOR(mediumorchid1,224,102,255); COLOR(mediumorchid2,209,95,238); COLOR(mediumorchid3,180,82,205); COLOR(mediumorchid4,122,55,139); COLOR(mediumpurple,147,112,219);
3634861997-03-21Per Hedbor COLOR(mediumpurple1,171,130,255);
a36d931997-05-16Per Hedbor COLOR(mediumpurple2,159,121,238); COLOR(mediumpurple3,137,104,205); COLOR(mediumpurple4,93,71,139); COLOR(mediumseagreen,60,179,113); COLOR(mediumslateblue,123,104,238); COLOR(mediumspringgreen,0,250,154); COLOR(mediumturquoise,72,209,204); COLOR(mediumvioletred,199,21,133); COLOR(midnightblue,25,25,112); COLOR(mintcream,245,255,250); COLOR(mistyrose,255,228,225); COLOR(mistyrose1,255,228,225); COLOR(mistyrose2,238,213,210); COLOR(mistyrose3,205,183,181); COLOR(mistyrose4,139,125,123); COLOR(moccasin,255,228,181); COLOR(navajowhite,255,222,173); COLOR(navajowhite1,255,222,173); COLOR(navajowhite2,238,207,161); COLOR(navajowhite3,205,179,139); COLOR(navajowhite4,139,121,94); COLOR(navy,0,0,128); COLOR(navyblue,0,0,128); COLOR(oldlace,253,245,230); COLOR(olivedrab,107,142,35); COLOR(olivedrab1,192,255,62); COLOR(olivedrab2,179,238,58); COLOR(olivedrab3,154,205,50); COLOR(olivedrab4,105,139,34); COLOR(orange,255,165,0); COLOR(orange1,255,165,0); COLOR(orange2,238,154,0); COLOR(orange3,205,133,0); COLOR(orange4,139,90,0); COLOR(orangered,255,69,0); COLOR(orangered1,255,69,0); COLOR(orangered2,238,64,0);
3634861997-03-21Per Hedbor COLOR(orangered3,205,55,0);
a36d931997-05-16Per Hedbor COLOR(orangered4,139,37,0);
3634861997-03-21Per Hedbor COLOR(orchid,218,112,214);
a36d931997-05-16Per Hedbor COLOR(orchid1,255,131,250); COLOR(orchid2,238,122,233); COLOR(orchid3,205,105,201); COLOR(orchid4,139,71,137); COLOR(palegoldenrod,238,232,170); COLOR(palegreen,152,251,152); COLOR(palegreen1,154,255,154); COLOR(palegreen2,144,238,144);
3634861997-03-21Per Hedbor COLOR(palegreen3,124,205,124);
a36d931997-05-16Per Hedbor COLOR(palegreen4,84,139,84); COLOR(paleturquoise,175,238,238); COLOR(paleturquoise1,187,255,255); COLOR(paleturquoise2,174,238,238); COLOR(paleturquoise3,150,205,205); COLOR(paleturquoise4,102,139,139); COLOR(palevioletred,219,112,147); COLOR(palevioletred1,255,130,171); COLOR(palevioletred2,238,121,159); COLOR(palevioletred3,205,104,137); COLOR(palevioletred4,139,71,93);
3634861997-03-21Per Hedbor COLOR(papayawhip,255,239,213);
a36d931997-05-16Per Hedbor COLOR(peachpuff,255,218,185); COLOR(peachpuff1,255,218,185); COLOR(peachpuff2,238,203,173); COLOR(peachpuff3,205,175,149); COLOR(peachpuff4,139,119,101); COLOR(peru,205,133,63); COLOR(pink,255,192,203); COLOR(pink1,255,181,197); COLOR(pink2,238,169,184); COLOR(pink3,205,145,158); COLOR(pink4,139,99,108); COLOR(plum,221,160,221); COLOR(plum1,255,187,255); COLOR(plum2,238,174,238); COLOR(plum3,205,150,205); COLOR(plum4,139,102,139); COLOR(powderblue,176,224,230); COLOR(purple,160,32,240); COLOR(purple1,155,48,255); COLOR(purple2,145,44,238); COLOR(purple3,125,38,205); COLOR(purple4,85,26,139); COLOR(red,255,0,0); COLOR(red1,255,0,0); COLOR(red2,238,0,0); COLOR(red3,205,0,0); COLOR(red4,139,0,0); COLOR(rosybrown,188,143,143); COLOR(rosybrown1,255,193,193); COLOR(rosybrown2,238,180,180); COLOR(rosybrown3,205,155,155); COLOR(rosybrown4,139,105,105); COLOR(royalblue,65,105,225); COLOR(royalblue1,72,118,255); COLOR(royalblue2,67,110,238); COLOR(royalblue3,58,95,205); COLOR(royalblue4,39,64,139); COLOR(saddlebrown,139,69,19); COLOR(salmon,250,128,114); COLOR(salmon1,255,140,105); COLOR(salmon2,238,130,98); COLOR(salmon3,205,112,84); COLOR(salmon4,139,76,57); COLOR(sandybrown,244,164,96); COLOR(seagreen,46,139,87);
3634861997-03-21Per Hedbor COLOR(seagreen1,84,255,159);
a36d931997-05-16Per Hedbor COLOR(seagreen2,78,238,148); COLOR(seagreen3,67,205,128); COLOR(seagreen4,46,139,87); COLOR(seashell,255,245,238); COLOR(seashell1,255,245,238); COLOR(seashell2,238,229,222); COLOR(seashell3,205,197,191); COLOR(seashell4,139,134,130); COLOR(sienna,160,82,45); COLOR(sienna1,255,130,71); COLOR(sienna2,238,121,66); COLOR(sienna3,205,104,57);
3634861997-03-21Per Hedbor COLOR(sienna4,139,71,38); COLOR(skyblue,135,206,235);
a36d931997-05-16Per Hedbor COLOR(skyblue1,135,206,255); COLOR(skyblue2,126,192,238);
3634861997-03-21Per Hedbor COLOR(skyblue3,108,166,205);
a36d931997-05-16Per Hedbor COLOR(skyblue4,74,112,139); COLOR(slateblue,106,90,205); COLOR(slateblue1,131,111,255); COLOR(slateblue2,122,103,238); COLOR(slateblue3,105,89,205); COLOR(slateblue4,71,60,139); COLOR(slategrey,112,128,144); COLOR(slategrey1,198,226,255); COLOR(slategrey2,185,211,238); COLOR(slategrey3,159,182,205); COLOR(slategrey4,108,123,139);
3634861997-03-21Per Hedbor COLOR(snow,255,250,250);
a36d931997-05-16Per Hedbor COLOR(snow1,255,250,250); COLOR(snow2,238,233,233); COLOR(snow3,205,201,201); COLOR(snow4,139,137,137); COLOR(springgreen,0,255,127); COLOR(springgreen1,0,255,127); COLOR(springgreen2,0,238,118); COLOR(springgreen3,0,205,102); COLOR(springgreen4,0,139,69); COLOR(steelblue,70,130,180);
3634861997-03-21Per Hedbor COLOR(steelblue1,99,184,255);
a36d931997-05-16Per Hedbor COLOR(steelblue2,92,172,238); COLOR(steelblue3,79,148,205);
3634861997-03-21Per Hedbor COLOR(steelblue4,54,100,139);
a36d931997-05-16Per Hedbor COLOR(tan,210,180,140); COLOR(tan1,255,165,79);
3634861997-03-21Per Hedbor COLOR(tan2,238,154,73);
a36d931997-05-16Per Hedbor COLOR(tan3,205,133,63); COLOR(tan4,139,90,43); COLOR(thistle,216,191,216); COLOR(thistle1,255,225,255); COLOR(thistle2,238,210,238); COLOR(thistle3,205,181,205);
3634861997-03-21Per Hedbor COLOR(thistle4,139,123,139);
a36d931997-05-16Per Hedbor COLOR(tomato,255,99,71); COLOR(tomato1,255,99,71); COLOR(tomato2,238,92,66); COLOR(tomato3,205,79,57);
3634861997-03-21Per Hedbor COLOR(tomato4,139,54,38);
a36d931997-05-16Per Hedbor COLOR(turquoise,64,224,208); COLOR(turquoise1,0,245,255); COLOR(turquoise2,0,229,238); COLOR(turquoise3,0,197,205); COLOR(turquoise4,0,134,139); COLOR(violet,238,130,238); COLOR(violetred,208,32,144); COLOR(violetred1,255,62,150);
3634861997-03-21Per Hedbor COLOR(violetred2,238,58,140);
a36d931997-05-16Per Hedbor COLOR(violetred3,205,50,120);
3634861997-03-21Per Hedbor COLOR(violetred4,139,34,82);
a36d931997-05-16Per Hedbor COLOR(wheat,245,222,179); COLOR(wheat1,255,231,186); COLOR(wheat2,238,216,174); COLOR(wheat3,205,186,150); COLOR(wheat4,139,126,102); COLOR(white,255,255,255);
3634861997-03-21Per Hedbor COLOR(whitesmoke,245,245,245);
a36d931997-05-16Per Hedbor COLOR(yellow,255,255,0); COLOR(yellow1,255,255,0); COLOR(yellow2,238,238,0); COLOR(yellow3,205,205,0);
3634861997-03-21Per Hedbor COLOR(yellow4,139,139,0);
a36d931997-05-16Per Hedbor COLOR(yellowgreen,154,205,50); #ifdef ROXEN mapping (string:string) html_32_colors = ([ "black":"#000000", "green":"#008000", "silver":"#C0C0C0", "lime":"#00FF00", "gray":"#808080", "olive":"#808000", "white":"#FFFFFF","yellow":"#FFFF00", "maroon":"#800000", "navy":"#000080", "red":"#FF0000", "blue":"#0000FF", "purple":"#800080", "teal":"#008080", "fuchsia":"#FF00FF", "aqua":"#00FFFF", ]); #endif #define MAX(X,Y) ((X)>(Y)?(X):(Y)) #define MIN(X,Y) ((X)<(Y)?(X):(Y)) #define MAX3(X,Y,Z) MAX(MAX(X,Y),Z) array rgb_to_hsv(array|int ri, int|void gi, int|void bi) { float max, min; float r,g,b, delta; float h, s, v; if(arrayp(ri)) return rgb_to_hsv(@ri); r = (float)ri/255.0; g = (float)gi/255.0; b = (float)bi/255.0; max = MAX3(r,g,b); min = -(MAX3(-r,-g,-b)); v = max; if(max != 0.0) s = (max - min)/max; else return ({ -10, 0, (int)(v*255) }); delta = max-min; if(r==max) h = (g-b)/delta; else if(g==max) h = 2+(b-r)/delta; else if(b==max) h = 4+(r-g)/delta; h *= 60; // now in degrees. if(h<0) h+=360; return ({ (int)((h/360.0)*255), (int)(s*255), (int)(v*255) }); } array hsv_to_rgb(array|int hv, int|void sv, int|void vv) { if(arrayp(hv)) return hsv_to_rgb(@hv); float h,sat,v; float r,g,b; h = (hv/255.0)*(360.0/60.0); sat = sv/255.0; v = vv/255.0; if(sat==0.0) { r = g = b = v; } else { #define i floor(h) #define f (h-i) #define p (v * (1 - sat)) #define q (v * (1 - (sat * f))) #define t (v * (1 - (sat * (1 -f)))) switch((int)i) { case 6: // 360 degrees. Same as 0.. case 0: r = v; g = t; b = p; break; case 1: r = q; g = v; b = p; break; case 2: r = p; g = v; b = t; break; case 3: r = p; g = q; b = v; break; case 4: r = t; g = p; b = v; break; case 5: r = v; g = p; b = q; break; } } #undef i #undef f #undef p #undef q #undef t #define FOO(X) ((int)((X)<0.0?0:(X)>1.0?255:(int)((X)*255.0))) return ({FOO(r), FOO(g), FOO(b) }); } array(int) parse_color(string from) { int c; 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]; else #endif if(arrayp(this_object()[from])) return this_object()[from]; // Is it #rrggbb? if(from[0]=='#') { c = (int)("0x"+from[1..]); if(strlen(from)>6) return ({ c>>16, (c>>8)&255, c&255 }); return ({ (c>>8)<<4, ((c>>4)&15)<<4, (c&15)<<4 }); } else if(from[0]=='@') { // Nope. What about @h,s,v? (h=degrees, 0 to 359, s and v = percent) float h, s, v; float r, g, b; sscanf(from[1..], "%d,%d,%d", h, s, v); h = (h/360.0) * 2*3.1415; s=(s/100.0); v=(v/100.0); r=v+s*cos(h); g=v+s*cos(h+(3.1415*2.0/3.0)); b=v+s*cos(h+(3.1415*4.0/3.0)); #define FOO(X) ((int)((X)<0.0?0:(X)>1.0?255:(int)((X)*255.0))) return ({FOO(r), FOO(g), FOO(b) }); } else if(from[0]=='%') { // Nope. What about %c,m,t,k? (percent) int c,m,y,k; sscanf(from[1..], "%d,%d,%d,%d", c, m, y, k); int r=100, b=100, g=100; r-=c+k; g-=m+k; b-=y+k; if(r<0) r=0; if(g<0) g=0; if(b<0) b=0; return ({ (int)(r*2.55), (int)(g*2.55), (int)(b*2.55) }); } // No luck. It might be a color on the form rrggbb (that is, no leading '#') if(c=(int)("0x"+from)) { if(strlen(from)>5) return ({ c>>16, (c>>8)&255, c&255 }); return ({ (c>>8)<<4, ((c>>4)&15)<<4, (c&15)<<4 }); } from = replace(from-" ", "gray", "grey"); // Perhaps it is a greyscale? (gray00 to gray99) if(sscanf(from, "grey%d", c)) return ({ (c*255)/100, (c*255)/100, (c*255)/100, }); if(sscanf(from, "light%s", from)) { array c = rgb_to_hsv(parse_color(from)); c[2] = -MAX(-(c[2]+50), -255); if(c[2]==255) c[1]=MAX(c[1]-20,0); return hsv_to_rgb(c); } if(sscanf(from, "dark%s", from)) { array c = rgb_to_hsv(parse_color(from)); c[2] = MAX(c[2]-50, 0); if(c[2]==0) c[1]=MIN(c[1]+20,255); return hsv_to_rgb(c); } if(sscanf(from, "neon%s", from)) { array c = rgb_to_hsv(parse_color(from)); c[1] = 255; c[2] = 255; return hsv_to_rgb(c); } // Lets call it black and be happy..... :-) return ({ 0,0,0 }); } // Mostly used for debug. Not really all that perfect.. string color_name(array (int) from) { if(!arrayp(from) || sizeof(from)!=3) return "-"; foreach(values(this_object()), mixed c) if(equal(c,from)) return search(mkmapping(indices(this_object()),values(this_object())),c); if(equal(parse_color("grey"+(((int)from[0]*100)/255)),from)) return "grey"+(((int)from[0]*100)/255); return sprintf("#%02x%02x%02x", @from); }