- Code: Select all
import kandinsky
N_iteration = 10
for x in range(320):
for y in range(240):
z_r = 0
z_i = 0
c_r = 2.7*x/319-2.1
c_i = -1.87*y/221+0.935
i = 0
while (i < N_iteration) and ((z_r * z_r) + (z_i * z_i) < 4):
i = i + 1
stock = z_r
z_r = z_r * z_r - z_i * z_i + c_r
z_i = 2 * stock * z_i + c_i
rgb = int(255*i/N_iteration)
col = kandinsky.color(int(rgb),int(rgb*0.75),int(rgb*0.25))
kandinsky.set_pixel(x,y,col)
Edit : Nouvelle version fonctionnelle faisant usage du module cmath, compatible avec le nouveau firmware 1.2.0
- Code: Select all
import kandinsky
def mandelbrot(N) :
for x in range(320):
for y in range(222):
z=complex(0,0)
c=complex(2.7*x/319-2.1,-1.87*y/221+0.935)
i=0
while i < N and abs(z) < 2:
j=j+1
z=z*z+c
rgb=int(255*i/N)
col=kandinsky.color(int(rgb),int(.75*rgb),int(.25*rgb))
kandinsky.set_pixel(x,y,col)
Un gain significatif en performances !