-
Notifications
You must be signed in to change notification settings - Fork 1
/
MUSIC-BALLS.html
229 lines (218 loc) · 4.86 KB
/
MUSIC-BALLS.html
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="MUSIC-BALLS.css">
<!-- Load the Paper.js library -->
<script type="text/javascript" src="paper-full.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.9/howler.js"></script>
<link rel="stylesheet" href="rafi.css">
<!-- Define inlined PaperScript associate it with myCanvas -->
<script type="text/paperscript" canvas="myCanvas">
var sound_a = new Howl({
src: ['sounds/a.mp3']
});
var sound_b = new Howl({
src: ['sounds/b.mp3']
});
var sound_c = new Howl({
src: ['sounds/c.mp3']
});
var sound_d = new Howl({
src: ['sounds/d.mp3']
});
var sound_e = new Howl({
src: ['sounds/e.mp3']
});
var sound_f = new Howl({
src: ['sounds/f.mp3']
});
var sound_g = new Howl({
src: ['sounds/g.mp3']
});
var sound_h = new Howl({
src: ['sounds/h.mp3']
});
var sound_i = new Howl({
src: ['sounds/i.mp3']
});
var sound_j = new Howl({
src: ['sounds/j.mp3']
});
var sound_k = new Howl({
src: ['sounds/k.mp3']
});
var sound_l = new Howl({
src: ['sounds/l.mp3']
});
var sound_m = new Howl({
src: ['sounds/m.mp3']
});
var sound_n = new Howl({
src: ['sounds/n.mp3']
});
var sound_o = new Howl({
src: ['sounds/o.mp3']
});
var sound_p = new Howl({
src: ['sounds/p.mp3']
});
var sound_q = new Howl({
src: ['sounds/q.mp3']
});
var sound_r = new Howl({
src: ['sounds/r.mp3']
});
var sound_s = new Howl({
src: ['sounds/s.mp3']
});
var sound_t = new Howl({
src: ['sounds/t.mp3']
});
var sound_u = new Howl({
src: ['sounds/u.mp3']
});
var sound_v = new Howl({
src: ['sounds/v.mp3']
});
var sound_w = new Howl({
src: ['sounds/w.mp3']
});
var sound_x = new Howl({
src: ['sounds/y.mp3']
});
var sound_y = new Howl({
src: ['sounds/x.mp3']
});
var sound_z = new Howl({
src: ['sounds/z.mp3']
});
var circles = [];
function onKeyDown(event) {
var maxpoint = new Point(view.size.width, view.size.height);
var randompoint = Point.random();
var point = maxpoint * randompoint;
var cir = new Path.Circle(point, 600);
// cir.fillColor = "green";
if (event.key === "a") {
sound_a.play();
cir.fillColor = '#1abc9c';
circles.push(cir);
} if (event.key === "b") {
cir.fillColor = '#2ecc71'
sound_b.play();
circles.push(cir);
} if (event.key === "c") {
cir.fillColor = '#3498db'
sound_c.play();
circles.push(cir);
} if (event.key === "d") {
cir.fillColor = '#9b59b6'
sound_d.play();
circles.push(cir);
} if (event.key === "e") {
cir.fillColor = '#34495e'
sound_e.play();
circles.push(cir);
} if (event.key === "f") {
cir.fillColor = '#16a085'
sound_f.play();
circles.push(cir);
} if (event.key === "g") {
cir.fillColor = '#27ae60'
sound_g.play();
circles.push(cir);
} if (event.key === "h") {
cir.fillColor = '#2980b9'
sound_h.play();
circles.push(cir);
} if (event.key === "i") {
cir.fillColor = '#8e44ad'
sound_i.play();
circles.push(cir);
} if (event.key === "j") {
cir.fillColor = '#2c3e50'
sound_j.play();
circles.push(cir);
} if (event.key === "k") {
cir.fillColor = '#f1c40f'
sound_k.play();
circles.push(cir);
}if (event.key === "l") {
cir.fillColor = '#e67e22'
sound_l.play();
circles.push(cir);
}if (event.key === "m") {
cir.fillColor = '#e74c3c'
sound_m.play();
circles.push(cir);
}if (event.key === "n") {
cir.fillColor = '#95a5a6'
sound_n.play();
circles.push(cir);
}if (event.key === "o") {
cir.fillColor = '#f39c12'
sound_o.play();
circles.push(cir);
}if (event.key === "p") {
cir.fillColor = '#d35400'
sound_p.play();
circles.push(cir);
}if (event.key === "q") {
cir.fillColor = '#1abc9c'
sound_q.play();
circles.push(cir);
}if (event.key === "r") {
cir.fillColor = '#2ecc71'
sound_r.play();
circles.push(cir);
}if (event.key === "s") {
cir.fillColor = '#3498db'
sound_s.play();
circles.push(cir);
}if (event.key === "t") {
cir.fillColor = '#9b59b6'
sound_t.play();
circles.push(cir);
}if (event.key === "u") {
cir.fillColor = '#34495e'
sound_u.play();
circles.push(cir);
}if (event.key === "v") {
cir.fillColor = '#16a085'
sound_v.play();
circles.push(cir);
}if (event.key === "w") {
cir.fillColor = '#27ae60'
sound_w.play();
circles.push(cir);
}if (event.key === "x") {
cir.fillColor = '#2980b9'
sound_x.play();
circles.push(cir);
}if (event.key === "y") {
cir.fillColor = '#8e44ad'
sound_y.play();
circles.push(cir);
}if (event.key === "z") {
cir.fillColor = '#2c3e50'
sound_z.play();
circles.push(cir);
}
}
function onFrame(event) {
for(var i = 0; i< circles.length; i++){
circles[i].fillColor.hue += 7;
circles[i].scale(.9);
if(circles[i].area < 1){
circles[i].remove();
circles.splice(i, 1);
console.log(circles);
}
}
}
</script>
</head>
<body>
<canvas id="myCanvas" resize></canvas>
</body>
</html>