Skip to content

Instantly share code, notes, and snippets.

@pr1ntf
Forked from windytan/mandelbrot.pl
Created October 23, 2015 19:28
Show Gist options
  • Save pr1ntf/1b94959d0002836a8fbf to your computer and use it in GitHub Desktop.
Save pr1ntf/1b94959d0002836a8fbf to your computer and use it in GitHub Desktop.
@size = (1920,1080);
@center = (-.743653135,.131826563);
$zoom = .000014628;
$max_it = 700;
open U, "|convert -size $size[0]x$size[1] -depth 8 gray:- mandel.png";
for $py (0..$size[1]-1) {
$y0 = $center[1] + ($py/($size[0]-1) - .5) * $zoom;
for $px (0..$size[0]-1) {
$x0 = $center[0] + ($px/($size[0]-1) - .5) * $zoom;
$x = $y = $it = 0;
while ($x*$x + $y*$y < 2*2 && $it++ < $max_it) {
$xt = $x*$x - $y*$y + $x0;
$y = 2*$x*$y + $y0;
$x = $xt;
}
print U chr($it >= $max_it ? 0 : ($it*3) % 256);
}
}
close U;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment