Code
void setup(){
size(500,200);
noLoop();
}
void draw(){
background(255);
for (int i=0; i<4; i++){
float pos = 100 + i*100;
house(pos);
}
}
void house(float pos){
fill((random(0,255)), (random(0,255)), (random(0,255)));
triangle(pos-30,150,pos-5,100,pos+20,150);
rect(pos-30,150,50,70);
}
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