in reply to Re: to generate a set of well contrasted colors
in thread to generate a set of well contrasted colors

Quite a few interesting replies came up for this thread!

I come up below piece of code to demon different solutions together. It displays a table that:

To run it, just type:

perl -w blah.pl > result.html

And then use your browser to view result.html.

You will see that each siolution has its merit, and a different look and feel. I think, if you love fish, then take fish; if you love meat, then take meat, all delicious.

sub random_colors { my ($r, $g, $b) = map { int rand 256 } 1 .. 3; my $lum = ($r * 0.3) + ($g * 0.59) + ($b * 0.11); my $bg = sprintf("#%02x%02x%02x", $r, $g, $b); my $fg1 = sprintf("#%02x%02x%02x", ($r + 128) % 256, ($g + 128) % +256, ($b + 128) % 256); my $fg2 = $lum < 128 ? "white" : "black"; return ($bg, $fg1, $fg2); } for (1 .. 100) { my ($bg, $fg1, $fg2) = random_colors(); print qq{ <table> <tr> <td bgcolor=$bg><font size=5 color=$fg1>pg</font></td> <td bgcolor=$bg><font size=5 color=$fg2>blokhead</font></t +d> </tr> </table> }; }

Here is just a piece of it:

pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead
pg blokhead