Last active
November 3, 2016 09:14
-
-
Save utgwkk/cb3b6db658f1be0c4f316757dca3f491 to your computer and use it in GitHub Desktop.
Burning ship fractal https://gyazo.com/87b8fc56ae22cd9d3966587cd34839d6
This file contains hidden or 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 | |
| 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