julia.py

Created by loupiot

Created on June 14, 2018

470 Bytes

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)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.