I'd like to offer up a small conversion to make this web-based. I'm not sure how well it would perform on a low bandwidth connection, but running off my local web server it works quickly enough to completely refresh and complete the request every second. Good stuff, ++hiseldl!
#!perl
$|=1;
$w = 25;
$h = 25;
$img="."x($w*$h-1);
substr($img,11*$w+12,1,"#"); # in the middle
$,="\n";
@hour=split//,"Just";
@min =split//,"another";
@sec =split//,"Perl hacker";
print "Content-type: text/html\n\n";
print "<pre>";
@t = localtime;
$_=$img;
for $hidx(0..3) {
$newx=newx($t[2]%12*30+180,0,2+$hidx)+12;
$newy=newy($t[2]%12*30+180,0,2+$hidx)+11;
$vx = sprintf("%d", $newx);
$vy = sprintf("%d", $newy);
substr($_,$vy*$w+$vx,1,$hour[$hidx]);
}
for $midx(0..$#min) {
$newx=newx($t[1]*6,0,-4-$midx)+12;
$newy=newy($t[1]*6,0,-4-$midx)+11;
$vx = sprintf("%d", $newx);
$vy = sprintf("%d", $newy);
substr($_,$vy*$w+$vx,1,$min[$midx]);
}
for $sidx(0..$#sec) {
$newx=newx($t[0]*6,0,-1-$sidx)+12;
$newy=newy($t[0]*6,0,-1-$sidx)+11;
$vx = sprintf("%d", $newx);
$vy = sprintf("%d", $newy);
substr($_,$vy*$w+$vx,1,$sec[$sidx]);
}
print (/.{$w}/g),scalar localtime;
print '<meta http-equiv="refresh" content="1;url=">';
sub newx {
my($ang,$x,$y) = @_;
my $a=$ang * atan2(1,1)/45;# angle in radians
return
($x)*cos($a) - ($y)*sin($a);
}
sub newy {
my($ang,$x,$y) = @_;
my $a=$ang * atan2(1,1)/45;# angle in radians
return
($x)*sin($a) + ($y)*cos($a);
}
exit 0;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.