tiled background w/ canvas
by sporritt
JavaScript
var _tile = function(w, h, dotWidth, dotHeight, target) {
var c = document.createElement("canvas");
c.width = w;
c.height = h;
var ctx = c.getContext("2d");
ctx.fillStyle = "#ecedef";
ctx.fillRect(0,0,w,h);
// paint top left corner
ctx.fillStyle = "#CCC";
ctx.fillRect(0,0,dotWidth,dotHeight);
target.style.backgroundImage = "url(" + c.toDataURL() + ")";
};
_tile(20, 20, 2, 2, document.body);