tbeseda
1/19/2011 - 12:00 AM

Use js to create a canvas image to create a pinstripe background.

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")+")"});
}