Skip to content

Instantly share code, notes, and snippets.

@jaburns
Created August 25, 2015 18:01
Show Gist options
  • Save jaburns/181974192e381b91aff3 to your computer and use it in GitHub Desktop.
Save jaburns/181974192e381b91aff3 to your computer and use it in GitHub Desktop.
Shim for messing around with effects
<!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