var cnv = document.getElementById('canvas');
var ctx = cnv.getContext('2d');
ctx.width = ctx.width; // Clear the context
// A red rectangle demonstrating shadows.
ctx.save();
ctx.shadowColor = "#222222";
ctx.shadowOffsetX = 20;
ctx.shadowOffsetY = 20;
ctx.shadowBlur = 50;
ctx.fillStyle = "#FF0000";
ctx.fillRect(20, 20, 80, 60);
ctx.restore();
// Transparency can also be used when rendering shadows.
ctx.save();
ctx.shadowColor = "rgba(34, 34, 34, 0.75)";
ctx.shadowOffsetX = 20;
ctx.shadowOffsetY = 20;
ctx.shadowBlur = 50;
ctx.fillStyle = "rgba(255, 0, 0, 0.6)";
ctx.fillRect(180, 20, 80, 60);
ctx.restore();