Skip to content

Instantly share code, notes, and snippets.

@federico-pepe
Created August 4, 2016 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save federico-pepe/a835bc8e4bdeeb95afe4c47144e40943 to your computer and use it in GitHub Desktop.
Save federico-pepe/a835bc8e4bdeeb95afe4c47144e40943 to your computer and use it in GitHub Desktop.
Funzioni ricorsive + mousePressed()
/*
* Funzioni Ricorsive: drawCircle()
* by Federico Pepe
*
*/
int rec = 1;
void setup() {
size(700, 400);
noFill();
background(255);
}
void draw() {
background(255);
drawCircle(width/2, height/2, width/2, rec);
}
void drawCircle(int x, int y, int radius, int recursion) {
ellipse(x, y, radius, radius);
if (recursion > 1) {
recursion--;
drawCircle(x + radius/2, y, radius/2, recursion);
drawCircle(x - radius/2, y, radius/2, recursion);
}
}
void mousePressed() {
rec++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment