Created
August 4, 2016 14:07
-
-
Save federico-pepe/a835bc8e4bdeeb95afe4c47144e40943 to your computer and use it in GitHub Desktop.
Funzioni ricorsive + mousePressed()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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