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]],Graphics[{PointSize[0.02],Red,Point[{0,0}],Point[pos1[ϕin][t]],Point[pos2[ϕin][t]],Point[pos3[ϕin][t]]}],ParametricPlot[pos3[ϕin][τ],{τ,Max[t-0.5,0],t},PlotRange->{{-2.2 l1,2.2 l1},{-2.2 l1,2.2 l1}},ColorFunction->(Opacity[#3,cor]&)],PlotRange->{{-3.2l1,3.2l1},{-3.2l1,3.2l1}},PlotLabel->"t="<>ToString[NumberForm[t,{∞,1}]],ImageSize->250]

frame[1,Hue[0.4]][15]

θinicial=135 ((2π)/360);
fps=10;
tab=Monitor[Table[frame[θinicial,Blue][t],{t,0.0000001,20.0000001,(1/fps)}],t];
ListAnimate[tab,fps,AnimationRepetitions->1]

Export["pendulos0.gif",tab,"DisplayDurations"->(1/fps),ImageSize->300,AnimationRepetitions->∞]

θinicial=135 ((2π)/360);
Δθin=0.001;
num=30;
Clear[framemultiplo]
framemultiplo[t_]:=
Show[
Table[frame[θinicial+n ((Δθin)/num),Hue[(n/num)]][t],{n,0,num-1}]]

fps=10;
tabela=Monitor[Table[framemultiplo[t],{t,0.0000001,20.0000001,(1/fps)}]//Flatten,t];

lista=ListAnimate[tabela,fps,AnimationRepetitions->1]

Export["pendulos_.gif",tabela,"DisplayDurations"->(1/fps),ImageSize->300]