-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboilerplate.html
57 lines (46 loc) · 1.56 KB
/
boilerplate.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rainbow</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/easings.js" charset="utf-8"></script>
</head>
<body>
<canvas id="canvas" width="300" height="300"></canvas>
<script type="text/javascript">
////////////////////////////////////////////////////////////
// DOC SETUP
////////////////////////////////////////////////////////////
var canvas = document.querySelector('canvas');
var c = canvas.getContext('2d');
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
canvas.width = w;
canvas.height = h;
var mouse = {
x: undefined,
y: undefined
};
////////////////////////////////////////////////////////////
// EVENTS
////////////////////////////////////////////////////////////
window.addEventListener('mousemove', function(event) {
mouse.x = event.x;
mouse.y = event.y;
});
window.addEventListener('mouseout', function(event) {
mouse.x = undefined;
mouse.y = undefined;
console.log("Mouse out of bounds.")
});
window.addEventListener('resize', function(event) {
w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
canvas.width = w;
canvas.height = h;
});
</script>
</body>
</html>