Code
void setup(){
size(500,200);
noLoop();
}
void draw(){
background(115,167,148);
drawHouse(400, 135);
drawHouse(20, 160);
drawHouse(128, 125);
drawHouse(155, 135);
drawPerson();
drawTree();
}
void drawHouse(int x, int y) {
fill (random(255),random(255),random(255),random(255));
triangle((x+5),(y +20), (x+40),(y + 20), (x+22), (y));
}
void drawPerson() {
fill (117,131,100);
rect (450, 160, 32, 4);
rect (480, 156, 3,8);
ellipse (445, 161, 8,7 );
}
void drawTree() {
fill (51, 80,14) ;
//smooth();
noStroke();
triangle (180,172, 300, 90, 420, 172);
triangle (200,145, 300,70, 400,145);
triangle (220,120, 300,50, 380,120);
triangle (240,90, 300, 35, 360, 90);
triangle (255,70, 300,20, 345,70);
triangle (267,50, 300, 10, 333, 50);
triangle (280, 30, 300, -5, 320, 30);
}
0307 - Functional Abstraction III: Iteration of parameters; random()
Statement:Because we have generalized the drawHouse() function with an argument which governs the house's position, we can use a for{} loop to draw a whole bunch of houses at the same time.
Use the code fragment below in order to render 4 houses across your canvas. This time, however, add some additional code inside the guts of your drawHouse() function, so that each house is drawn with a random fill color. (Note that the noLoop() function keeps the composition from twinkling.) Your results should look something like this:

void setup(){
size(500,200);
noLoop();
}
void draw(){
background(255);
for (int i=0; i<4; i++){
float pos = 100 + i*100;
drawHouse(pos);
}
}
/*
what goes here?
*/
hide statement