Guest User

Untitled

a guest
Jan 23rd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import sys
  2.  
  3. def mandelbrot(cr,ci):
  4. limit=95
  5. iterations =0
  6. c=complex(cr,ci)
  7. z=0+0j
  8.  
  9. while iterations < limit and abs(z) < 10:
  10. z=z*z+c
  11. iterations+=1
  12.  
  13. return iterations
  14.  
  15. def mandelbrot_calc(top_left_r,top_left_i,right_bottom_r,right_bottom_i, res):
  16. cur_i = top_left_i
  17. while cur_i > right_bottom_i:
  18. sys.stdout.write("|")
  19. cur_r = top_left_r
  20.  
  21. while cur_r < right_bottom_r:
  22. ch = 127 - mandelbrot(cur_r, cur_i)
  23. sys.stdout.write(chr(ch))
  24. cur_r += res
  25. sys.stdout.write("|\n")
  26. cur_i -= res
  27.  
  28. if __name__=="__main__":
  29. # topleft = (-2,1)
  30. # bottomright = (1,-1)
  31. mandelbrot_calc(-2,1, 1, -1, 0.04)
Add Comment
Please, Sign In to add comment