-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch_171103b.pde
71 lines (63 loc) · 1.42 KB
/
sketch_171103b.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
60
61
62
63
64
65
66
67
68
69
70
71
color[] colors = {
color(58, 62, 59),
color(234, 78, 91),
color(247, 240, 220),
color(36, 172, 180),
color(178, 204, 185),
};
color randomColor() {
return colors[(int) random(colors.length)];
}
int numBlocks = 75;
RotatingBlock[] blocks;
void setup() {
size(1000,1000);
nextColors();
color bg = lerpColor(colorFrom, colorTo, colorLerp);
background(bg);
blocks = new RotatingBlock[numBlocks];
for (int i = 0; i < numBlocks; i++) {
blocks[i] = new RotatingBlock();
}
}
float colorLerp = 0;
color colorFrom;
color colorTo;
int colorFromIdx = 0;
int colorToIdx = 1;
int pauseFrames = 60;
void nextColors() {
colorLerp = 0;
pauseFrames = 60;
colorToIdx = (colorToIdx + 1) % colors.length;
colorFromIdx = (colorFromIdx + 1) % colors.length;
colorTo = colors[colorToIdx];
colorFrom = colors[colorFromIdx];
}
void draw() {
if (colorLerp > 1) {
nextColors();
} else {
if (pauseFrames > 0) {
pauseFrames -= 1;
} else {
colorLerp += 0.004;
}
}
color bg = lerpColor(colorFrom, colorTo, colorLerp);
background(bg);
for (int i = 0; i < numBlocks; i++) {
RotatingBlock b = blocks[i];
if (b.isAlive()) {
b.update();
b.display();
} else {
RotatingBlock addedBlock = new RotatingBlock();
addedBlock.display();
blocks[i] = addedBlock;
}
}
if (frameCount < 3700) {
//saveFrame("/Users/travis/Desktop/PFrames/#####.png");
}
}