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?)

4 comments:

  1. Cool post, and a great reminder that sp* packages, functions, and classes can be used for all kind of fun this. Reminds me of some stuff I posted years ago:

    http://casoilresource.lawr.ucdavis.edu/drupal/node/878

    http://casoilresource.lawr.ucdavis.edu/drupal/node/838

    ReplyDelete
  2. You Rtist. Love your post!!!

    ReplyDelete
  3. Very nice. Makes me wonder how mind-bending it would be to do something similar for a self-intersecting closed curve (maybe parameterised as some kind of 2D spline with random knots)

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete