(* SIERPINSKI GASKET *)

II={{0,0},{1/4,1},{1,1/3}};
FF[jj_,xx_]:=(1/2)*(xx+II[[jj]]);
PP[jj_,ww_]:=Table[(1/2)*(ww[[kk]]+II[[jj]]),{kk,3}]; tb=Graphics[{RGBColor[0,0,1],Polygon[II]}];
a0={tb};
JJ={(1/2)*(II[[1]]+II[[2]]),(1/2)*(II[[2]]+II[[3]]),(1/2)*(II[[3]]+II[[1]])};
a1={Graphics[{RGBColor[1,1,1],Polygon[JJ]}]};
ba={};
Do[qq=PP[kk,JJ];ba=Append[ba,qq];ba,{kk,3}];
a2=Table[Graphics[{RGBColor[1,1,1],Polygon[ba[[tt]]]}],{tt,Length[ba]}];
ab=ba;
ba={};
Do[Do[qq=PP[kk,ab[[jj]]];ba=Append[ba,qq];ba,{kk,3}],{jj,Length[ab]}];
a3=Table[Graphics[{RGBColor[1,1,1],Polygon[ba[[tt]]]}],{tt,Length[ba]}];
ab=ba;
ba={};
Do[Do[qq=PP[kk,ab[[jj]]];ba=Append[ba,qq];ba,{kk,3}],{jj,Length[ab]}];
a4=Table[Graphics[{RGBColor[1,1,1],Polygon[ba[[tt]]]}],{tt,Length[ba]}];
ab=ba;
ba={};
Do[Do[qq=PP[kk,ab[[jj]]];ba=Append[ba,qq];ba,{kk,3}],{jj,Length[ab]}];
a5=Table[Graphics[{RGBColor[1,1,1],Polygon[ba[[tt]]]}],{tt,Length[ba]}];
ab=ba;
ba={};
Do[Do[qq=PP[kk,ab[[jj]]];ba=Append[ba,qq];ba,{kk,3}],{jj,Length[ab]}];
a6=Table[Graphics[{RGBColor[1,1,1],Polygon[ba[[tt]]]}],{tt,Length[ba]}];

z0=Show[a0,AspectRatio->Automatic];
z1=Show[a0,a1,AspectRatio->Automatic];
z2=Show[a0,a1,a2,AspectRatio->Automatic];
z3=Show[a0,a1,a2,a3,AspectRatio->Automatic];
z4=Show[a0,a1,a2,a3,a4,AspectRatio->Automatic];
z5=Show[a0,a1,a2,a3,a4,a5,AspectRatio->Automatic];
z6=Show[a0,a1,a2,a3,a4,a5,a6,AspectRatio->Automatic];
zz={z0,z1,z2,z3,z4,z5,z6};

ListAnimate[zz,1,AnimationRepetitions->3]

DD[uu_]:=Which[uu<1/3,1,uu<2/3,2,uu<1,3];
n1=100; n2=100;nn=n1*n2;
ss={1/2,1/2};
orbit={ss};
Do[tt=orbit[[Length[orbit]]];jj=DD[Random[]];uu=FF[jj,tt];orbit=Append[orbit,uu],{mm,nn}];
orbim=Table[Show[ListPlot[Take[orbit,{1,jj*n2}]],Axes->False,AspectRatio->Automatic, DefaultColor->RGBColor[1,0,0]],{jj,1,n1}];

ListAnimate[orbim,AnimationRepetitions->3]