Skip to content

Instantly share code, notes, and snippets.

@tbeseda
Created January 19, 2011 00:00
Show Gist options
  • Select an option

  • Save tbeseda/785418 to your computer and use it in GitHub Desktop.

Select an option

Save tbeseda/785418 to your computer and use it in GitHub Desktop.
Use js to create a canvas image to create a pinstripe background.
function bgStripe() {
if (!!!document.createElement('canvas').getContext)
return;
var canvas = document.createElement("canvas");
canvas.width = 6;
canvas.height = 1;
var ctx = canvas.getContext("2d");
ctx.fillStyle = 'black';
ctx.fillRect(0,0,2,1);
ctx.fillStyle = 'rgba(30,30,30,1)';
ctx.fillRect(2,0,4,1);
$('body').css({'background-image': "url("+canvas.toDataURL("image/png")+")"});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment