-
-
Save kublaj/8b49d7e6d0e0f5a09c06f9338de18e87 to your computer and use it in GitHub Desktop.
Canvas (2D) Boilerplate
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
| 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