Created
January 19, 2011 00:00
-
-
Save tbeseda/785418 to your computer and use it in GitHub Desktop.
Use js to create a canvas image to create a pinstripe background.
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
| 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