Squares

squares-01.jpg

int brickWidth = 40;
int brickHeight = 40;
int cols = 15;
int rows = 15;
int columnOffset = 60;
int rowOffset = 60;
float rotationIncrement = 0.15;

void setup() {
 size(800, 800);
 
 

background(255);
 smooth();
 fill(1) ;
 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();
 }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s