Cafe Wall Illusion

Every rectangle is the same size. All lines are parallel or perpendicular.

[kml_flashembed publishmethod=”static” fversion=”10.0.0″ movie=”http://www.bit-101.com/blog/wp-content/uploads/2009/09/CafeWallIllusion.swf” width=”600″ height=”800″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

Idea from http://mathworld.wolfram.com/CafeWallIllusion.html

I made it dynamic.

[as3]for(var i:int = 0; i < 20; i++) { var s:Sprite = new Sprite(); s.y = 760 - i * 40; s.filters = [new DropShadowFilter(4, 90, 0, 1, 4, 4, .2)]; s.graphics.lineStyle(0, 0x999999); for(var j:int = 0; j < 800; j += 120) { s.graphics.beginFill(0); s.graphics.drawRect(j, 0, 60, 40); s.graphics.endFill(); s.graphics.beginFill(0xffffff); s.graphics.drawRect(j + 60, 0, 60, 40); s.graphics.endFill(); } addChild(s); } stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove); function onMove(event:Event):void { for(var i:int = 0; i < 20; i++) { var s:Sprite = getChildAt(i) as Sprite; s.x = Math.sin(i * mouseX / 600) * 60 * mouseY / 600; } }[/as3]

This entry was posted in Flash. Bookmark the permalink.

3 Responses to Cafe Wall Illusion

  1. vamapaull says:

    great little piece of code
    very cool effect 😉

Leave a Reply