Genuary 2022: Abstract vegetation​
​by Sander Huisman
Each year there are several challenges for generative arts in the month January called “Genuary” ( https://genuary.art/prompts ) .This #genuary2022 prompt is “abstract vegetation”, so I decided to make a tree!
From a ‘config’ we create the triangle and then two new stems:
In[]:=
$HistoryLength=1;​​ClearAll[MakeNewConfig]​​MakeNewConfig[n_Integer,δ_:0.5]:=Module[{colors,nc,config,g},​​colors=Blend[{Orange,Yellow,Green},#]&/@Subdivide[n-1];(*colorsbydepth*)​​colors=MapThread[Darker,{colors,Subdivide[0,1/4,Length[colors]-1]}];​​ClearAll[NextConfigs,NewConfig];​​NewConfig[b1_List,b2_List]:=Module[{diff,perp},(*createtriangleandrectangles:*)​​diff=b2-b1;​​perp=Cross[b2-b1];​​<|"quad"->Polygon[{b1,b2,b2+2perp,b1+2perp}],"triang"->Polygon[{b1+(2.4+0.2Cos[2Piδ])perp+(0.5+0.2Sin[2Piδ])diff,b1+2perp,b2+2perp}]|>​​];​​NextConfigs[config_Association]:=Module[{tr},(*producttwoconfigsfroma'config'*)​​tr=config["triangs"][[All,1]];​​tr=Join[NewConfig@@@tr[[All,{2,1}]],NewConfig@@@tr[[All,{1,3}]]];​​<|"quads"->tr[[All,"quad"]],"triangs"->tr[[All,"triang"]]|>​​];​​nc=NewConfig[{-0.5,0},{0.5,0.0}];​​config=<|"quads"->{nc["quad"]},"triangs"->{nc["triang"]}|>;​​config=NestList[NextConfigs,config,n-1];(*iteraten-1timestogetthetree*)​​g=Graphics[MapThread[{EdgeForm[#2],FaceForm[#2],#1["quads"],#1["triangs"]}&,{config,colors}],PlotRange{{-4,4},{-0.25,6}},ImageSize500,PlotRangePadding0,BackgroundRGBColor[0.,0.21,0.46]];​​Rasterize[g,"Image",RasterSize500]​​]
In[]:=
MakeNewConfig[12,0]
Out[]=
imgs=Table[​​MakeNewConfig[12,x]​​,​​{x,Most@Subdivide[60]}(*makeframesfromtimegoingfrom0to1*)​​];
Export the imgs as GIF:
In[]:=
SetDirectory[NotebookDirectory[]];​​Export["2022_17.gif",imgs,"DisplayDurations"->1/30]
Out[]=
2022_17.gif