Skip to content

Instantly share code, notes, and snippets.

@foo9
Last active December 16, 2015 02:28
Show Gist options
  • Save foo9/5362367 to your computer and use it in GitHub Desktop.
Save foo9/5362367 to your computer and use it in GitHub Desktop.
背景いっぱいにドット
$(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