Skip to content

Instantly share code, notes, and snippets.

@nateperry
Created October 30, 2014 22:16
Show Gist options
  • Save nateperry/d96b7280bb2800dee1ac to your computer and use it in GitHub Desktop.
Save nateperry/d96b7280bb2800dee1ac to your computer and use it in GitHub Desktop.
This is a simple starter for working with canvas.
/*
Created by Nate Perry
http://github.com/nateperry
*/
var App;
App = {
canvas: null,
ctx: null,
init : function () {
App.addEventListeners();
App.setupCanvas();
},
addEventListeners : function () {
window.onresize = App.onResize;
},
onResize : function () {
App.resizeCanvas();
},
setupCanvas : function () {
App.canvas = document.getElementById('canvas');
App.ctx = App.canvas.getContext('2d');
App.resizeCanvas();
},
resizeCanvas : function () {
App.canvas.height = window.innerHeight;
App.canvas.width = window.innerWidth;
}
};
window.onload = App.init;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment