Created
August 23, 2013 22:38
-
-
Save jhafner/6324676 to your computer and use it in GitHub Desktop.
Canvas (2D) Boilerplate
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
var canvas = document.querySelector('canvas'); | |
var ctx = canvas.getContext('2d'); | |
canvas.width = window.innerWidth; | |
canvas.height = window.innerHeight; | |
function loop() { | |
clear(); | |
update(); | |
draw(); | |
queue(); | |
} | |
function clear() { | |
ctx.clearRect(0, 0, canvas.width, canvas.height); | |
} | |
function update() { | |
// stub | |
} | |
function draw() { | |
// stub | |
} | |
function queue() { | |
window.requestAnimationFrame(loop); | |
} | |
loop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment