# truchet patchwork 10/08/2023[br]from random import*[br]import time[br][br]# background:[br]A=Point(-100,-100, is_visible=False)[br]B=Point(100,-100, is_visible=False)[br]background=Polygon(A,B,4,opacity=1,color=[1,1,1])[br]#vert rgb(70, 144, 118)[br]#rosef rgb(212, 98, 157)[br]#rosec rgb(237, 160, 203)[br]#bleu rgb(94, 111, 166)[br]#orange rgb(171, 61, 40)[br]#jaune rgb(207, 154, 68)[br]#vert 2 rgb(211, 194, 150)[br][br]lcol=[[70/255, 144/255, 118/255],[212/255, 98/255, 157/255],[237/255, 160/255, 203/255],[94/255, 111/255, 166/255],[171/255, 61/255, 40/255],[207/255, 154/255, 68/255],[211/255, 194/255, 150/255],[0,0,0],[0,0,0]][br][br]def motif(n,m):[br] for i in range(n):[br] for j in range(m):[br] r=random()[br] col=choice(lcol)[br] if r<0.25 :[br] l=[Point(i,j,is_visible=False),Point(i+1,j,is_visible=False),Point(i+1,j+1,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(-i,j,is_visible=False),Point(-(i+1),j,is_visible=False),Point(-(i+1),j+1,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(i,-j,is_visible=False),Point(i+1,-j,is_visible=False),Point(i+1,-(j+1),is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(-i,-j,is_visible=False),Point(-(i+1),-j,is_visible=False),Point(-(i+1),-(j+1),is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] elif r<0.5 :[br] l=[Point(i,j,is_visible=False),Point(i,j+1,is_visible=False),Point(i+1,j,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(-i,j,is_visible=False),Point(-i,j+1,is_visible=False),Point(-(i+1),j,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(i,-j,is_visible=False),Point(i,-(j+1),is_visible=False),Point(i+1,-j,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(-i,-j,is_visible=False),Point(-i,-(j+1),is_visible=False),Point(-(i+1),-j,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] elif r<0.75 :[br] l=[Point(i+1,j,is_visible=False),Point(i+1,j+1,is_visible=False),Point(i,j+1,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(-(i+1),j,is_visible=False),Point(-(i+1),j+1,is_visible=False),Point(-i,j+1,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(i+1,-j,is_visible=False),Point(i+1,-(j+1),is_visible=False),Point(i,-(j+1),is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(-(i+1),-j,is_visible=False),Point(-(i+1),-(j+1),is_visible=False),Point(-i,-(j+1),is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] else:[br] l=[Point(i,j,is_visible=False),Point(i,j+1,is_visible=False),Point(i+1,j+1,is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0) [br] col=choice(lcol)[br] l=[Point(-i,j,is_visible=False),Point(-i,j+1,is_visible=False),Point(-(i+1),(j+1),is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0) [br] col=choice(lcol)[br] l=[Point(i,-j,is_visible=False),Point(i,-(j+1),is_visible=False),Point(i+1,-(j+1),is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0)[br] col=choice(lcol)[br] l=[Point(-i,-j,is_visible=False),Point(-i,-(j+1),is_visible=False),Point(-(i+1),-(j+1),is_visible=False)][br] s=Polygon(l,color=col,opacity=1,line_thickness=0) [br] time.sleep(0.001)[br] [br]motif(10,7)