-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathday_5.pde
59 lines (44 loc) · 1.22 KB
/
day_5.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// (c) 2023 Joseph HENRY
// This code is licensed under MIT license (see LICENSE for details)
boolean displayStack = false;
void displayStackTrace() {
fill(0, 255, 0);
int i = 0;
for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
text(ste.toString(), 10, 20 + i * 15);
i++;
}
displayStack = true;
}
void circleRecursive(float x, float y, float size, int depth, int maxDepth) {
if (depth >= maxDepth) {
if (!displayStack) displayStackTrace();
return;
}
pushMatrix();
translate(x, y);
noFill();
stroke(255);
circle(0, 0, size);
popMatrix();
for (int i = 0; i < 10; i++) {
float rsize = random(size / 12, size /1.5);
float angle = random(TWO_PI);
float radius = random((size - rsize) / 2.0);
float nextX = cos(angle) * radius;
float nextY = sin(angle) * radius;
if (random(1) < 0.5 - depth * 0.05) circleRecursive(x + nextX, y + nextY, rsize, depth + 1, maxDepth);
}
}
float animValue = 0;
void setup() {
size(400, 400);
}
void draw() {
background(0);
float cosValue = (cos(animValue) + 1) / 2.0;
int depth = floor(cosValue * 10);
circleRecursive(width / 2, height / 2, 300, 0, depth);
animValue += 0.1;
displayStack = false;
}