Skip to content

Instantly share code, notes, and snippets.

@aciceri
Created May 13, 2015 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aciceri/9ff5b217088d4614473d to your computer and use it in GitHub Desktop.
Save aciceri/9ff5b217088d4614473d to your computer and use it in GitHub Desktop.
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