Skip to content

Instantly share code, notes, and snippets.

@windytan
Last active October 28, 2015 13:15
Show Gist options
  • Save windytan/6d97e9937e856c2241b1 to your computer and use it in GitHub Desktop.
Save windytan/6d97e9937e856c2241b1 to your computer and use it in GitHub Desktop.
@size = (1920, 1080);
@center = (-.743653135, .131826563);
$zoom = .000014628;
$max_it = 700;
$oversample = 2;
$_ *= $oversample for (@size);
open $fh, "|-", "convert -size ".join("x",@size)." -depth 8 gray:- ".
"-resize ".(100/$oversample)."% mandel.png";
for $py (1 .. $size[1]) {
$y0 = $center[1] + ($py/$size[0] - .5) * $zoom;
for $px (1 .. $size[0]) {
$x0 = $center[0] + ($px/$size[0] - .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 $fh pack("C",$it >= $max_it ? 0 : 127*(1+sin(3.1416/192 * $it)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment