Rep-Tile

Author

Eric W. Weisstein
July 16, 2003

This notebook downloaded from http://mathworld.wolfram.com/notebooks/RecreationalMath/Rep-Tile.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Rep-Tile.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<<Graphics`Colors`

rot[a_]:={{Cos[a],-Sin[a]},{Sin[a],Cos[a]}}

TilePath[p0_,s_String,r_:Pi/2,ang0_:0,ds_]:=Module[{p={p0},i,ang=ang0},Do[Switch[StringTake[s,{i}],
"F",AppendTo[p,p[[-1]]+ds rot[ang].{1,0}],
"B",AppendTo[p,p[[-1]]-ds rot[ang].{1,0}],
"+",ang-=r,
"-",ang+=r],{i,StringLength[s]}];
p
]

tilestr="FF+F+F-F+F+FF";

Tile[0]:=Line[TilePath[{0,0},tilestr,Pi/2,Pi/2,1]]

Tile[n_]:=Module[{},
Map[Line,Tile[n-1]/.Line[p_List]:>(
TilePath[#1,tilestr,Pi/2,ArcTan@@(#2-#1),2^(-n)]&@@@{p[[{1,2}]],p[[{3,4}]],p[[{7,8}]],{(p[[1]]+p[[5]])/2,(p[[3]]+p[[4]])/2}}),{n}]
]

NestedTiles[max_]:=Module[{n},
Transpose[Reverse/@{
Take[{Black,Red,Orange,Yellow,Green,Blue,Indigo,Violet},max+1],Table[Tile[n],{n,0,max}]
}
]
]

Figure

Show[Graphics[Tile[0],AspectRatio->Automatic]]

Show[GraphicsArray[Partition[Table[Graphics[NestedTiles[n],AspectRatio->Automatic],{n,0,5}],3]]]//Timing

Show[Graphics[NestedTiles[5],AspectRatio->Automatic]]//Timing

NestedBlackTiles[max_]:=Module[{n},
Transpose[Reverse/@{
Take[{White,Red,Orange,Yellow,Green,Cyan,Blue,Violet},max+1],Table[Tile[n],{n,0,max}]
}
]
]

Show[Graphics[{Thickness[.007],NestedBlackTiles[6]},AspectRatio->Automatic,Background->Black]]//Timing

Show[Graphics[NestedBlackTiles[7],AspectRatio->Automatic,Background->Black]]//Timing