Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Last active November 3, 2016 09:14
Show Gist options
  • Save utgwkk/cb3b6db658f1be0c4f316757dca3f491 to your computer and use it in GitHub Desktop.
Save utgwkk/cb3b6db658f1be0c4f316757dca3f491 to your computer and use it in GitHub Desktop.
import itertools
from PIL import Image
SIZE = 4096
RAD = SIZE / 4.0
result = Image.new("L", (SIZE, SIZE))
for r, i in itertools.product(range(SIZE), repeat=2):
c = complex(r / RAD - 2.0, i / RAD - 2.0)
z = 0
print(c)
result.putpixel((r, i), 255)
for cnt in range(100):
z = (abs(z.real) + abs(z.imag) * 1.0j)**2 + c
if not (-2 < z.real < 2) or not (-2 < z.imag < 2):
result.putpixel((r, i), int(cnt * 2.56))
break
result.save('burning_ship.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment