# TUT­O­R­I­A­L 3: LOOPS

• Show Code
``````/** @peep sketch */

size(200,200);
for (int x=20; x<width; x+=20){
for (int y=x; y<height; y+=20){
rect (x-5,y-5,10,10)
}
}``````
• Show Code
``````/** @peep sketch */

size(200, 200);

for (int x = 20; x < width; x += 20) {
if (x<100){
fill(251,255,201);
rect(x-5, x-5, 10, 10);
}
else{
fill (206,255,201);
rect(x-5,x-5,10,10);
}
}``````
• Show Code
``````/** @peep sketch */

size (200,200);
noFill();
for (int d=10; d<150; d+=7){
ellipse(100,100,d,d);
}``````
• Show Code
``````/** @peep sketch */
size(200,200);
noFill();
for (int x=10; x<width; x+=20){
for (int y=x;y<height;y+=20){
for (int d=1; d<30;d+=5){
ellipse(x,y,d,d)
}
}
}``````
• Show Code
``````/** @peep sketch */

size (200,200);
for (int x=20; x<width;x+=20){
for (int y=20; y<height;y+=20){
rect(x-5,y-5,x/10,y/10)
}
}``````
• Show Code
``````/** @peep sketch */

void setup(){
size(200, 200);
frameRate(1);
}

void draw(){

for (int y = 20; y < height-10; y += 10) {
for (int x = 30; x < width-10; x += 10) {
if ((x % 20) == 0 || (y % 20) == 0) {
stroke(random(255), random(255), random(255));
ellipse(x-5, y+5, 10, 10);
} else {
}
}
}
}``````
• Show Code
``````/** @peep sketch */

size(200, 200);
beginShape();
vertex(20, 20);
for (int y = 20; y <= 180; y += 10) {
if (y % 20 == 0) {
vertex(40, y);
} else {
vertex(80, y);
}
}
vertex(20, 180);
endShape(CLOSE);

beginShape();
vertex(180, 20);
for (int y = 20; y <= 180; y += 10) {
if (y % 20 == 0) {
vertex(160, y);
} else {
vertex(120, y);
}
}
vertex(180, 180);
endShape(CLOSE);``````
• Show Code
``````/** @peep sketch */

void setup(){
size(200,200);
noFill();
frameRate(3);
}

void draw(){
stroke(252,random(180,250) ,100);

beginShape();
background(255);
vertex(10,150);
for(float x=10;x<200;x+=30){
if (x % 2 == 0){
vertex(x,random(10,100));
}
else if (x % 10 == 0){
vertex(x-5,130);
}
}

vertex(190,150);

endShape(CLOSE);
}``````