-
Notifications
You must be signed in to change notification settings - Fork 82
/
equalizer.html
112 lines (80 loc) · 1.86 KB
/
equalizer.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Winamp Equalizer</title>
<style>
canvas{
margin:0px;
padding:0px;
}
body {
background:url(/image/equalizers.png) no-repeat;
padding-left:206px;
padding-top:40px;
}
</style>
<script type="text/javascript">
/**
* @license HTML5 experiment Equalizer
* http://www.xarg.org/project/winamp-equalizer/
*
* Copyright (c) 2011, Robert Eisele ([email protected])
* Dual licensed under the MIT or GPL Version 2 licenses.
**/
var ctx;
var bars = new Array();
var shutdown = false;
function $(id) {
return document.getElementById(id);
}
function Bar(x) {
this.x = x;
this.scale = 0;
this.max = 0;
this.run = function() {
if (this.scale < this.max) {
this.scale+= 1;
} else if (this.scale > this.max) {
this.scale-= 1;
} else if(!shutdown) {
this.max = Math.floor(Math.random() * 29);
}
if (this.scale > 15) {
ctx.fillRect(this.x, 15, 3, 14);
for (var pos = 13, y = 29 - this.scale; pos >= y; pos-= 2) {
ctx.fillRect(this.x, pos, 3, 1);
}
} else {
ctx.fillRect(this.x, 29 - this.scale, 3, 29);
}
}
}
function clock() {
ctx.clearRect(5, 0, 67, 29);
for(var i = 0; i < bars.length; i++) {
bars[i].run();
}
window.setTimeout('clock()', 50);
}
function init() {
ctx = $('canvas').getContext('2d');
ctx.fillStyle = "#fff";
$('canvas').onclick = function() {
if(shutdown =!shutdown) {
for (var i = 0; i < 17; i++) {
bars[i].max = 0;
}
}
}
for (var i = 0; i < 17; i++) {
bars.push(new Bar(5 + (i << 2)));
}
clock();
}
</script>
</head>
<body onload="init()">
<canvas id="canvas" height="29" width="77">how can you use the internet?</canvas>
</body>
</html>