Skip to content

Instantly share code, notes, and snippets.

@lean8086
Created May 22, 2012 19:27
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 lean8086/2771108 to your computer and use it in GitHub Desktop.
Save lean8086/2771108 to your computer and use it in GitHub Desktop.
Set the 2D context of a canvas
var context = (function () {
"use strict";
// Get the HTML Canvas element
var canvas = document.querySelector("canvas");
// Set canvas size
canvas.width = 200;
canvas.height = 200;
// Return context
return canvas.getContext("2d");
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment