-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
90 lines (86 loc) · 2.59 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
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
<html>
<head>
<title>Wave Plotter</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta name="keywords" content="Achyut,HTML,CSS,wave, wave plotter, github">
<meta name="author" content="Achyut">
<style type="text/css">
@viewport{
zoom : 1.0;
width: extend-to-zoom;
}
@-ms-viewport{
zoom : 1.0;
width: extend-to-zoom;
}
@-webkit-viewport{
zoom : 1.0;
width: extend-to-zoom;
}
*{
margin:0;
padding:0;
}
body{
margin: 0;
padding: 0;
font-size: 1em;
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
canvas{
margin-bottom: 50;
}
input{
font-size: 1em;
margin-bottom: 10;
margin-left: 20;
width: 200;
}
</style>
</head>
<body>
<canvas id = "canvas" width="350" height="350"></canvas><br>
Amplitude: <input type="text" name="" id="input1" placeholder="100"><br>
Wavelength: <input type="text" name="" id="input2" placeholder="200"><br>
Time Period: <input type="text" name="" id="input3" placeholder="300"><br>
Copyright 2019© Achyut Raj😂😂
<script type="text/javascript">
var frameRate = 1, margin = 15,thickness = 3,
x, t=0,T = 300,L = 2*100,a = 100;
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
window.onload = function(){
document.getElementById("input1").onchange = function(){
a = document.getElementById("input1").value;
document.getElementById("input1").placeholder = a;
}
document.getElementById("input2").onchange = function(){
L = document.getElementById("input2").value;
document.getElementById("input2").placeholder = L;
}
document.getElementById("input3").onchange = function(){
T = document.getElementById("input3").value;
document.getElementById("input3").placeholder = T;
}
setInterval(update, 1);
}
update = function(){
if(t%frameRate==0){
context.fillStyle = "black";
context.fillRect(0,0, canvas.width, canvas.height);
context.fillStyle = "red";
context.fillRect(margin, 2*margin, 1, canvas.height-4*margin);
context.fillRect(margin, canvas.height/2, canvas.width-2*margin, 1);
for(x=1; x<canvas.width-2*margin; x++){
y = a*Math.sin(2*Math.PI*((t/T)-(x/L)));
context.fillStyle = "green";
context.fillRect(margin+x, (canvas.height/2)-y, thickness,thickness);
}
}
t++;
}
</script>
</body>
</html>