for ($k = 1.2 ;$k >- 1.2 ;$k-=(2.4 )/40){ for ($j=-2.1 ;$j <.7 ;$j +=2.8 /100) {($x, $y, $i )=($j, $k, 0); + while (sqrt( $x** 2+$y + **2) <2 && $i<200) {($x ,$y )=( $x**2 -$y** 2+ $j,2 *$x*$y +$k ) ;$i++ ;} print ($i <12?( $i <4?($i <2? '#': + '%'): ($i <8?'&' :'*' )): ($i<50 ?($i <20? '+':'-') :( $i<80?',' :($i< 190 ?'.':' ') ))) ;} print"\n" ;}
Draws a Mandelbrot fractal in the terminal

Replies are listed 'Best First'.
Re: Fractal Generator
by liverpole (Monsignor) on Aug 15, 2007 at 15:36 UTC
    Very nice!  ++my $self.

    You might want to mention that the width of the terminal needs to be greater than 100 characters, to avoid line wrap.

    High marks for presentation and output both!

    Oh, and I see, too, that it's your very first post.  Congratulations on making a dazzling debut!


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
Re: Fractal Generator
by dbw (Beadle) on Aug 15, 2007 at 16:14 UTC
    This is great, really well done! ++
Re: Fractal Generator
by Argel (Prior) on Aug 15, 2007 at 23:17 UTC
    ++ Wow!! Very nice!! Julia sets next?! Or color ANSI? ;-)
      julia sets are a possibility, but I've never worked with colored ANSI text. Know a good CPAN module for that?
        You are not doing anything special (from an ANSI standpoint) so Term::ANSIColor might get the job done for you. I haven't used it but really, I think the biggest thing you need to know are the escape sequences for the colors (and maybe some other ones like bold and highlighting). The last time I dealt with any of this was a decade ago and never in Perl. Ah, the good old BBS days! :-)