Created
April 29, 2013 09:42
-
-
Save gnufied/5480667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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