Genuary 2022: Sol LeWitt Wall Drawing​
​by Sander Huisman
Each year there are several challenges for generative arts in the month January called “Genuary” ( https://genuary.art/prompts ). This #genuary2022 the challenge is called “Sol LeWitt Wall Drawing”. So I embarked on making an animated version of it:
Animated colorful Sol LeWitt drawing
ClearAll[OffsetLine](*Lineoffsetfunction*)​​OffsetLine[pts_,δ_]:=Module[{normals},​​normals=Map[Normalize/*Cross][Drop[pts,2]-Drop[pts,-2]];​​normals//=Join[{Normalize[pts[[2]]-pts[[1]]]//Cross},#,{Normalize[pts[[-1]]-pts[[-2]]]//Cross}]&;​​pts+δnormals​​]​​SeedRandom[1234];​​colors=ColorData[3]/@Range[10];(*somecolors*)​​cols=RandomChoice[colors,1000]//.{z___,x_,x_,y___}:>{z,x,y};(*getabunchofcolorsbutwithoutadjacentonesbeingthesame*)​​Dynamic[θ]​​imgs=Table[​​cp=ResourceFunction["CurvaturePlot"][(SawtoothWave[t]-1/2)Sin[t](32+4Sin[θ]),{t,0,4}];(*createafunkycurve*)​​pts=FirstCase[cp,Line[x___]:>x,Missing[],∞];​​dist=Accumulate[Prepend[Map[Norm][Differences[pts]],0]];​​ifx=Interpolation[Transpose@{dist,pts[[All,1]]}];(*re-interpolateusingthelengthofthecurve*)​​ify=Interpolation[Transpose@{dist,pts[[All,2]]}];​​pts=Table[{ifx[d],ify[d]},{d,Subdivide[0,Max[dist],2500]}];​​lns=OffsetLine[pts,#]&/@Subdivide[-0.05,0.05,8];(*offsetthepaths*)​​​​ϵ=3×0.014;​​back=Table[Rectangle[{x-0.01ϵ,-2},{x+1.01ϵ,2}],{x,0.5,3,ϵ}];(*Createthebackground*)​​back=Riffle[Take[cols,Length[back]],back];​​g=Graphics[{back,JoinForm["Round"],CapForm["Round"],AbsoluteThickness[10.5],Riffle[Take[colors,Length[lns]],Line/@lns]},AxesFalse,PlotRange{{0.5,1.5},{-0.55,0.2}},ImageSize800];​​Rasterize[g,"Image",RasterSize800,ImageSize800](*rasterizethescenes*)​​,​​{θ,Subdivide[0,2Pi,120]//Most}​​];
Export as a gif:
In[]:=
SetDirectory[NotebookDirectory[]];​​Export["2022_7.gif",imgs,"DisplayDurations"->1/60]
Out[]=
2022_7.gif