fromturtleimport*fromkandinskyimportfill_rect,get_pixel,draw_stringfrommathimportcos,sin,exp,pifromtimeimportsleepfromrandomimportrandomspeed(0)hideturtle()# Produit matrice * vecteur
defprod(m,v):r=[]forlinrange(4):s=0forcinrange(4):s+=m[l][c]*v[c]r.append(s)returnrdefaffiche(t,x,y):fori,cinenumerate(t):# vert ou jaune
coul=(0,255,0)ifrandom()<.5else (255,255,0)draw_string(c,x+10*i,y,coul,(0,0,0))# Position de la camera
M=[[1,0,0,0],\
[0,.28,-.96,0],\
[0,.96,.28,0],\
[0,0,0,1]]# ecran noir
fill_rect(0,0,320,222,(0,0,0))forrinrange(42,1,-1):# rayon des cercles
d=4*exp(r/10)*sin(r*3*pi/100)# sapin epais et sol plus fin
pensize(3ifd>0else2)# nb de points par cercle
p=36forkinrange(p):# coordonnees x,y sur le cercle
x,y=d*cos(k*2*pi/p),d*sin(k*2*pi/p)# w sert pour les translations
z,w=-110+5*r,1# coordonnees sur ecran en regardant depuis la camera
[xv,yv,zv,wv]=prod(M,[x,y,z,w])# si point est loin alors plus sombre
c=min(255,220-zv)v=get_pixel(int(xv+160),int(110-yv))[0]# On evite de mettre un point sombre sur un point plus clair
ifv<c:penup()goto(xv,yv)pendown()# sapin si d > 0 sinon sol
ifd>0:pencolor(0,c,0)else:pencolor(c,c,0)goto(xv,yv)whileTrue:affiche("BONNES",40,40)affiche("FETES !",220,100)sleep(.1)
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
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.