-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
173 lines (165 loc) · 5.47 KB
/
Copy pathindex.html
File metadata and controls
173 lines (165 loc) · 5.47 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
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
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<title>HTML5 Canvas - Sine wave</title>
<style>
body{
background:#151515;
}
div{
z-index:2;
position:absolute;
}
input[type=range]{
width:200px;
height:15px;
-webkit-appearance:none;
background:#111;
outline:none;
margin:5px;
position: relative;
border-radius:15px;
overflow:hidden;
box-shadow:inset 0 0 5px rgba(0,0,0,1);
}
input[type=range]::-moz-range-thumb,input[type=range]::-webkit-slider-thumb{
-webkit-appearance:none;
width:15px;
height:15px;
border-radius:50%;
background:#00fd0a;
cursor:pointer;
border:4px solid #333;
box-shadow:-407px 0 0 400px #00fd0a;
}
ul {
background: #ff9999;
padding: 20px;
}
ul li {
background: #ffe5e5;
padding: 5px;
margin-left: 35px;
overflow-x:hidden;
}
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
width:100%;
text-align:left;
}
a:hover, a:active {
background-color: red;
}
</style>
</head>
<body>
<div>
<input title="height" type="range" id="height" oninput="ranges()" onchange="ranges()">
<input title="wavelength" type="range" id="wavelength" oninput="ranges()" onchange="ranges()">
<input title="amplitude" type="range" id="amplitude" oninput="ranges()" onchange="ranges()">
<input title="frequency" type="range" id="freq" oninput="ranges()" onchange="ranges()"></br>
<input title="H" type="range" id="h" oninput="color()" onchange="color()">
<input title="S" type="range" id="s" oninput="color()" onchange="color()">
<input title="L" type="range" id="l" oninput="color()" onchange="color()">
</div>
<canvas style="background-color:white"></canvas>
<ul>
<li><a href="Data visulization JavaScript/index.html" target="_self">Data Visualization with javascript</a></li>
</ul>
</body>
<script>
var inheight = document.getElementById('height');
var inwavelen = document.getElementById('wavelength');
var inamplitude = document.getElementById('amplitude');
var infreq = document.getElementById('freq');
var inh = document.getElementById('h');
var ins = document.getElementById('s');
var inl = document.getElementById('l');
var canvas = document.querySelector('canvas');
var c = canvas.getContext("2d");
var y,wavelength,ampliude,freq;
var inc=0.01;//change to 0.01 to make //animation
var H,W,h,s,l;
// inc=parseFloat(freq);
function animate(){
requestAnimationFrame(animate);
c.fillStyle="rgba(0,0,0,0.01)";
c.fillRect(0,0,W,H); //animation
c.beginPath();
c.moveTo(0,y);
for(let i=0;i<canvas.width;++i){
c.lineTo(i,y + Math.sin(i*wavelength+inc)*ampliude);
}
c.stroke();
c.strokeStyle = `hsl(${h},${s}%,${l}%)`;
inc+= parseFloat(freq); //animation
}
animate();
function ranges(){
y=inheight.value/2;
wavelength=inwavelen.value;
ampliude=inamplitude.value;
freq=infreq.value;
}
function color(){
h = inh.value;
s = ins.value;
l = inl.value;
c.strokeStyle = `hsl(${r},${g}%,${b}%)`;
}
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
H = canvas.height;
W = canvas.width;
//set min/max height of wave
inheight.min = 0;
inheight.max = H;
inheight.value=H;
//set min/max/step wavelength of wave
inwavelen.step=0.001;
inwavelen.min = -0.01;
inwavelen.max = 0.01;
inwavelen.value=0.01;
//set amplitude of wave
inamplitude.min=-300;
inamplitude.max=300;
inamplitude.value = 100;
//set frequency
infreq.step=0.01;
infreq.min=-0.1;
infreq.max=0.1;
infreq.value=0.01;
//set color values
inh.max=255;
inh.min=0;
inh.value=0;
ins.max=100;
ins.min=0;
ins.value=50;
inl.max=100;
inl.min=0;
inl.value=50;
y=inheight.value/2;
wavelength=inwavelen.value;
ampliude=inamplitude.value;
freq = infreq.value;
inc = parseFloat(freq);
h = inh.value;
s = ins.value;
l = inl.value;
c.strokeStyle = `hsl(${s},${s}%,${l}%)`;
window.onresize = () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
H = canvas.height;
W = canvas.width;
}
</script>
</html>