-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTMLCanvas.html
60 lines (43 loc) · 897 Bytes
/
HTMLCanvas.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>
<title> Template </title>
<style>
html, body {
margin: 0 !important;
padding: 3 !important;
overflow: hidden;
}
body {
background-color: #000000;
}
#canvas {
position: absolute;
}
</style>
<script>
// JavaScript here
function main() {
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
window.requestAnimationFrame(tick);
function render() {
ctx.fillStyle = "#222222";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
function tick() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
render();
window.requestAnimationFrame(tick);
}
}
document.addEventListener("DOMContentLoaded", main);
</script>
</head>
<body>
<canvas id=canvas> </canvas>
</body>
</html>