Each year there are several challenges for generative arts in the month January called “Genuary” ( https://genuary.art/prompts ). The genuary 2022 prompt is “Destroy a square” so I thought, let’s exactly do that: make a square, cut it in 4, and iteratively keep cutting the quadrilaterals:
Define a function that take a quadrilateral, find the center, move the center, and define 4 new quadrilaterals:
ClearAll[BreakSquare]BreakSquare[Polygon[ps:{a_,b_,c_,d_}]]:=Module[{ab,bc,cd,da,cntr,t},t=Norm[a-c]0.1;{ab,bc,cd,da}=(ps+RotateLeft[ps])/2;cntr=(a+b+c+d)/4;cntr+=RandomReal[{-t,t},2];{Polygon[{da,a,ab,cntr}],Polygon[{ab,b,bc,cntr}],Polygon[{bc,c,cd,cntr}],Polygon[{cd,d,da,cntr}]}](*Definethestartingsquareanditerativelybreakuparandompolygoninto4pieces:*)SetDirectory[NotebookDirectory[]];sq={Polygon[0.75{{-1,-1},{1,-1},{1,1},{-1,1}}]};Dynamic[i]imgs=Table[g=Graphics[{FaceForm[],EdgeForm[{White,AbsoluteThickness[2],JoinForm["Round"]}],sq},PlotRange1,ImageSize2×600,BackgroundRGBColor[0.,0.21,0.46]];ind=RandomInteger[{1,Length[sq]}];sel=sq[[ind]];sq=Delete[sq,ind];sq=Join[sq,BreakSquare[sel]];Rasterize[g,"Image",RasterSize600,ImageSize600],{i,300}];
Out[]=
i
In[]:=
imgs[[-1]]
Out[]=
Export the images to a gif:
In[]:=
Export["2022_5.gif",imgs,"DisplayDurations"->1/60]
Out[]=
2022_5.gif