-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmusic_landscape.js
More file actions
executable file
·58 lines (49 loc) · 1.55 KB
/
music_landscape.js
File metadata and controls
executable file
·58 lines (49 loc) · 1.55 KB
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
let last_words = "";
let last_words_opacity = 0;
function draw_one_frame(words, vocal, drum, bass, other) {
background(100, 200, 100);
fill(100, 255, 100);
let stripeWidth = map(other, 40, 100, 40, 80, true);
let numStripes = height / stripeWidth;
for(let i=0; i<numStripes; i=i+2) {
let cury = map(i, 0, numStripes-1, 0, height);
rect(0, cury, width, stripeWidth);
}
let triangleHeight = map(bass, 40, 100, 100, 400, true);
fill(100, 100, 255);
for(let i=0; i<3; i++) {
let cur_x = map(i, 0, 4, 0, width);
let next_x = map(i+1, 0, 3, 0, width);
let mid_x = (cur_x + next_x) / 2.0;
let cur_y = 4 * height / 5;
triangle(cur_x, cur_y, mid_x, cur_y - triangleHeight, next_x, cur_y);
}
let drumSize = map(drum, 30, 100, 30, 300, true);
fill(200, 200, 200);
rect(0, 0, drumSize, drumSize);
rect(width, 0, -drumSize, drumSize);
rect(0, height, drumSize, -drumSize);
rect(width, height, -drumSize, -drumSize);
let ovalPlace = map(vocal, 20, 100, height-50, 50, true);
let ovalSize = map(vocal, 20, 100, 60, 150, true);
fill(200, 150, 150);
ellipse(width/2, ovalPlace, ovalSize);
if(words == "") {
last_words_opacity = last_words_opacity * 0.95;
words = last_words;
}
else {
last_words_opacity = (1 + last_words_opacity) * 1.1;
if(last_words_opacity > 255) {
last_words_opacity = 255;
}
}
last_words = words;
textFont('Georgia');
textAlign(CENTER);
textStyle(BOLD);
textSize(80);
noStroke();
fill(0, 0, 0, int(last_words_opacity));
text(words, width/2, height/2);
}