Skip to content

Instantly share code, notes, and snippets.

@brettz9
Created March 25, 2011 06:27
Show Gist options
  • Save brettz9/886440 to your computer and use it in GitHub Desktop.
Save brettz9/886440 to your computer and use it in GitHub Desktop.
// Get first canvas tag on page
var ctx = C2D2();
// Wrap a specific canvas DOM element
var ctx = C2D2(myCanvas);
// Use existing canvas tag (by string ID)
var ctx = C2D2('cnv');
// Single argument array; creating a new canvas and context and adding canvas to the body
var ctx = C2D2([1000, 450]);
// Dual argument array and configuration: specifying creation of canvas with other attributes for appending canvas to the body
var ctx = C2D2([1000, 450], {id:'cnv'})
// Single argument object with custom appendTo element as ID string:
var ctx = C2D2({width: 1000, height: 550, id:'cnv', appendTo: 'myId'});
// Single argument object with custom appendTo element as DOM element:
var ctx = C2D2({width: 1000, height: 550, id:'cnv', appendTo: document.body});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment