FORM+CODE in Design, Art, and Architecture

Parameterize: WAVE

Parameters are powerful tools for controlling a series of objects. The behavior or form of each object can be connected to the value of one or more variables. The designer can think about more than just the individual objects—in this case a rectangle—and instead consider how a population of those objects could combine to create a larger form. Here, the rotation of each rectangle is linked to the rotations of its neighbors. This type of parameterization lends itself to the creation of complex patterns.

The pattern begins with a row of rectangles, each slightly rotated to a random angle. The rotation of each row is determined by the rotation of the rectangle above it. At first, the rotations proceed clockwise, but to prevent overlap, the direction reverses if the new rotation value is too large or small.

/** * Parameterize: Wave * from Form+Code in Design, Art, and Architecture * by Casey Reas, Chandler McWilliams, and LUST * Princeton Architectural Press, 2010 * ISBN 9781568989372 * * This code was written for Processing 1.2+ * Get Processing at */ int brickWidth = 40; int brickHeight = 15; int cols = 20; int rows = 24; int columnOffset = 60; int rowOffset = 30; float rotationIncrement = 0.15; void setup() {   size(1200, 768);      background(255);   smooth();   noFill();   stroke(0);   noLoop(); } void draw() {   translate(30, 30);   for (int i=0; i<cols; i++) {     pushMatrix();     translate(i * columnOffset, 0);     float r = random(-QUARTER_PI, QUARTER_PI);     int dir = 1;     for (int j=0; j<rows; j++) {       pushMatrix();       translate(0, rowOffset * j);       rotate(r);       rect(-brickWidth/2, -brickHeight/2, brickWidth, brickHeight);       popMatrix();       r += dir * rotationIncrement;       if (r > QUARTER_PI || r < -QUARTER_PI) dir *= -1;     }     popMatrix();   } }

Contributed Examples


We are looking for implementations of the code examples in other programming languages to post on the site. If you would like to submit a sample, or if you find a bug, please write to