Skip to content

Instantly share code, notes, and snippets.

@fharper
Created August 26, 2013 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fharper/6341953 to your computer and use it in GitHub Desktop.
Save fharper/6341953 to your computer and use it in GitHub Desktop.
Resize the canvas for different window size
(function() {
"use strict";
function resizeCanvas() {
var canvas = document.querySelector("#canvas");
var context = canvas.getContext("2d");
//Need to set the canvas size here, as it zoom with CSS
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.onload = function() {
resizeCanvas();
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment