Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import sys
  2. import time
  3. #Zn+1 = Zn**2 + c
  4.  
  5. maxx = 1.0
  6. minx = -2.0
  7. maxy = 1.0
  8. miny = -1.0
  9. resx = 80
  10. resy = 40
  11. iterations = 100
  12. image = ""
  13.  
  14. xsize = (maxx - minx) / resx
  15. ysize = (maxy - miny) / resy
  16.  
  17. start = time.time()
  18. for y in xrange(resy):
  19.     for x in xrange(resx):
  20.         count = 0
  21.         c = (x * xsize + minx) + ((y * ysize + miny) * 1j)
  22.         z = 0 + 0j
  23.         while z.real + z.imag <= 4.0 and count < iterations:
  24.             z = z**2 + c
  25.             count += 1
  26.         if z.real + z.imag <= 4.0:
  27.             sys.stdout.write("#")
  28.             image += "#"
  29.         else:
  30.             sys.stdout.write(" ")
  31.             image += " "
  32. print time.time() - start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement