Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- def mandelbrot(cr,ci):
- limit=95
- iterations =0
- c=complex(cr,ci)
- z=0+0j
- while iterations < limit and abs(z) < 10:
- z=z*z+c
- iterations+=1
- return iterations
- def mandelbrot_calc(top_left_r,top_left_i,right_bottom_r,right_bottom_i, res):
- cur_i = top_left_i
- while cur_i > right_bottom_i:
- sys.stdout.write("|")
- cur_r = top_left_r
- while cur_r < right_bottom_r:
- ch = 127 - mandelbrot(cur_r, cur_i)
- sys.stdout.write(chr(ch))
- cur_r += res
- sys.stdout.write("|\n")
- cur_i -= res
- if __name__=="__main__":
- # topleft = (-2,1)
- # bottomright = (1,-1)
- mandelbrot_calc(-2,1, 1, -1, 0.04)
Add Comment
Please, Sign In to add comment