a=function(){d=document;with(Math){r=random;R=round;f=floor;m=min}var j=function(h){return h.reduce(function(c,e){return c+e},0)/h.length},q=function(h,c,e,g,l,n,o,p){if(e>1){e=f(e/2);g=f(g/2);var i=j([l,n,o,p])+(r()-.5)*(e+g)/128*20;i=i<0?0:i>1?1:i;var s=j([l,n]),t=j([n,o]),u=j([o,p]),v=j([p,l]);q(h,c,e,g,l,s,i,v);q(h+e,c,e,g,s,n,t,i);q(h+e,c+g,e,g,i,t,o,u);q(h,c+g,e,g,v,i,u,p)}else k[c][h]=j([l,n,o,p])},z=function(){for(y=0;y<128;y++)for(x=0;x<128;x++){k[y][x]+=.05;if(k[y][x]>1)k[y][x]=0}w()},
w=function(){for(y=0;y<128;y++)for(x=0;x<128;x++){var h=Y,c;c=k[y][x];var e=c>=.3&&c<.8?(c-.3)*2:c<.3?(.3-c)*2:(1.3-c)*2,g=c>=.5?(c-.5)*2:(.5-c)*2;c="rgb("+R((c<.5?c*2:(1-c)*2)*255)+","+R(e*255)+","+R(g*255)+")";h.fillStyle=c;Y.fillRect(x+x*b,y+y*b,b,b)}setInterval(z,50)};with(d.body.style){backgroundColor="#000";textAlign="center"}Z=d.getElementById("c");Y=Z.getContext("2d");a=m(innerHeight,innerWidth)-20;b=R(a/128);Z.height=Z.width=a;k=[];for(y=0;y<128;y++)k[y]=[];q(0,0,128,128,r(),
r(),r(),r());w()}();
a = function() {
d = document;
with(Math)r=random,R=round,f=floor,m=min;
var compute_color = function(c)
{
var red = (c < .5) ? (c * 2) : ((1 - c) * 2);
var green = (c >= .3 && c < .8) ? ((c - .3) * 2) : (c < .3) ? ((.3 - c) * 2) : (1.3 - c) * 2;
var blue = (c >= .5) ? ((c - .5) * 2) : ((.5 - c) * 2);
return 'rgb(' + R(red * 255) + ',' + R(green * 255) + ',' + R(blue * 255) + ')';
};
var displace = function(num){
return (r() - .5) * (num / 128 * 20);
};
var average_colors = function(array) {
return array.reduce(function(a, b){return a + b;}, 0) / array.length;
};
var iterate = function(x, y, w, h, c1, c2, c3, c4) {
if (w > 1) {
var new_w = f(w / 2);
var new_h = f(h / 2);
var midpoint = average_colors([c1, c2, c3, c4]) + displace(new_w + new_h);
midpoint = midpoint < 0 ? 0 : midpoint > 1 ? 1 : midpoint;
var e1 = average_colors([c1, c2]);
var e2 = average_colors([c2, c3]);
var e3 = average_colors([c3, c4]);
var e4 = average_colors([c4, c1]);
iterate(x, y, new_w, new_h, c1, e1, midpoint, e4);
iterate(x + new_w, y, new_w, new_h, e1, c2, e2, midpoint);
iterate(x + new_w, y + new_h, new_w, new_h, midpoint, e2, c3, e3);
iterate(x, y + new_h, new_w, new_h, e4, midpoint, e3, c4);
} else {
map[y][x] = average_colors([c1, c2, c3, c4]);
}
};
var cycle = function() {
for (y = 0; y < 128; y++)
for (x = 0; x < 128; x++) {
map[y][x] += .05;
if (map[y][x] > 1)
map[y][x] = 0;
}
render();
};
var render = function() {
for (y = 0; y < 128; y++)
for (x = 0; x < 128; x++) {
Y.fillStyle = compute_color(map[y][x]);
Y.fillRect(x + x*b, y + y*b, b, b);
}
setInterval(cycle, 50);
};
with(d.body.style)backgroundColor = '#000',textAlign = 'center';
Z = d.getElementById("c");
Y = Z.getContext("2d");
a = m(innerHeight, innerWidth)-20;
b = R(a / 128)
Z.height = Z.width = a;
var map=[];
for (y = 0; y < 128; y++)map[y]=[];
iterate(0, 0, 128, 128, r(), r(), r(), r());
render();
}();