Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import math
  2. import random
  3. from PIL import Image
  4. imgx = 4000
  5. imgy = 2250
  6. image = Image.new("RGB", (imgx, imgy))
  7. maxIt = 100000
  8.  
  9. s = math.sqrt(3.0)
  10. def f(z):
  11. return 3.0 / (1.0 + s - z) - (1.0 + s) / (2.0 + s)
  12. ifs = ["f(z)", "f(z) * complex(-9.2, s) / 2.2", "f(z) * complex(-2.0, -s) / 4.2", "f(z) / complex(1.2, s) * 6.2"]
  13.  
  14. xa = -0.9
  15. xb = 0.9
  16. ya = -0.75
  17. yb = 0.75
  18.  
  19. z = complex(0.0, 0.0)
  20. for i in range(maxIt):
  21. z = eval(ifs[random.randint(0, 3)])
  22. kx = int((z.real - xa) / (xb - xa) * (imgx - 1))
  23. ky = int((z.imag - ya) / (yb - ya) * (imgy - 1))
  24. if kx >=0 and kx < imgx and ky >= 0 and ky < imgy:
  25. image.putpixel((kx, ky), (255, 255, 255))
  26.  
  27. image.save("g.png", "PNG")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement