Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
|||
int depth = 5;
|
||||
int interval = 50;
|
||||
|
||||
int currentTime;
|
||||
int lastTime;
|
||||
int progress = 0;
|
||||
int lastProgress = 0;
|
||||
//int finished = int(pow(3,depth));
|
||||
boolean intervalExpired = false;
|
||||
|
||||
void setup() {
|
||||
size(410, 230);
|
||||
background(255);
|
||||
fill(0);
|
||||
lastTime = millis();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
currentTime = millis();
|
||||
triangle (10, 25, 100, depth);
|
||||
}
|
||||
|
||||
void triangle (int x, int y, int l, int n) {
|
||||
if (n == 0) {
|
||||
checkIfIntervalExpired();
|
||||
if (intervalExpired && progress == lastProgress) {
|
||||
text("*", x, y);
|
||||
lastProgress++;
|
||||
intervalExpired = false;
|
||||
}
|
||||
progress++;
|
||||
} else {
|
||||
triangle(x, y+l, l/2, n-1);
|
||||
triangle(x+l, y, l/2, n-1);
|
||||
triangle(x+l*2, y+l, l/2, n-1);
|
||||
}
|
||||
}
|
||||
|
||||
void checkIfIntervalExpired() {
|
||||
if (currentTime-lastTime > interval) {
|
||||
lastTime = currentTime;
|
||||
progress = 0;
|
||||
intervalExpired = true;
|
||||
}
|
||||
}
|
||||
|
||||
void keyReleased() {
|
||||
if (key==' ') { // reset
|
||||
progress = 0;
|
||||
lastProgress = 0;
|
||||
background(255);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue