function q(t,o){return Math.floor(Math.random()*t-o)}function t(t){c.strokeStyle=t,c.beginPath()}function i(o,n,r,e){t(e);for(var v=0;4>v;v++)c.moveTo(o,n),c.lineTo(o+q(6,3),n+q(6,3));c.stroke(),c.fillStyle=e,t(),c.arc(o,n,r,0,2*Math.PI,0),c.fill()}function e(t,o,n){v=this,v.x=o,v.y=n,v.h=q(9,4),v.v=q(9,4),v.r=t}function j(o,n,r,e,v,f){t(40>k?o:n),c.moveTo(r,e),c.lineTo(v,f),c.stroke()}function st(){c.clearRect(0,0,w,h),k++;for(var t=0;65>t;t++)n=y[0].x,g=y[0].y,y[t].w(),j(o,z,n,g,y[t].x,y[t].y),y[t].e(),l>m&&(l=0,k=0,p())}function p(){S=q(m,-9),u=q(m,-9),o=s[q(7,0)];for(var t=0;65>t;t++)y[t]=new e(o,9*S,6*u);y[0].h=0,y[0].v=0}function d(){clearInterval(f),f=setInterval(function(){st(),l>m&&d(),l++},30)}b.style.background="#000";var w=a.width,h=a.height,l=0,y=[],k=0,S,f,n,g,o,z="rgba(0,0,0,0)",v,m=75,u,r=1,s=["red","gold","#f0f","lime","aqua","blue","#fff"];e.prototype.w=function(){v=this,l>15&&(r=2),l>25&&(r=4),l>50&&(r=1,v.r=s[1]),i(v.x,v.y,r,v.r)},e.prototype.e=function(){v=this,v.x+=v.h,v.y+=v.v},p(),d();
//Let's go
b.style.background='#000';
var w=a.width,h=a.height,
l=0,y=[],k=0,S,f,n,g,o,
z='rgba(0,0,0,0)',v,m=75,u,r=1,
s=['red','gold','#f0f','lime','aqua','blue','#fff'];
//Generate a random value
function q(a,b){
return Math.floor(Math.random()*a-b);
}
//help to minify code
function t(r){
c.strokeStyle=r;
c.beginPath();
}
//Draw one ball
function i(x,y,u,f){
t(f);
for (var s=0;s<4;s++){
c.moveTo(x,y);
c.lineTo(x+q(6,3),y+q(6,3));
}
c.stroke();
c.fillStyle=f;
t();
c.arc(x,y,u,0,Math.PI*2,0);
c.fill();
}
//Ball constructor
function e(y,g,f){
v=this;
v.x=g;
v.y=f;
v.h=q(9,4);
v.v=q(9,4);
v.r=y;
}
//Ball's draw method
e.prototype.w=function(){
v=this;
//set radius according to value of l
if(l>15){
r=2;
}
if(l>25){
r=4;
}
if(l>50){
r=1;
v.r=s[1];
}
i(v.x,v.y,r,v.r);
};
//Ball's move method
e.prototype.e=function(){
v=this;
v.x+=v.h;
v.y+=v.v;
};
//Draw rays from center to balls
function j(cs,e,X,Y,bX,bY){
if(k<40){
t(cs);
}else{
t(e);
}
c.moveTo(X,Y);
c.lineTo(bX,bY);
c.stroke();
}
//Draw and move balls until condition (l>m) is false. If (l>m) is true objects reset function (ra()) will be called
function st(){
c.clearRect(0,0,w,h);
k++;
for(var i=0;i<65;i++){
n=y[0].x,g=y[0].y;
y[i].w();
j(o,z,n,g,y[i].x,y[i].y);
y[i].e();
if(l>m){
l=0;
k=0;
p()
}
}
}
//Create and then reset objects(balls) and set their properties(coordinates, speed, color)
function p(){
S=q(m,-9);
u=q(m,-9);
o=s[q(7,0)];
for(var i=0;i<65;i++){
y[i]=new e(o,S*9,u*6);
}
y[0].h=0;
y[0].v=0;
}
//salute. Call itself if condition (l>m) is true so the salute will never stop
function d(){
clearInterval(f);
f=setInterval(function(){
st();
if(l>m){
d()
}
l++;
},30);
}
//set objects
p();
//call salute
d();