Below is some sample code for this assignment using the Processing Language:
void setup(){
background(0);
size(800,600);
noFill();
stroke(255);
drawCircle(400,300,200);
}
//top code never changes - drawCircle evolves.
//evolution 1 - basic method that draws a circle
void drawCircle(int x, int y, int sz){
ellipse(x,y,sz,sz);
}
//evolution 2 - 1st recursion - have students draw on paper what they think the code will
//produce
void drawCircle(int x, int y, int sz){
ellipse(x,y,sz,sz);
if(sz > 10)
drawCircle(x,y,sz/2);
}
//evolution 3 - move the circles to the right - have students draw on paper before running code
void drawCircle(int x, int y, int sz){
ellipse(x,y,sz,sz);
if(sz > 10)
drawCircle(x+sz/2,y,sz/2);
}
//evolution 4 - add second recursion - this is where the surprise happens
void drawCircle(int x, int y, int sz){
ellipse(x,y,sz,sz);
if(sz > 10) {
drawCircle(x+sz/2,y,sz/2);
drawCircle(x-sz/2,y,sz/2);
}
}