Skip to content

Instantly share code, notes, and snippets.

@gnufied
Created April 29, 2013 09:42
Show Gist options
  • Save gnufied/5480667 to your computer and use it in GitHub Desktop.
Save gnufied/5480667 to your computer and use it in GitHub Desktop.
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var width = canvas.width;
var height = canvas.height;
var i = 0;
// inset box shadow alpha values
var shades = [140, 163, 184, 201, 217, 229, 240, 247, 252];
// draw inset box shadow
for (i = 0; i < shades.length; i++) {
var shade = 1 - (shades[i] / 255);
shade = "rgba(0, 0, 0, " + shade + ")";
ctx.fillStyle = shade;
ctx.fillRect(0, i, width, 1); // top
ctx.fillRect(0, height - i + 1, width, 1); // bottom
ctx.fillRect(i, 0, 1, height) // left
ctx.fillRect(width - i + 1, 0, 1, height) // right
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment