PyGGB : Truchet & Translations

Image
# truchet triangles frises translation 2 6/08/2023 from random import* import time from math import* # background: A=Point(-1,-1,is_visible=False) B=Point(100,-1,is_visible=False) background=Polygon(A,B,4,opacity=1,color=[1,1,1]) def motif(n,m,t,u): for i in range(n): for j in range(m): r=random() if r<0.25 : for k in range(0,t): for p in range(0,u): col=[(i+j)/(2*n),(i+j)/(2*n)*r,r**2*abs(sin(k+p))] l=[Point(i+k*n,j+p*m,is_visible=False),Point(i+1+k*n,j+p*m,is_visible=False),Point(i+1+k*n,j+1+p*m,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) elif r<0.5 : for k in range(0,t): for p in range(0,u): col=[(i+j)/(2*n),(i+j)/(2*n)*r,r**2*abs(sin(k+p))] l=[Point(i+k*n,j+p*m,is_visible=False),Point(i+k*n,j+1+p*m,is_visible=False),Point(i+1+k*n,j+p*m,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) elif r<0.75 : for k in range(0,t): for p in range(0,u): col=[(i+j)/(2*n),(i+j)/(2*n)*r,r**2*abs(sin(k+p))] l=[Point(i+1+k*n,j+p*m,is_visible=False),Point(i+1+k*n,j+1+p*m,is_visible=False),Point(i+k*n,j+1+p*m,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) else: for k in range(0,t): for p in range(0,u): col=[(i+j)/(2*n),(i+j)/(2*n)*r,r**2*abs(sin(k+p))] l=[Point(i+k*n,j+p*m,is_visible=False),Point(i+k*n,j+1+p*m,is_visible=False),Point(i+1+k*n,j+1+p*m,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) time.sleep(0.001) motif(3,4,5,4)
Image