Flat shadow

by cvalleskey

HTML

<canvas id="can" width="200" height="200"></canvas>

SCSS

canvas {
    border: 2px solid #CCC;
}

JavaScript

$(document).ready(function() {  
    var canvas = document.getElementById("can");
    var ctx = canvas.getContext("2d");
    
    ctx.fillStyle = "rgb(64,64,64)";
    ctx.fillRect (50, 75, 100, 50);
    
    ctx.fillStyle = 'rgba(0,0,0,0.2)';
    ctx.beginPath();
    
    ctx.lineTo(50,75);
    ctx.lineTo(50,125);
    
    ctx.lineTo(150,125);
    ctx.lineTo(50,200);
    
    ctx.lineTo(0,200);
    ctx.lineTo(0,125);
    
    ctx.closePath();
    ctx.fill();
});