I love optical illusions (like this and this and these), not just because they're fun, but also because they give us insights into how the brain processes sensory information. Apparently so does Kohske Takahashi, who conducts research on cognitive psychology and cognitive neuroscience at the University of Tokyo's Research Center for Advanced Science and Technology. He's re-created some classic optical illusions using R, as part of an upcoming workshop on illusions. Here are some of his examples:
The horizontal lines in this grid are all parallel (which you can verify by looking at the R code that generated it):
Though the stripes appear offset diaglonally, these symbols are arranged in perfect horizontal/vertical tiles, and appear to move as you scroll the page:
The small squares here are all exactly the same shade of grey:
That last one, by the way, is a variant of my favorite illusion of all time. In the diagram below, the squares labelled A and B are also the exact same shade of grey:
Each of Kohske's illusions requires only a few lines of R code, which goes to show that even simple constructs can play havok with how our brain makes sense of visual signals. You can find the R code for these illusions and more (featuring some very elegant uses of the "grid" graphics package), at the document Kohske Takahashi published to RPubs, linked below.