Created
May 13, 2015 19:21
-
-
Save aciceri/9ff5b217088d4614473d to your computer and use it in GitHub Desktop.
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
from PIL import Image | |
from colorsys import hsv_to_rgb | |
hue2rgb = lambda hue: tuple([int(color * 255) for color in hsv_to_rgb(hue, 1, 1)]) | |
width, height = 300, 300 | |
image = Image.new(mode="RGB", size=(width, height), color=(0, 0, 0)) | |
xa, xb = -1.5, 1.5 | |
ya, yb = -1.5, 1.5 | |
maxstep = 100 | |
for y in range(height): | |
for x in range(width): | |
z = complex(xa + (xb - xa) * x / width, ya + (yb - ya) * y / height) | |
c = complex(0, 0.65) | |
for i in range(maxstep): | |
z = z ** 2 + c | |
if abs(z) >= 2: | |
image.putpixel((x, y), (i*7, i*7, i*7)) | |
break | |
print("Riga n. %d di %d completata" % (y+1, height)) | |
image.save("julia.png") | |
image.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment