-
Notifications
You must be signed in to change notification settings - Fork 0
/
wana.html
69 lines (45 loc) · 1.6 KB
/
wana.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Wanna Wanna Wanna Wanna Wanna Wanna Wanamaker</title>
<style type="text/css">
body {
background-color: #ffffff;
margin: 0px;
cursor: none;
overflow: hidden;
}
</style>
<meta http-equiv="x-dns-prefetch-control" content="off"/></head>
<body>
<!-- Eventually have the head be replaceable? //-->
<script type="text/javascript">
var imageWidthHalf, imageHeightHalf;
var canvas = document.createElement( 'canvas' );
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.style.display = 'block';
document.body.appendChild( canvas );
var context = canvas.getContext( '2d' );
var image = document.createElement( 'img' );
image.addEventListener('load', function() {
imageWidthHalf = Math.floor( this.width / 2 );
imageHeightHalf = Math.floor( this.height / 2 );
document.addEventListener( 'mousemove', onMouseEvent, false );
document.addEventListener( 'touchstart', onTouchEvent, false );
document.addEventListener( 'touchmove', onTouchEvent, false );
}, false );
image.src = "https://dl.dropboxusercontent.com/u/11323116/w.png";
function onMouseEvent( event ) {
context.drawImage( image, event.clientX - imageWidthHalf, event.clientY - imageHeightHalf );
}
function onTouchEvent( event ) {
event.preventDefault();
for ( var i = 0; i < event.touches.length; i++ ) {
context.drawImage( image, event.touches[i].pageX - imageWidthHalf, event.touches[i].pageY - imageHeightHalf );
}
}
</script>
</body>
</html>