var cnv = document.getElementById('canvas');
var ctx = cnv.getContext('2d');
ctx.width = ctx.width; // Clear the context
ctx.lineWidth = 2;
// Drawing a rectangle
ctx.strokeRect(20, 20, 120, 60);
// Filling a rectangle with red
ctx.fillStyle = "#FF0000";
ctx.fillRect(180, 20, 120, 60);
// Filling and outlining a green rectangle
ctx.fillStyle = "#00FF00";
ctx.fillRect(20, 100, 120, 60);
ctx.strokeRect(20, 100, 120, 60);
// A blue rectangle, with the middle cleared out of it
ctx.fillStyle = "#0000FF";
ctx.fillRect(180, 100, 120, 60);
ctx.clearRect(200, 110, 80, 40);