c’est une fonction qui prend en entrées : c un nombre complexe, N_i le nombre d’itérations,xmin et autres la fenêtre du plan que l’on va afficher. Elle renvoi une version approchée de l’ensemble de julia qui correspond au nombre c entré. Il est obligatoire de rentrer c,N_i,xmin,xmax,ymin et ymax pour se placer dans une partie du plan. Essayez julia(0.3+0.51J,30,-2,2,-2,2)
from kandinsky import* def julia(c,N_i,xmin=-2,xmax=2,ymin=-2,ymax=2): if type(N_i*xmin*xmax*ymin*ymax)==complex or N_i<1 or xmin>=xmax or ymin>=ymax: return "N_i>=1, xmin<xmax, ymin<ymax" for x in range(320): for y in range(222): i=0 z=xmin+(xmax-xmin)*x/320+(ymax-(ymax-ymin)*y/222)*1J while i<N_i and abs(z)<=2: i+=1 z=z*z+c rgb=int(255*i/N_i) col=color(rgb,rgb,rgb) set_pixel(x,y,col)