1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| def mandel2(c):
z=0
for h in range(0,50): #nombre d'iteration
z = z**2 + c
if abs(z) > 2: #abs(z) correspond au module de z
break #arrête l'execution du for si la condition est remplie
if abs(z) >= 2:
return False
else:
return True
root = Tk()
w = Canvas(root, width=600, height=600, background='white' )
w.pack()
for hx in range(0,600,50):
w.create_line(0,hx,600,hx,fill="blue")
for hy in range(0,600,50):
w.create_line(hy,0,hy,600,fill="blue")
print ("Initializing...")
for x in range(0,600):
real = x / 200.0 -2
for y in range(0,600):
img = y / 200.0 -1.5
c = complex(real, img)
if mandel2(c):
w.create_line(x,600-y,x+1,601-y,fill="black")
w.pack()
print ("Complete!")
root.mainloop() |
Partager