forked from disorient/acw
/
ColorDrop.pde
46 lines (35 loc) · 937 Bytes
/
ColorDrop.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
class ColorDrop extends Routine {
void draw() {
background(0);
float frame_mult = 3; // speed adjustment
// lets add some jitter
modeFrameStart = modeFrameStart - min(0,int(random(-5,12)));
long frame = frameCount - modeFrameStart;
for(int row = 0; row < height; row++) {
float phase = sin((float)((row+frame*frame_mult)%height)/height*3.146);
float r = 0;
float g = 0;
float b = 0;
if((row+frame*frame_mult)%(3*height) < height) {
r = 255*phase;
g = 0;
b = 0;
}
else if((row+frame*frame_mult)%(3*height) < height*2) {
r = 0;
g = 255*phase;
b = 0;
}
else {
r = 0;
g = 0;
b = 255*phase;
}
stroke(r,g,b);
line(0, row, width, row);
}
if (frame > FRAMERATE*TYPICAL_MODE_TIME) {
newMode();
}
}
}