Grille de quadrilatères "aléatoires" #PyGgb (V5)

Grille de quadrilatères "aléatoires" #PyGgb (V5)
Grille de quadrilatères "aléatoires" #PyGgb (V5)
Grille de quadrilatères "aléatoires" #PyGgb (V5)
Grille de quadrilatères "aléatoires" #PyGgb (V5)
#31/01/2024 from random import* import time # point au hasard sur un segment: def pt_hasard(A,B): t = random() C = Point(A.x+t*(B.x-A.x),A.y+t*(B.y-A.y),is_visible=False) return C def motif(n,m): for y in range (0,m): for x in range(0,n): L = [] r=0 A=pt_hasard(Point(x+r,y+r,is_visible=False),Point(x+1-r,y-r,is_visible=False)) B=pt_hasard(Point(x+1+r,y+r,is_visible=False),Point(x+1-r,y+1-r,is_visible=False)) C=pt_hasard(Point(x+1+r,y+1+r,is_visible=False),Point(x-r,y+1-r,is_visible=False)) D=pt_hasard(Point(x-r,y+1-r,is_visible=False),Point(x-r,y-r,is_visible=False)) coul=[[0,0,0],[1,1,1]] L1=[Point(x,y,is_visible=False),A,D] p1=Polygon(L1) p1.opacity=1 p1.color=choice(coul) p1.line_thickness=2 L2=[A,Point(x+1,y,is_visible=False),B] p2=Polygon(L2) p2.opacity=1 p2.color=choice(coul) p2.line_thickness=2 L3=[B,Point(x+1,y+1,is_visible=False),C] p3=Polygon(L3) p3.opacity=1 p3.color=choice(coul) p3.line_thickness=2 L4=[C,Point(x,y+1,is_visible=False),D] p4=Polygon(L4) p4.opacity=1 p4.color=choice(coul) p4.line_thickness=2 L.append(A) L.append(B) L.append(C) L.append(D) p = Polygon(L) p.opacity=1 p.color=[x/n,y/m,1-(x+y)/(m+n)] p.line_thickness=0 time.sleep(0.001) #Exécution: n=10 m=10 # fond / background A = Point(-1,-1,is_visible=False) B = Point(n+1,-1,is_visible=False) b = Polygon(A,B,4) b.color = "black" b.opacity = 1 motif(n,m)