For Loop Pattern

Screen Shot 2017-03-01 at 7.53.24 PM.png

int option = 1;
void setup() {
size(400, 300);
smooth();
noFill();
}

void draw() {
background(300,214,321);

if (option == 1) {
for (int x = 21; x <= width-43; x += 25) {
for (int y = 32; y <= height-52; y+=19) {
line(x-21, y-20, x+19, y+18);
line(x+21, y-20, x-19, y+18);
}
}
}
else if (option == 2) {
for (int x = 45; x <= width-37; x += 17) {
for (int y = 91; y <= height-39; y+=94) {
line(x, y, width/2, height/2);
}
}
}
else if (option == 3) {
for (int x = 90; x <= width-90; x += 32) {
for (int y = 21; y <= height-45; y+=67) {
ellipse(x, y, 90, 30);
}
}
}
else if (option == 4) {
int count = 160;
for (int x = 10; x <= width-10; x += 35) {
for (int y = 67; y <= height-34; y+=10) {
float s = map(count, 120, 0, 0, TWO_PI*2);
arc(x, y, 30, 30, s, s + PI);
count–;
}
}
}
else if (option == 5) {
for (int x = 37; x < width-66; x += 19) {
for (int y = 90; y < height-20; y+=10) {
//rect(x-50, y-30, 40, 40);
for (int i = 0; i < 14; i+=9) {
line(x + i, y, x + i, y + 27);
}
line(x, y, x + 50, y + 30);
}
}
}
}

void mousePressed() {
option++;
if (option > 5) option = 1;
}

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