Skip to content

Instantly share code, notes, and snippets.

@dexteryy
Created October 15, 2011 12:42
Show Gist options
  • Save dexteryy/1289506 to your computer and use it in GitHub Desktop.
Save dexteryy/1289506 to your computer and use it in GitHub Desktop.
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);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment