# Créé le 25/09/2016 en Python 3.2 # 25 septembre 2016 : ensemble de Julia dans une # image PNG en utilisant le module PIL from PIL import Image from math import * x_min=-1.81 x_max=2.13 y_min=-1.36 y_max=1.40 res_x=800 res_y=600 size=(res_x,res_y) im=Image.new('RGB',size) pix=im.load() print('Calcul de l\'ensemble de Julia en cour ...') for py in range(1,res_y+1): for px in range(1,res_x+1): n=0 x=x_min+px*(x_max-x_min)/res_x y=y_max-py*(y_max-y_min)/res_y z=complex(x,y) z2=complex(-0.0986,-0.65186) # Voici 6 autres exemples d'ensembles de Julia : #z2=complex(-0.772691322542185,0.124281466072787) #z2=complex(-0.7927,0.1609) #z2=complex(0.32,0.043) #z2=complex(-1.1380,0.2403) #z2=complex(-0.1225,0.7449) #z2=complex(-0.3380,-0.6230) while(abs(z)<2): z=z*z+z2 n+=1 if n>=255: break pix[px-1,py-1]=256*n nom_fic='julia.png' print('Enregistrement du fichier '+nom_fic+' ...') im.save(nom_fic)