Jump to content

Mandelbrot set: Difference between revisions

→‎{{header|Raku}}: simplifying first version and commenting the second one
(→‎{{header|UNIX Shell}}: cleaning and try to use COLUMNS and LINES)
(→‎{{header|Raku}}: simplifying first version and commenting the second one)
Line 11,411:
 
[[File:mandelbrot-raku-1.2.png|300px|thumb|right]]
<syntaxhighlight lang="perl6" line>useconstant ColorMAX_ITERATIONS = 1000;
 
constant MAX_ITERATIONS = 1000;
my $width = my $height = +(@*ARGS[0] // 800);
 
Line 11,425 ⟶ 11,423:
sub mandelbrot(Complex $z is copy, Complex $c --> Int) {
for 1 .. MAX_ITERATIONS {
$z = $z*$z + $c;
return $_ if $z.abs > 2;
}
return 0;
Line 11,432 ⟶ 11,430:
say "P3";
say "{+@re.elems} {+@im.elems}";
say "255";
my @half-screen = hyper for @im.reverse X+ @re {
use Color;
mandelbrot(0i, $_)
putmy .map({$i = (255 * sqrt(mandelbrot(0i, $_) / (MAX_ITERATIONS + 1))).Int });
}
(state @)[$i] //= Color.new(hsv => $i xx 3).rgb
}.rotor(+@im).map(&put)
}</syntaxhighlight>
 
<!-- # Not sure this version is that much modern or faster now.
for @half-screen.rotor(@im.elems) {
put .map({ (255 * sqrt($_/(MAX_ITERATIONS + 1))).Int })
.map(-> $i {
(state @)[$i] //= Color.new(hsv => $i xx 3).rgb
});
}</syntaxhighlight>
 
Alternately, a more modern, faster version.
Line 11,496 ⟶ 11,492:
}
}</syntaxhighlight>
 
-->
 
=={{header|REXX}}==
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.