PyGGB (test): Truchet triangles & symétries

Image
# truchet triangles 5/05/2023 from random import* import time # background: A=Point(-100,-100, is_visible=False) B=Point(100,-100, is_visible=False) background=Polygon(A,B,4,opacity=1,color=[1,1,1]) def motif(n,m): for i in range(n): for j in range(m): r=random() col=[(i+j)/(2*n),(i+j)/(2*n)*r,r**2] if r<0.25 : l=[Point(i,j,is_visible=False),Point(i+1,j,is_visible=False),Point(i+1,j+1,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-i,j,is_visible=False),Point(-(i+1),j,is_visible=False),Point(-(i+1),j+1,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(i,-j,is_visible=False),Point(i+1,-j,is_visible=False),Point(i+1,-(j+1),is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-i,-j,is_visible=False),Point(-(i+1),-j,is_visible=False),Point(-(i+1),-(j+1),is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) elif r<0.5 : l=[Point(i,j,is_visible=False),Point(i,j+1,is_visible=False),Point(i+1,j,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-i,j,is_visible=False),Point(-i,j+1,is_visible=False),Point(-(i+1),j,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(i,-j,is_visible=False),Point(i,-(j+1),is_visible=False),Point(i+1,-j,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-i,-j,is_visible=False),Point(-i,-(j+1),is_visible=False),Point(-(i+1),-j,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) elif r<0.75 : l=[Point(i+1,j,is_visible=False),Point(i+1,j+1,is_visible=False),Point(i,j+1,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-(i+1),j,is_visible=False),Point(-(i+1),j+1,is_visible=False),Point(-i,j+1,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(i+1,-j,is_visible=False),Point(i+1,-(j+1),is_visible=False),Point(i,-(j+1),is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-(i+1),-j,is_visible=False),Point(-(i+1),-(j+1),is_visible=False),Point(-i,-(j+1),is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) else: l=[Point(i,j,is_visible=False),Point(i,j+1,is_visible=False),Point(i+1,j+1,is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-i,j,is_visible=False),Point(-i,j+1,is_visible=False),Point(-(i+1),(j+1),is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(i,-j,is_visible=False),Point(i,-(j+1),is_visible=False),Point(i+1,-(j+1),is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) l=[Point(-i,-j,is_visible=False),Point(-i,-(j+1),is_visible=False),Point(-(i+1),-(j+1),is_visible=False)] s=Polygon(l,color=col,opacity=1,line_thickness=0) time.sleep(0.001) motif(10,7)

Variante

col=[(i+j)/(2*n)*r**5,(i+j)/(2*n)*r**5,0.5]
Image
Variante: col=[(i+j)/(2*n)*r**5,(i+j)/(2*n)*r**5,r]
Image