-
-
Save utgwkk/83691138e85b5a65bdcb to your computer and use it in GitHub Desktop.
draw Mandelbrot set / requires PIL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
from PIL import Image | |
result = Image.new("L", (6400, 6400)) | |
for r, i in itertools.product(range(6400), repeat=2): | |
c = complex(r / 1600.0 - 2.0, i / 1600.0 - 2.0) | |
z = 0 | |
print(c) | |
result.putpixel((r, i), 255) | |
for cnt in range(50): | |
z = z ** 2 + c | |
if not (-2 < z.real < 2) or not (-2 < z.imag < 2): | |
result.putpixel((r, i), int(cnt * 5.12)) | |
break | |
result.save('mandel.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment