Since showrgb also prints out the rgb values you can use the brightness equation to determine foreground font (white or black)... something like:
#!/usr/bin/perl use strict; my @colorinfo=<DATA>; my $i = rand @colorinfo; my $line=$colorinfo[$i]; $line=~/(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/; my $brightness=($1*299+$2*587+$3*114)/1000; my $fg=$brightness>135?"black":"white"; exec("xterm -fg $fg -bg \'$4\' -font 6x13 -ls -sb -sl 1000 &"); __DATA__ 199 21 133 medium violet red 176 196 222 light steel blue 102 139 139 paleturquoise4 159 121 238 mediumpurple2 141 182 205 lightskyblue3 0 238 118 springgreen2 255 160 122 light salmon 154 205 50 yellowgreen 178 58 238 darkorchid2 69 139 116 aquamarine4 71 60 139 slateblue4 131 111 255 slateblue1 192 255 62 olivedrab1 139 105 20 goldenrod4 205 155 29 goldenrod3 142 229 238 cadetblue2
... and so forth. (I just concatenated showrgb to the bottom of my script.) 135 was about the value that worked best for my eyes in terms of a cut off between brightness warranting a black foreground color or a white.

In reply to Re: Random xterms in OpenWindows by jcc
in thread Random xterms in OpenWindows by insensate

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.