Julia set: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Raku}}: concurrency is a bigger win than caching) |
|||
Line 2,546: | Line 2,546: | ||
sub julia ( $png ) { |
sub julia ( $png ) { |
||
^$w .map: -> $x { |
^$w .race.map: -> $x { |
||
for ^$h -> $y { |
for ^$h -> $y { |
||
my $z = Complex.new(($x - $w / 2) / $w * 3, ($y - $h / 2) / $h * 2); |
my $z = Complex.new(($x - $w / 2) / $w * 3, ($y - $h / 2) / $h * 2); |
||
Line 2,557: | Line 2,557: | ||
} |
} |
||
} |
} |
||
sub hsv2rgb ( $h, $s, $v ){ |
sub hsv2rgb ( $h, $s, $v ){ |
||
my $c = $v * $s; |
|||
⚫ | |||
%cache{"$h|$s|$v"} //= do { |
|||
my $m = $v - $c; |
|||
[(do given $h { |
|||
⚫ | |||
when 0..^1/6 { $c, $x, 0 } |
|||
when 1/6..^1/3 { $x, $c, 0 } |
|||
when 1/3..^1/2 { 0, $c, $x } |
|||
when 1/2..^2/3 { 0, $x, $c } |
|||
when 2/3..^5/6 { $x, 0, $c } |
|||
when 5/6..1 { $c, 0, $x } |
|||
⚫ | |||
when 2/3..^5/6 { $x, 0, $c } |
|||
when 5/6..1 { $c, 0, $x } |
|||
⚫ | |||
} |
|||
}</lang> |
}</lang> |
||