Monday, July 16, 2012

Optical Art with R

Last week, in a post entitled Bridget Riley exhibition in London, the author Markus Gesmann wrote an R script reproducing one of Riley's famous art pieces: Movement in Squares.

This reminded me of my own first "brush" with Op art. It was in art class years ago, our professor (Madame VitrĂ©) had asked that we recreate an interesting piece. The concept in itself was easy: pick two points and draw a number of lines through each of them. Where they intersect, the two sets of lines create a multitude of polygons that can be filled in black or white alternatively, for quite a dramatic result.

As you can imagine, it was tedious work on paper. Years later, I'd get a thrill at doing it in just a couple minutes using Paint on Windows. Well, here I am again in 2012, now a grown-up programmer:

The example above was run using P = 2, N = 30, and colors = c("black", "white"). And here is a nice series using three points and colors from the brewer palette:
P = 3, N = 12,
colors = brewer.pal(3, "Reds")
P = 3, N = 15,
colors = brewer.pal(3, "Purples")
P = 3, N = 15,
colors = brewer.pal(3, "Blues")
P = 3, N = 9,
colors = brewer.pal(3, "Greens")

Madame VitrĂ© would be proud. (or horrified?)