1
# Copyright (c) AT&T Corp. 1994, 1995.
2
# This code is licensed by AT&T Corp. For the
3
# terms and conditions of the license, see
4
# http://www.research.att.com/orgs/ssr/book/reuse
6
function rgb_to_hsb(r,g,b) {
7
r = r / 255.0; g = g / 255.0; b = b / 255.0;
8
max = r; if (max < g) max = g; if (max < b) max = b;
9
min = r; if (min > g) min = g; if (min > b) min = b;
11
if (max != 0) s = (max - min) / max;
19
if (r == max) h = bc - gc;
21
if (g == max) h = 2.0 + (rc - bc);
22
else h = 4.0 + (gc - rc);
25
if (h < 0.0) h = h + 360.0;
27
h = h / 360.0 * 255.0;
32
BEGIN { s = ARGV[1]; gsub("\\.","_",s); printf("hsbcolor_t %s[] = {\n",s); }
37
printf("{\"%s\",%d,%d,%d},\n",$1,h,s,v);
39
END { printf("};\n"); }