What follows is a quick reference of the canvas element’s 2d context drawing methods. For more extensive specifications and discussions of the canvas element visit the WHATWG canvas specifications or the canvas tutorial on Mozilla.org.
To start using the canvas element’s drawing API we first create a reference to a context to draw in inside a DOM-ready listener or window onload event:
var canvas1 = document.getElementById('canvas1');
if (canvas1.getContext){
var cntxt = canvas.getContext('2d');
}else{
//fallback code
}