#!/usr/bin/perl use strict; use Time::HiRes qw(usleep);my @j=split //,'just another perl hacker' ;my $clear =( $^O=~/win/i? 'cls':'clear' );my ($ +w,$h)=(80,23);my ($hw,$hh,$ky) =($w/2,int$h /2,0.5); my $times= +20;my @mix;my $M;my ($ofs,$len ,$hl)=($hh*$w+$hw-@j/2,scalar@j ,@j/2); +my $pi=3.1416;sub mix {for ( 1.. $times){my $f=int rand @j;my $t ;SAME: +$t= int rand @j ;my $r=int abs(($f-$t) /2);goto SAME if $r< +5|| $j[$f]eq $j [$t]||($j[ $f]eq"\040" &&$j[$t]eq" " );unshi +ft @mix,[$f,$t ,$r];@j[$f ,$t]=@j[$t, $f];} 1;} sub fill{$M +=' 'x($w*$h);}sub show (@){system "$clear +";print"$M\n";usleep( 10000)} sub line(@ ){subst +r($M,$ofs,$len)=join '',@j;} sub letter {my($l0,$l1 ,$a,$r,$c)=@_ ;substr +($M ,($hh+int (sin($a) * $r*$ky))*$w +$c+int(cos( $a)*$r) +,1) =$l0;substr($M,($hh-int (sin($a)*$r *$ky))*$w+$c- int(cos +($a )*$r),1)=$l1;} sub pair {my($f,$t,$r)=@_; my @c=(@j[$f, $t]); s +how line fill; $j[$f]=$j[$t ]="\040";my $xc=$hw-$hl+$r+($f <$t?$f: +$t) ;my $da=$pi/6;my $a= $da; while($a<$pi){ line fill and s +how letter(@c,$a ,$r,$xc);$a+= $da;}@j[$t, $f]=@c}sub go {pair(@$_) for@mix;show line fill}
mix and go
In reply to Some rotations (first JAPH) by maard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |