Truchet Triangles avec PyGgb (simple)

 from random import* import time #dimensions: nl = 8 nc = 8 # background : A = Point(-1,-1,is_visible=False) B = Point(nc,-1,is_visible=False) fond = Polygon(A,B,4) fond.color="white" fond.opacity=1 # cadre : A = Point(-1,-1,is_visible=False) B = Point(nc,-1,is_visible=False) cadre = Polygon(A,B,4) cadre.color="black" cadre.opacity=0 cadre.line_thickness=20 # triangles : for y in range(nl-1): for x in range(nc-1): r = randint(1,4) A = Point(x,y,is_visible=False) B = Point(x+1,y,is_visible=False) C = Point(x+1,y+1,is_visible=False) D = Point(x,y+1,is_visible=False) if r ==1 : P = Polygon([A,B,C]) if r ==2 : P = Polygon([B,C,D]) if r ==3 : P = Polygon([C,D,A]) if r ==4 : P = Polygon([D,A,B]) P.color = "black" P.opacity = 1
Image