Julia set: Difference between revisions

m
→‎{{header|Perl}}: mor code simplifications
m (→‎{{header|Perl}}: minor code simplification)
m (→‎{{header|Perl}}: mor code simplifications)
Line 95:
 
my $maxIter = 255;
my ($cX, $cY) = (-0.7, 0.27015);
my ($moveX, $moveY) = (0, 0);
 
my $color = Imager::Color->new('#000000');
 
foreach my $x (0 .. $w - 1) {
Line 103 ⟶ 105:
my $zy = (($y - $h / 2) / (0.5 * $zoom * $h) + $moveY);
my $i = $maxIter;
forwhile (; $zx**2 + $zy**2 < 4 and --$i >= 1; --$i0) {
($zy, $zx) = (2.0 * $zx * $zy + $cY, $zx**2 - $zy**2 + $cX);
}
my $color->set(hsv => [$i / $maxIter * 360, 1, $i Imager::Color->new( 0 ? 1 : 0]);
hsv => [($i / $maxIter) * 360, 1, $i > 1 ? 1 : 0]
);
$img->setpixel(x => $x, y => $y, color => $color);
}
2,747

edits