Grille de quadrilatères "aléatoires" #PyGgb
LIEN / LINK/ ENLACE
Pour n=20 et m=20
# grille de quadrilatères (17/10//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 = []
L.append(pt_hasard(Point(x,y,is_visible=False),Point(x+1,y,is_visible=False)))
L.append(pt_hasard(Point(x+1,y,is_visible=False),Point(x+1,y+1,is_visible=False)))
L.append(pt_hasard(Point(x+1,y+1,is_visible=False),Point(x,y+1,is_visible=False)))
L.append(pt_hasard(Point(x,y+1,is_visible=False),Point(x,y,is_visible=False)))
p = Polygon(L)
p.opacity=1
p.color=[x/n,y/m,1]
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)