Created
May 29, 2012 21:06
-
-
Save gerred/2830710 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style>body { text-align: center; } canvas { border: 1px solid black; margin: auto;}</style> | |
</head> | |
<body> | |
<canvas id="canvas" width="500" height="500"></canvas> | |
<div> | |
X: | |
<span id="xPos"></span> | |
Y: | |
<span id="yPos"></span> | |
</div> | |
<script type='text/javascript' src='helpers.js'></script> | |
<script> | |
var canvas = document.getElementById("canvas"), | |
context = canvas.getContext('2d'); | |
canvas.addEventListener('mousemove', function(e) { | |
mousePos = helpers.getMouse(e, canvas); | |
document.getElementById("xPos").innerHTML = mousePos.x | |
document.getElementById("yPos").innerHTML = mousePos.y | |
}, true) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment