Julia set: Difference between revisions
→{{header|Perl 6}}: Small tweaks, finishes in 1/3 the time, same output
Thundergnat (talk | contribs) m (→{{header|C}}: Remove vanity tags) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Small tweaks, finishes in 1/3 the time, same output) |
||
Line 1,174:
sub julia ( $png ) {
for ^$h -> $y {
my $z = Complex.new(($x - $w / 2) / $w * 3, ($y - $h / 2) / $h * 2);
Line 1,181:
$z = $z*$z + $c;
}
$png.set: $x, $y, |hsv2rgb($i / $maxIter
}
}
}
sub hsv2rgb ( $h, $s, $v ){ # inputs normalized 0-1
my $c = $v * $s;
my $x = $c * (1 - abs( (($h
my $m = $v - $c;
my ($r, $g, $b) = do given $h {
when 0..^
when
when
when
when
when
}
( $r, $g, $b )
}</lang>
|