Motif de Truchet ( Triangles et symétries ) avec PyGGb

Motif de Truchet ( Triangles et symétries ) avec PyGGb #pyggb #geogebra
Motif de Truchet ( Triangles et symétries ) avec PyGGb #pyggb #geogebra
# 21/01/2025 from random import* 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) D = Point(x+1,y,is_visible = False) p = Polygon([A,B,C],color=[0,0,0],opacity=1,line_thickness=0) p2 = Polygon([C,D,A],color=[r,g,b],opacity=1,line_thickness=0) def t2(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([B,C,D],color=[0,0,0],opacity=1,line_thickness=0) p2 = Polygon([D,A,B],color=[r,g,b],opacity=1,line_thickness=0) def t3(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([C,D,A],color=[0,0,0],opacity=1,line_thickness=0) p2 = Polygon([A,B,C],color=[r,g,b],opacity=1,line_thickness=0) def t4(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([D,A,B],color=[0,0,0],opacity=1,line_thickness=0) p2 = Polygon([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,4) r = (x+y)/(2*n+1) g = 0 b = 0.9 if a==1: t1(x,y,r,g,b) t2(-x-1,y,r,g,b) t4(x,-y-1,r,g,b) t3(-x-1,-y-1,r,g,b) if a==2: t2(x,y,r,g,b) t1(-x-1,y,r,g,b) t3(x,-y-1,r,g,b) t4(-x-1,-y-1,r,g,b) if a==3: t3(x,y,r,g,b) t4(-x-1,y,r,g,b) t2(x,-y-1,r,g,b) t1(-x-1,-y-1,r,g,b) if a==4: t4(x,y,r,g,b) t3(-x-1,y,r,g,b) t1(x,-y-1,r,g,b) t2(-x-1,-y-1,r,g,b) ################### Exécution ########################## n = 6 fond = Polygon(Point(-n-1,-n-1,is_visible=False),Point(n+1,-n-1,is_visible=False),4 ,opacity=1,color="white",line_thickness=0) dessin(n)
C'est une variante de l'activité : https://www.geogebra.org/m/sgb5yhz5