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

Re: Camel Time

by Theseus (Pilgrim)
on Nov 24, 2002 at 06:12 UTC ( #215482=note: print w/ replies, xml ) Need Help??

in reply to Camel Time

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;

Comment on Re: Camel Time
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://215482]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2014-04-21 12:45 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (495 votes), past polls