dexteryy
10/15/2011 - 12:42 PM

random bitmap

random bitmap

var tmp = document.createElement('DIV');
tmp.innerHTML = '<canvas width="512" height="512" style="position:fixed;top:10px;right:10px;z-index:99999;"></canvas>';
var e = tmp.firstChild;
document.body.appendChild(e);
var ctx = e.getContext('2d');
ctx.fillStyle = "#000";
ctx.fillRect(0, 0, 512, 512);
ctx.fillStyle = "#fff";
for (var y = 0, x; y < 512; y++) {
    for (x = 0; x < 512; x++) {
        if (Math.random() > 0.5) {
            ctx.fillRect(x, y, 1, 1);
        }
    }
}