-
Notifications
You must be signed in to change notification settings - Fork 0
/
static2.5.html
60 lines (47 loc) · 1.12 KB
/
static2.5.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Attempt 2.5</title>
<style type="text/css">
html, body {
margin: 0px;
background-color: #000000;
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<canvas id='canvas'></canvas>
</body>
<script type="text/javascript">
async function noise() {
// let start = Date.now()
let h = window.innerHeight;
let w = window.innerWidth;
let canvas = document.getElementById('canvas');
canvas.height = h;
canvas.width = w;
let ctx = canvas.getContext('2d');
for (let y=0; y < h; y+=1) {
for (let x=0; x < w; x+=1) {
let color = Math.random().toString(16).slice(-6);
ctx.fillStyle = '#' + color;
ctx.fillRect(x, y, 1, 1);
}
if (y % 10 == 0) {
await drawPixels();
}
}
// console.log(`Done in ${Date.now()-start} ms`);
}
function drawPixels() {
return new Promise(resolve => setTimeout(resolve, 0));
}
window.onload = noise;
window.onclick = noise;
window.ontouchstart = noise;
</script>
</html>