#!/bin/perl # sirts.pl (c) 1996-1997 Jason D. Hartline and Prescient Code Solutions. # # This is the engine behind The SIRTS Generator at http://www.coder.com/ # creations/stereo/. This code is released as is. Use it at your own risk. # This code may be distributed or modified in accordance with the GNU Public # Licence avilable with this source file at http://www.coder.com/creations/ # stereo/GPL.gz. This source file can be obtained from http://www.coder.com/ # creations/stereo/sirts.perl. Questions and comments may be sent to # jason@coder.com. # $opts{'level'}=0; $opts{'color'}=0; $opts{'depth'}=15; $opts{'cool'}=.05; $opts{'width'}=70; $opts{'symbol'}=.4; $opts{'space'}=.02; $opts{'bg'}=''; $opts{'fg'}=''; $opts{'bright'}=''; $opts{'colors'}=''; @cool=('Prescient Code!','CAN+YOU_SEE~SIRTS?','CROSS_YOUR*EYES!','CooL', 'Code','IDEA','WORLD WIDE+WEB','code IN perl','STEREO','SIRTS', 'POP OUT','three dimensional','3d fun','alt.3d'); $badchars='<>&"'; foreach (33..37,39..47,58,59,61,63,64,91..96,123..126) { push @symbol,chr; } @digits = ('0'..'9'); @loweralpha=('a'..'z'); @alpha=('a'..'z','A'..'Z'); @upperalpha=('A'..'Z'); @alphanum=('0'..'9','a'..'z','A'..'Z'); @color=('#ffffff','#000000','#ff0000','#00ff00','#0000ff','#ff00ff','#00ffff', '#ffff00'); srand; $last=0; $next=0; @text = <>; # Remove comments and options from input file. # This uses postscript style comments where lines beginning with % # are ignored and lines beginning with %% are options. foreach (@text) { chomp; if (!m/^%/) { push @input, $_; } elsif (m/^%%/) { push @opt,$_; } } #extract optinos foreach (@opt) { s/%%(.*)/$1/s; ($cmd,$opt)=split '='; $opts{lc $cmd}=$opt; } sub random { @_[rand($#_+1)]; } if ($opts{'colors'}) { @color=split(',',$opts{'colors'}); } if ($opts{'bright'}) { push @color,$opts{'bright'}; } if ($opts{'fg'}) { $text .= ''; } foreach $in (@input) { @s=(); if ($opts{'cool'}&& rand() < $opts{'cool'}) { @s = reverse(split("",random(@cool))); } while ($#s < $opts{'depth'}) { $rand=rand(); if ($rand < $opts{'symbol'}) { push @s,(&random(@symbol)); } elsif ($rand > (1.0-$opts{'space'})) { push @s,' '; } else { push @s,&random(@alphanum); } } if ($opts{'color'}) { foreach (@s) { if (rand()<$opts{'color'}) { $color=random(@color); $_="".$_.""; } } } while ($#s > $opts{'depth'}) { push @ns,pop @s; } @in=split '',' '.$in; for (;$#in < $opts{'width'};push (@in,' ')) {} @in=@in[1..$opts{'width'}]; $last=0; foreach (@in) { $next = (!m/\d/s)?$opts{'level'}:ord($_)-ord("0"); $diff=$next-$last; for(;$diff>0;$diff--) { push @ns,pop @s;} for(;$diff<0;$diff++) { push @s,pop @ns;} unshift @s, pop @s; $text .= $s[0]; $last=$next; } $text .= "\n"; } if ($opts{'fg'}) { $text .= ''; } print $text; exit;