Last active
December 16, 2015 02:28
-
-
Save foo9/5362367 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
$(function () { | |
var dotSize = 3; | |
var dotColor = "#abc"; | |
var canvas = $("<canvas/>").attr({ | |
width: dotSize * 2, | |
height: dotSize * 2 | |
})[0]; | |
var ctx = canvas.getContext('2d'); | |
ctx.fillStyle = dotColor; | |
ctx.beginPath(); | |
ctx.fillRect(0, 0, dotSize, dotSize); | |
ctx.fillRect(dotSize, dotSize, dotSize, dotSize); | |
$('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