Created
August 25, 2015 18:01
-
-
Save jaburns/181974192e381b91aff3 to your computer and use it in GitHub Desktop.
Shim for messing around with effects
This file contains 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
<!DOCTYPE html> | |
<html> | |
<body> | |
<canvas id="paper" width="1024" height="768"></canvas> | |
<script> | |
// --------------------------------------------------------------------------- | |
var canvas = document.getElementById("paper"); | |
var ctx = canvas.getContext("2d"); | |
var mouse = {}, keys = {}; | |
canvas.addEventListener('mousemove', function(e) { | |
var rect = canvas.getBoundingClientRect(); | |
mouse.x = e.clientX - rect.left; | |
mouse.y = e.clientY - rect.top; | |
}); | |
document.addEventListener("keydown", function(e) { keys[e.keyCode] = true; }); | |
document.addEventListener("keyup", function(e) { delete keys[e.keyCode]; }); | |
start(); | |
requestAnimationFrame(function animFrame() { | |
update(); | |
requestAnimationFrame(animFrame); | |
}); | |
// --------------------------------------------------------------------------- | |
function start() | |
{ | |
} | |
function update() | |
{ | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment