-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsinewave.js
More file actions
60 lines (60 loc) · 1.03 KB
/
sinewave.js
File metadata and controls
60 lines (60 loc) · 1.03 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
59
60
var fastSin = function(steps) {
var table = [],
ang = 0,
angStep = (Math.PI * 2) / steps;
do {
table.push(Math.sin(ang));
ang += angStep;
} while (ang < Math.PI * 2);
return table;
};
var makedivs=function()
{
divs="";
for(i=0;i<500;i++)
{
divs=divs+"<div style='position:absolute;width:1px;height:40px;top:0px;background-color:red;left:"+i+"px;'></div>";
}
$("#canvas").append(divs);
};
var drawsine=function(height,ang,freq)
{
var sinTable = fastSin(4096);
bars=$("#canvas").children();
for(i=0;i<500;i++)
{
bars[i].style.top=140+height*Math.sin(ang+i*freq);
}
}
$(document).ready(function(){
makedivs();
drawsine(10,30,.2);
});
x=1;
setInterval(function() {
drawsine(10, x,.2);
x++;
}, 50);
//drawsine(x*50,32-Math.sin(x*20)*16,50-Math.sin(x*10)*20);
//html,css code for the sinewave
/*<html>
<head>
<script src="jquery.js"></script>
<script src="sinewave.js"></script>
<style>
body{
margin: 0px;
padding: 0px;
}
#canvas
{
width:500px;
height:300px;
background-color: black;
}
</style>
</head>
<body>
<div id="canvas"></div>
</body>
</html>*/