Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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:

  • The background color of each row is randomly generated, and keep the same for all cells in the row;
  • The foreground color is generated by different solutions, identified by author's name.

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

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found