"If a million* monkeys^ sit at a million* pixels and randomly change them, they will eventually produce the Mona Lisa."
var z,c=document.getElementById("c"),t=c.getContext("2d"),w=640,h=480,px=w/2,py=h/2,p=t.createImageData?t.createImageData(1,1):{width:1,height:1,data:[]},R=Math.random,F=Math.floor;c.setAttribute("style","border:1em ridge goldenrod");c.setAttribute("width",w);c.setAttribute("height",h);function M(){var a=F(4*R()),b=F(4*R());px=(R()<0.5)?px+a:px-a;py=(R()<0.5)?py+b:py-b;px=(px>=w)?0:(px<0)?px=w-1:px;py=(py>=h)?0:(py<0)?py=h-1:py;p.data[0]=F(256*R());p.data[1]=F(256*R());p.data[2]=F(256*R());p.data[3]=255;t.putImageData(p,px,py)}c.onclick=(function(){z==null?(z=setInterval(M,50),c.title="Click to pause"):(clearInterval(z),z=null,c.title="Click to unpause");return arguments.callee})();
dmFyIHosYz1kb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiYyIpLHQ9Yy5nZXRDb250ZXh0KCIyZCIpLHc9NjQwLGg9NDgwLHB4PXcvMixweT1oLzIscD10LmNyZWF0ZUltYWdlRGF0YT90LmNyZWF0ZUltYWdlRGF0YSgxLDEpOnt3aWR0aDoxLGhlaWdodDoxLGRhdGE6W119LFI9TWF0aC5yYW5kb20sRj1NYXRoLmZsb29yO2Muc2V0QXR0cmlidXRlKCJzdHlsZSIsImJvcmRlcjoxZW0gcmlkZ2UgZ29sZGVucm9kIik7Yy5zZXRBdHRyaWJ1dGUoIndpZHRoIix3KTtjLnNldEF0dHJpYnV0ZSgiaGVpZ2h0IixoKTtmdW5jdGlvbiBNKCl7dmFyIGE9Rig0KlIoKSksYj1GKDQqUigpKTtweD0oUigpPDAuNSk/cHgrYTpweC1hO3B5PShSKCk8MC41KT9weStiOnB5LWI7cHg9KHB4Pj13KT8wOihweDwwKT9weD13LTE6cHg7cHk9KHB5Pj1oKT8wOihweTwwKT9weT1oLTE6cHk7cC5kYXRhWzBdPUYoMjU2KlIoKSk7cC5kYXRhWzFdPUYoMjU2KlIoKSk7cC5kYXRhWzJdPUYoMjU2KlIoKSk7cC5kYXRhWzNdPTI1NTt0LnB1dEltYWdlRGF0YShwLHB4LHB5KX1jLm9uY2xpY2s9KGZ1bmN0aW9uKCl7ej09bnVsbD8oej1zZXRJbnRlcnZhbChNLDUwKSxjLnRpdGxlPSJDbGljayB0byBwYXVzZSIpOihjbGVhckludGVydmFsKHopLHo9bnVsbCxjLnRpdGxlPSJDbGljayB0byB1bnBhdXNlIik7cmV0dXJuIGFyZ3VtZW50cy5jYWxsZWV9KSgpOw==
var
z, c = document.getElementById('c'),
t = c.getContext('2d'),
w = 640, h = 480, // Dimensions
px = w / 2, py = h / 2, // Starting point
p = t.createImageData ? t.createImageData(1, 1) : {width: 1, height: 1, data: []}, // Opera doesn't support createImageData, so we fake it
R = Math.random,
F = Math.floor
;
// Make it purty
c.setAttribute('style', 'border:1em ridge goldenrod');
c.setAttribute('width', w);
c.setAttribute('height', h);
function M(){
// Choose a random pixel within 3px of previous
var x = F(4 * R()), y = F(4 * R());
px = (R() < 0.5) ? px + x : px - x;
py = (R() < 0.5) ? py + y : py - y;
// Warp to other side of canvas
px = (px >= w) ? 0 : (px < 0) ? px = w - 1 : px;
py = (py >= h) ? 0 : (py < 0) ? py = h - 1 : py;
// Set pixel to random R, G & B values
// Need to set each member individually instead of as an array literal for Chrome
p.data[0] = F(256 * R());
p.data[1] = F(256 * R());
p.data[2] = F(256 * R());
p.data[3] = 255;
t.putImageData(p, px, py);
};
// Click to pause/unpause
c.onclick = (function(){
z == null ? (z = setInterval(M, 50),c.title = 'Click to pause') : (clearInterval(z),z = null,c.title = 'Click to unpause');
return arguments.callee;
})();