Calculation (cont.)

After removing comments and adding a little whitespace, we can explain the rest of the program:

for ( 1 .. $i ) {                 # calculate as many images as we want
    $w *= $z; $h *= $z; $A += $a; # relative changes between images 
    for ( 0 .. $H * $W - 1 ) {    # calculate each screen "point"
        ( $U, $R, @0 ) = ( f( $_ % $W, int $_ / $W ), $n );
        ( $p, $q )     = ( $j ? ( $x, $y ) : ( $U, $R ) );
        do { ( $U, $R ) = ( $U * $U - $R * $R + $p, $U * 2 * $R + $q ) }
            until ( ( $U * $U + $R * $R > 4 ) || --$0[0] == 0 );
        print $c[ int( $0[0] * 9 / $n ) ], # print the character
              ++$_ % $W ? $# : "\n";       # and an optional newline
    }
}

$i is the number of images we want to calculate in this (mostly used when in batch-mode).

Previous | Next


Copyright © 2000-2001, Philippe "BooK" Bruhat.