-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
38 lines (36 loc) · 1.52 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Glitch Machine</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="img/favicon.png">
<link rel="stylesheet" type="text/css" href="css/main.css">
<script type="text/javascript" src="js/lib/paper-full.min.js"></script>
<script type="text/javascript" src="js/lib/howler.core.min.js"></script>
<script type="text/paperscript" canvas="myCanvas">
var circles = [];
function onKeyDown(event) {
if(keyData[event.key]){
var maxPoint = new Point(view.size.width, view.size.height);
var randomPoint = Point.random(); //create a random point
var point = maxPoint * randomPoint;
var newCircle = new Path.Circle(point, 500); //create a circle with a random point with a radius 500
newCircle.fillColor = keyData[event.key].color;
keyData[event.key].sound.play();
circles.push(newCircle); //push it into the array "circles"
}
}
function onFrame(event){ //every animation frame
for (var i = 0; i < circles.length; i++) { //loop through the array "circles"
circles[i].fillColor.hue += 1; //for each one add 1 to the hue
circles[i].scale(.9); //scale down by 90% of what it was in a prev frame
}
}
</script>
</head>
<body>
<canvas id="myCanvas" resize></canvas>
<script type="text/javascript" src="js/script.js"></script>
</body>
</html>