I'd re-work that like this:
use constant LIMIT => 20; ## It's a constant. (Should do the same for +4) my @palette = Imager::Color->new( 0,0,0 ); ## Set the first color to b +lack avoids the need for $div ... my ( $re_z, $im_z, iterations ) = (0) x 3; while ( 1 ) { my $saved = $re_z; ## It's just saving a value for use lat +er in the calculation; $temp might also do. $re_z = $re_z * $re_z - $im_z * $im_z + $re_c; $im_z = 2 * $saved * $im_z + $im_c; ++$iterations; last if $re_z * $re_z + $im_z * $im_z > 4; ## Exit and use + the iteration count to pick a color $iterations = 0, last if $iterations == LIMIT; ## beyond t +he limit, set the iterations to 0 to pick black. } $image->setpixel( x => $x, y => $y, color => $palette[ $iterat +ions ] )
In reply to Re: Refactoring: Better Variable Names For Better Understanding?
by BrowserUk
in thread Refactoring: Better Variable Names For Better Understanding? [SOLVED]
by karlgoethebier
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |