nlafferty has asked for the wisdom of the Perl Monks concerning the following question:

I was just wondering how the tables are generated in the gradient style on the Saints in our Book node. It's really cool. An too avoid the bottom cells from getting too dark lets reverse the order before it does, then back again for really long lists. Just curious. Thanks.

Replies are listed 'Best First'.
Re: Table generation (Saints in our Book)
by larsen (Parson) on Nov 26, 2001 at 04:47 UTC
    Since you have asked it, here a portion of the actual code that produces Saints in our book page:
    my $step = 0; my $str = ""; my $color; my $range = { "min" => 130, "max" => 230, "steps" => 50 }; my $curr; # ... omissis ... while($node = $csr->fetchrow_hashref) { # ... omissis ... $curr = $$range{max} - (($$range{max} - $$range{min})/$$range{steps}) * $step; $curr = sprintf("%02x", $curr); $color = "#" . $curr . $curr . $curr; $str .= "<tr bgcolor='" . $color . "'><td>" # ... omissis ... # ... omissis ... $step++; }
      Hmm. The list is almost unreadable with the Blue Scheme maybe a patch is in order?

      :-)

      Yves / DeMerphq
      --
      Have you registered your Name Space?

Re: Table generation (Saints in our Book)
by Fastolfe (Vicar) on Nov 26, 2001 at 02:59 UTC
    You can build a simple color gradiant by doing something like:
    my @to_color = qw/ one two three four five /; my @colors = &get_gradients(scalar @to_color); sub get_gradients { my $number = shift; my $interval = 0xff / ($number - 1); my (@c, $i); push(@c, sprintf("%02x", $interval * $i++)) while $i < $number; return @c; }
    Building an HTML table out of that information is left as an exercise for the reader. See CGI.