(function(b,g,h,c,k,l,m,d,e,f,a){function i(a,b){return parseInt(pec[a]*b+pbc[a]*(1-b));}function j(a,c,d,e){b.fillStyle=a,b.beginPath(),b.arc(c,d,e,0,m*2,!1),b.fill();}function n(){b.fillRect(0,0,g,h),st.forEach(function(a){j(a.color,a.x,a.y,1);}),ps.forEach(function(c){var a=c.d/pmd,b=[i(0,a),i(1,a),i(2,a)];j('rgb('+b[0]+','+b[1]+','+b[2]+')',c.x,c.y,1);}),j('#000',d,e,bhr),ps.forEach(function(a){a.a+=a.d*0.00001,a.x=d+(bhr+a.d)*l(a.a),a.y=e+(bhr+a.d)*k(a.a);});}for(d=g/2,e=h/2,bhr=50,st=[],sc='175,20,0',ps=[],pmd=400,pec=[255,168,0],pbc=[102,0,0],f=0;f<5000;f++)st.push({x:c()*g+1,y:c()*h+1,color:'rgba('+sc+(f%2==0?',1':',0.3')+')'}),a={},a.a=c()*2*m,a.d=c()*pmd+1,a.x=d+(bhr+a.d)*l(a.a),a.y=e+(bhr+a.d)*k(a.a),ps.push(a);setInterval(n,20);}(c,a.width,a.height,Math.random,Math.sin,Math.cos,Math.PI));
(function(c, ww, wh, rnd, sin, cos, pi) {
var bhx = ww / 2,
bhy = wh / 2;
bhr = 50,
st = [],
sc = "175,20,0",
ps = [],
pmd = 400,
pec = [255,168,0],
pbc = [102,0,0];
function grad(part, perc) {
return parseInt(pec[part] * perc + pbc[part] * (1 - perc));
}
function circle(color, x, y, r) {
c.fillStyle = color;
c.beginPath();
c.arc(x, y, r, 0, pi * 2, false);
c.fill();
}
function update() {
c.fillRect(0, 0, ww, wh);
// Render stars.
st.forEach(function(s) {
circle(s.color, s.x, s.y, 1);
});
// Render ring.
ps.forEach(function(p) {
var perc = p.d / pmd,
color = [grad(0, perc), grad(1, perc), grad(2, perc)];
circle("rgb(" + color[0] + "," + color[1] + "," + color[2] + ")", p.x, p.y, 1);
});
// Render event horizon.
circle("#000", bhx, bhy, bhr);
// Rotate.
ps.forEach(function(p) {
p.a += p.d * 0.00001;
p.x = bhx + (bhr + p.d) * cos(p.a);
p.y = bhy + (bhr + p.d) * sin(p.a);
});
}
// Init stars and black hole ring.
for(var i = 0; i < 5000; i++) {
st.push({
x: rnd() * ww + 1,
y: rnd() * wh + 1,
color: "rgba(" + sc + (i % 2 == 0 ? ",1" : ",0.3") + ")"
});
var p = {};
// Random angle.
p.a = rnd() * 2 * pi;
// Random particle distance.
p.d = rnd() * pmd + 1;
// Calculate particle x and y.
p.x = bhx + (bhr + p.d) * cos(p.a);
p.y = bhy + (bhr + p.d) * sin(p.a);
ps.push(p);
}
setInterval(update, 20);
})(c,
a.width,
a.height,
Math.random,
Math.sin,
Math.cos,
Math.PI);