-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsceneWaveCircles.pde
120 lines (101 loc) · 2.32 KB
/
sceneWaveCircles.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
CircleWaveRound circles[];
class waveCircles extends Scene {
waveCircles(SceneTime[] times) {
super("waveCircles",times);
}
void setup() {
circles = new CircleWaveRound[3];
int size = height/4;
circles[0] = new CircleWaveRound(width/4,height/2,size,-1);
circles[1] = new CircleWaveRound(width/2,height/2,size,0);
circles[2] = new CircleWaveRound(width/4*3,height/2,size,1);
}
void draw() {
if (beat.isKick()) {
circles[0].move();
}
if (beat.isHat()) {
circles[1].move();
}
if (beat.isSnare()) {
circles[2].move();
}
circles[0].draw();
circles[1].draw();
circles[2].draw();
}
}
class CircleWaveRound {
int x, y, size, leftOrRight;
int drawSize;
CircleWaveRound(int x, int y,int size,int leftOrRight) {
this.x = x;
this.y = y;
this.leftOrRight = leftOrRight;
this.size = size;
this.drawSize = size;
}
void move() {
int max = drawSize/4;
int xPlus = int(random(-max,max));
x += xPlus;
while (x>width) {
x -= width;
}
while ( x<0 ) {
x += width;
}
int yPlus = int(random(-max,max));
y += yPlus;
while (y>height) {
y -= height;
}
while ( y<0 ) {
y += height;
}
}
void draw() {
int steps = player.bufferSize() - 1;
float angleStep = 2*PI / steps;
int[] xc = new int[steps];
int[] yc = new int[steps];
drawSize = size;
if (player.position()<15000) {
drawSize = drawSize * player.position() / 15000;
}
for(int i = 0; i < steps; i++)
{
float volume = 0.0;
if (leftOrRight<0) {
volume = player.left.get(i);
}
if (leftOrRight==0) {
volume = player.mix.get(i);
}
if (leftOrRight>0) {
volume = player.right.get(i);
}
float angle = angleStep * i;
float radius = drawSize * (abs(volume)+.5);
xc[i] = int(x + sin(angle) * radius);
yc[i] = int(y + cos(angle) * radius);
}
if (leftOrRight<0) {
stroke(110,55,55,10);
fill(255,0,0,1);
}
if (leftOrRight==0) {
stroke(110,110,55,10);
fill(255,255,0,1);
}
if (leftOrRight>0) {
stroke(55,55,110,10);
fill(0,0,255,1);
}
beginShape();
for(int i = 0; i < steps; i++) {
vertex( xc[i],yc[i] );
}
endShape();
}
}