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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| from numpy import *
import pygame
from pygame.locals import *
def pycode(c_1,c_2,c_3):
return c_3+c_2*256+c_1*256**2
couleur=zeros((150))
ri,vi,bi=250,0,0
for i in range(25):
couleur[i]=pycode(ri,vi,bi)
vi+=10
for i in range(25,50):
couleur[i]=pycode(ri,vi,bi)
ri-=10
for i in range(50,75):
couleur[i]=pycode(ri,vi,bi)
bi+=10
for i in range(75,100):
couleur[i]=pycode(ri,vi,bi)
vi-=10
for i in range(100,125):
couleur[i]=pycode(ri,vi,bi)
ri+=10
for i in range(125,150):
couleur[i]=pycode(ri,vi,bi)
bi-=10
iteration_max=input("iteration maxi")
zoom=float(input("zoom"))
point=input("point")
eca=zoom/200
x1 = -1.5
x2 = 1.5
y1 = -1.2
y2 = 1.2
image_x = (x2 - x1) * zoom
image_y = (y2 - y1) * zoom
a=zeros((image_x,image_y),dtype=uint32)
for x in range(0,image_x):
for y in range(0,image_y):
c_r =point[0]
c_i =point[1]
z_r = x / zoom + x1
z_i = y / zoom + y1
i = 0
while z_r*z_r + z_i*z_i <4 and i < iteration_max:
tmp = z_r
z_r = z_r*z_r - z_i*z_i + c_r
z_i = 2*z_i*tmp + c_i
i = i+1
if i < iteration_max:
a[x][y]=couleur[(i*2)%150]
M=a
hM=len(M)
lM=len(M[0])
print hM,lM
pygame.init()
fenetre = pygame.display.set_mode((hM,lM))
pygame.display.set_caption('julias')
pygame.surfarray.blit_array(fenetre,M)
pygame.image.save(fenetre,"Julias000.png")
continuer = True
while continuer:
pygame.time.Clock().tick(1)
pygame.display.flip()
for event in pygame.event.get(): #Attente des événements
if event.type == QUIT:
continuer = False
pygame.quit() |
Partager