code:
# 27/11/2024
from random import*
import time
def t1(x,y,r,g,b):
A = Point(x,y,is_visible = False)
B = Point(x,y+1,is_visible = False)
C = Point(x+1,y+1,is_visible = False)
p = Polygon([A,B,C],color=[r,g,b],opacity=1,line_thickness=0)
def t2(x,y,r,g,b):
D = Point(x+1,y,is_visible = False)
B = Point(x,y+1,is_visible = False)
C = Point(x+1,y+1,is_visible = False)
p = Polygon([B,C,D],color=[r,g,b],opacity=1,line_thickness=0)
def t3(x,y,r,g,b):
C = Point(x+1,y+1,is_visible = False)
D = Point(x+1,y,is_visible = False)
A = Point(x,y,is_visible = False)
p = Polygon([C,D,A],color=[r,g,b],opacity=1,line_thickness=0)
def t4(x,y,r,g,b):
D = Point(x+1,y,is_visible = False)
A = Point(x,y,is_visible = False)
B = Point(x,y+1,is_visible = False)
p = Polygon([D,A,B],color=[r,g,b],opacity=1,line_thickness=0)
def cercle(x,y,r,g,b):
centre = Point(x+0.5,y+0.5,is_visible=False)
c = Circle(centre, 0.5, opacity=1,color=[r,g,b],line_thickness=0)
def carre(x,y,r,g,b):
A = Point(x,y,is_visible = False)
B = Point(x,y+1,is_visible = False)
C = Point(x+1,y+1,is_visible = False)
D = Point(x+1,y,is_visible = False)
p = Polygon([A,B,C,D],color=[r,g,b],opacity=1,line_thickness=0)
def dessin(n):
for y in range(n):
for x in range(n):
a = randint(1,6)
if a==1:
t1(x,y,0,0,0)
if a==2:
t2(x,y,0,0,0)
if a==3:
t3(x,y,0,0,0)
if a==4:
t4(x,y,0,0,0)
if a==5:
cercle(x,y,0,x/(n+1),1)
if a==6:
carre(x,y,0,0,0)
time.sleep(0.01)
################### Exécution ##########################
n = 10
fond = Polygon(Point(-1,-1,is_visible=False),Point(n+1,-1,is_visible=False),4
,opacity=1,color="white",line_thickness=0)
dessin(n)