< 454 Home

Read and practice the functions in the handout provided in class, then begin a new sketch that incorporates recursion (functions that call themselves), to create designs of interesting patterns.
Make your sketch at least 3000, 2000 pixels, try doing form in black and white or in color, use lines and shapes.
Also, try a sketch that incorporates interactive recursion (maybe a pattern that changes from mouse movement or sound).

20 points

Here’s a basic recursive program:


void setup() {
size(1000, 600);
smooth();
//this program does no not need continuously redrawn
noLoop();
}

// call the recursive function
void draw() {
myCircle(100, 200, 100, 0);
}

//define the recrusive function
void myCircle (int x, int y, int radius, int num) {
noStroke();
fill(255, 30);
//draw a circle
ellipse(x, y, radius, radius);
//control how many time the circle is drawn, and how it should change each time
if ( num < 50 ) { num = num + 1; myCircle( x + 5, y + 5, radius + 5, num); } }