Skip to content

Instantly share code, notes, and snippets.

@arikui
Created August 25, 2009 10:14
Show Gist options
  • Save arikui/174620 to your computer and use it in GitHub Desktop.
Save arikui/174620 to your computer and use it in GitHub Desktop.
(function(lv, ps, init){
ps.each(function(i, v){ return Math.random() > 0.3 ? v.src = lv : v.src; });
var timer = setInterval(function(bs){
ps.map(function(i, img){
var x = i % 6, y = i / 6 << 1 >> 1, n = 0, cs = $.each(
[[x - 1, y - 1], [x, y - 1], [x + 1, y - 1],
[x - 1, y ], [x + 1, y ],
[x - 1, y + 1], [x, y + 1], [x + 1, y + 1]],
function(i, v){
if(v[0] < 0 || v[0] >= 6 || v[1] < 0 || v[1] >= 6) return;
i = v[1] * 6 + v[0];
if(ps[i] && ps[i].src == lv) n++;
}
);
return (img.src == lv) ? (n == 2 || n == 3) : n == 3;
})
.map(function(i, v){ ps[i].src = v ? lv : init[i]; return v; });
}, 1000, []);
})("http://a3.twimg.com/profile_images/256862425/oquno-c_mini.png", $("img.photo"), $("img.photo").map(function(i, v){return v.src;}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment