-
Notifications
You must be signed in to change notification settings - Fork 10
/
Wave.pde
56 lines (42 loc) · 941 Bytes
/
Wave.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
class Wave {
private float a;
private float f;
private float r;
private int y;
private boolean t;
private float s;
PGraphics g;
color c;
public Wave() {
init();
g = createGraphics(WIDTH, HEIGHT, P2D);
}
public void init() {
r = random(TWO_PI);
f = PI/32 + random(PI/32);
a = HEIGHT/3 + random(HEIGHT/3);
y = HEIGHT/8 + int(random(HEIGHT - HEIGHT/8));
s = PI/128 + random(PI/64);
if (random(10)<5) {
s = -s;
}
c = color(random(255), random(255), random(255));
}
public void draw() {
float step;
float h;
r = r + s;
if (r > TWO_PI) r = r - TWO_PI;
step = r;
g.beginDraw();
g.background(0);
g.stroke(c);
for (int x=0; x<WIDTH; x++) {
h = sin(step) * a;
step = step + f;
g.line(x, y, x, y+h);
}
g.endDraw();
blend(g, 0, 0, WIDTH, HEIGHT, 0, 0, WIDTH, HEIGHT, SCREEN);
}
}