It requires an 80 character width screen, and because of the 'cls' needs windows. Should work on *nix with a 'clear' though.
It prints an animated fractal ascii-art tree blowing in the wind.
Any comments welcome.
#!/usr/bin/perl -w use strict; while(1){$:=' 'x2E3;$a+=.01;$b+=.03;$~=(sin$a+sin$b)/10+.2;system( "cls");t(40.5,0,-11/7);print$:}sub t{my($x,$y,$d,$D)=@_;($x,$y)=l( $x,$y,$d,11/++$D);$D<4||return;t($x,$y,$d-.6-$~*$d,$D);t($x,$y,$d+ .6-$~*$d,$D--)}sub l{my($x,$y)=@_;for(0..pop) {p($x+=cos$_[2],$y+= sin$_[2])}($x,$y)}sub p{substr($:,int(pop)*80+int(pop),1)='#'}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Animated Fractal Tree
by ktross (Deacon) on May 26, 2005 at 15:43 UTC | |
by reasonablekeith (Deacon) on May 26, 2005 at 16:28 UTC |