Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Algorithims with perl

Status
Not open for further replies.

vcherubini

Programmer
May 29, 2000
527
US
Hello, I have a problem that I would like to have solved. I was wondering if anyone knew of a way to write an algorithim in Perl that would generate all of the hex code colors possible. Something that would generate all of the colors between #000000 and #FFFFFF? If anyone knows that, I would be very appreciative. Thanks a lot.<br><br>-Vic
 
Nevermind, I got it working. Here is the code if anyone wants it:<br><br><FONT FACE=monospace><br><br>#!usr/bin/perl <br><br>@colors = qw(00 20 40 60 80 a0 c0 ff);<br><br>print &quot;Content-type:text/html\n\n&quot;;<br><br>print &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Colors&lt;/title&gt;&lt;/head&gt;\n&quot;;<br><br>print &quot;&lt;body&gt;\n&quot;;<br><br>for ($i=0; $i&lt;8; $i++) {<br> for ($j=0; $j&lt;8; $j++) {<br> for ($k=0; $k&lt;8; $k++) {<br><br>print &quot;&lt;font color=\#$colors[$i]$colors[$j]$colors[$k]&gt;$colors[$i]$colors[$j]$colors[$k]&lt;/font&gt;&lt;br&gt;\n&quot;;<br><br> }<br> }<br>}<br><br>print &quot;&lt;/body&gt;\n&quot;;<br>print &quot;&lt;/html&gt;\n&quot;;<br></font><br><br>Or you can go to <A HREF=" TARGET="_new"> to see it in action.<br><br>Thanks.<br><br>-Vic
 
Here is a more updated version if anyone wants to use it.<br><br><FONT FACE=monospace><br>#!usr/bin/perl <br><br>@colors = qw(00 20 40 60 80 a0 c0 ff);<br><br>print &quot;Content-type:text/html\n\n&quot;;<br><br>print &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Colors&lt;/title&gt;&lt;/head&gt;\n&quot;;<br><br>print &quot;&lt;body&gt;\n&quot;;<br><br><br>for ($i=0; $i&lt;8; $i++) {<br>print &quot;&lt;table border=1 cellpadding=0 cellspacing=0&gt;&lt;br&gt;\n&quot;;<br> for ($j=0; $j&lt;8; $j++) {<br><br> print &quot;&lt;/tr&gt;&lt;tr&gt;\n&quot;;<br><br> for ($k=0; $k&lt;8; $k++) {<br><br>print &quot;&lt;td bgcolor=\#$colors[$i]$colors[$j]$colors[$k] width=30 height=30&gt;\n&quot;;<br>print &quot;\&nbsp\;\n&quot;;<br># print &quot;&lt;font color=\#$colors[7-$i]$colors[7-$j]$colors[7-$k]&gt;$colors[$i]$colors[$j]$colors[$k]&lt;/font&gt;&lt;br&gt;\n&quot;;<br>print &quot;&lt;/td&gt;\n&quot;;<br><br><br> }<br> }<br>}<br><br>print &quot;&lt;/table&gt;\n&quot;;<br>print &quot;&lt;/body&gt;\n&quot;;<br>print &quot;&lt;/html&gt;\n&quot;;<br><br></font>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top