This is really great. I wound up doing something like this by hand (by eye?) the last time I needed to generate a distinct color palette (player colors in an online map game).
Similar concept: I like to be able to generate terminals of varying-but-viewable color schemes. I'd like to tweak this to use more an HSV than RGB scheme.<p>#!/usr/bin/gawk -f<p>function ranint (x) { return int(rand() * x) }
function hex (x) { return sprintf("%02x", x) }<p>BEGIN {<p><pre><code> mc = 96 # max color
# Seed RNG using nanoseconds
cmd="date +%N"
cmd | getline seed
close(cmd)
srand(seed)
r = ranint(mc)
g = ranint(mc)
b = ranint(mc)
printf( "rxvt -bg \x27#%s%s%s\x27 -fg gold -cr blue &\n", hex(r), hex(g), hex(b) )
}</code></pre>
The "ceiling" symbols (left/right square bracket upper corner) at the beginning of the explanatory text are displayed as unknown character boxes here (Win7/Chrome).