This is not the most elegant perl by a long shot, It seems to me
that the way to do this would be a subroutine that takes a color in hex
and stuffs it into a table field, so that I wouldn't have to duplicate
the script 8 times.
#!/usr/bin/perl -w
use CGI qw(:standard);
print header();
print start_html(-title=>"Lots of colors",
-text=>"black",
-link=>"#ff0000",
-vlink=>"#0000FF",
-alink=>"#00ff00");
$how =param("how");
if ($how eq "yes" ) {
info();
} else {
info();
red();
green();
blue();
greyscale();
yellow();
cyan();
magenta();
colors();
}
print end_html();
sub info {
if ($how eq "yes") {
print ("This is not the most elegant perl by a long shot, It seems to me \
that the way to do this would be a subroutine that takes a color in hex\
and stuffs it into a table field, so that I wouldn\'t have to duplicate\
the script 8 times.<hr>");
$info = `cat colors.pl`;
# these substitutions don't look right because they worked on themselves
# before you got to see them, but it really doesn't matter as they're
# just to make the "<" and ">" show up properly and not get interpreted
# by the browser as tags.
$info =~ s/</</g ;
$info =~ s/>/>/g ;
print pre($info); # the <PRE> tags
} else {
$info = <<INFO;
Here's a bunch of colors with their descriptions in hex.
It's not totally useful, as it doesn't let you pick the axis (yet).
<br>
click <a href="http://www.mahonkin.com/~milktree/colors.pl?how=yes">here</a>
to see the perl script that generated this page.
<br>
<a href="http://www.domtools.com/~pab/colors/">Here</a> is another page on
web browser colors that's really quite useful.
INFO
print $info;
} #end of if
} #enf of info subroutine
sub colors {
@values = ("00", 10, 20, 30, 40, 50, 60, 70, 80, 90, "a0", "b0", "c0", "d0", "e0", "f0", "ff");
$values=@values;
print h2("lots of colors");
print (" Add blue left to right, green top to bottom of each group, add red between groups.");
print ("<table width=100% >\n\n");
print ("\n<tr>");
my $r=0;
while ($r<$values) {
my $g=0;
while ($g<$values) {
my $b=0;
while ($b<$values) {
print ("<td bgcolor=\"#");
print ($values[$r], $values[$g], $values[$b]);
print ("\">");
print ( $values[$r], $values[$g], $values[$b]);
$b ++
}
print ("\n<tr>");
$g ++;
}
$r ++
}
print ("</table>");
}
###### this bit is the grayscale part
sub greyscale {
print h3("All 256 pure greys");
print ("<table width=100%>\n\n");
print ("\n<tr>");
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print ("\">");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
print ("</table>");
}
#### red only
sub red {
print h3("black to white through red");
print ("<table width=100%>\n\n");
print ("\n<tr>");
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, c, f);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#");
print $full[$bn], $full[$ln] ;
print ("0000\">");
print $full[$bn], $full[$ln] ;
print ("0000");
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
pink();
}
#### pink only
sub pink {
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, c, f);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#ff");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print ("\">");
print ("ff");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
print ("</table>");
}
#### green only
sub green {
print h3("black to white through green");
print ("<table width=100%>\n\n");
print ("\n<tr>");
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#00");
print $full[$bn], $full[$ln] ;
print ("00\">00");
print $full[$bn], $full[$ln] ;
print ("00");
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
lightgreen();
}
#### lightgreen only
sub lightgreen {
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#");
print $full[$bn], $full[$ln] ;
print ("ff");
print $full[$bn], $full[$ln] ;
print ("\">");
print $full[$bn], $full[$ln] ;
print ("ff");
print $full[$bn], $full[$ln] ;
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
print ("</table>");
}
#### lightblue only
sub lightblue {
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print ("ff\">");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print ("ff");
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
}
#### blue only
sub blue {
print h3("black to white through blue");
print ("<table width=100%>\n\n");
print ("\n<tr>");
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#0000");
print $full[$bn], $full[$ln] ;
print ("\">0000");
print $full[$bn], $full[$ln] ;
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
lightblue();
print ("</table>");
}
#### yellow only
sub yellow {
print h3("All 256 \"pure\" yellows");
print ("<table width=100%>\n\n");
print ("\n<tr>");
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print ("00\">");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print ("00");
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
print ("</table>");
}
#### cyan only
sub cyan {
print h3("All 256 \"pure\" cyans");
print ("<table width=100%>\n\n");
print ("\n<tr>");
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#00");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
print ("\">00");
print $full[$bn], $full[$ln] ;
print $full[$bn], $full[$ln] ;
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
print ("</table>");
}
#### magenta only
sub magenta {
print h3("All 256 \"pure\" magentas");
print ("<table width=100%>\n\n");
print ("\n<tr>");
@full = ("0", 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f");
#@full = ("0", 4, 8, C, F);
$full=@full;
my $bn=0;
while ($bn<$full) {
my $ln=0;
while ($ln<$full) {
print ("<td bgcolor=\"#");
print $full[$bn], $full[$ln] ;
print ("00");
print $full[$bn], $full[$ln] ;
print ("\">");
print $full[$bn], $full[$ln] ;
print ("00");
print $full[$bn], $full[$ln] ;
$ln ++;
}
print ("\n<tr>");
$bn ++;
}
print ("</table>");
}