Cafe Wall Illusion

Author

Eric W. Weisstein
April 20, 2002

This notebook downloaded from http://mathworld.wolfram.com/notebooks/RecreationalMath/CafeWallIllusion.nb.

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

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

Initialization

<<Graphics`Colors`

RectangleRow[{x_,y_},r_,n_]:=Module[{i},
Table[Rectangle[{x+i r,y},{x+(i+1)r,y+1}],
{i,1,n,2}
]
]

Options[CafeWall]={
LineColor->GrayLevel[.5]
};

CafeWall[r_,dx_,{n_,k_,p_},opts___]:=Module[{y,off,color},
color=LineColor/.{opts}/.Options[CafeWall];
off=Join[Range[0,p],Range[p-1,1,-1]];
{Table[
RectangleRow[{dx off[[1+Mod[y-1,2p]]],-y},r,n],{y,k}],
{color,
Table[Line[{{r,-y},{(n+1) r+p dx,-y}}],{y,0,k}]
}
}
]

Graphic

Show[GraphicsArray[{Graphics[#,AspectRatio->Automatic]}&/@{
CafeWall[1.7,.4,{9,8,3}],
CafeWall[1.7,.4,{9,8,3},LineColor->Black]
}
]
]