var b=requestAnimationFrame,d=Math,e='length',f='splice',g=2*d.PI,h,j,k,l,m,n,o=[],p=a.width,q=a.height,r,s,t=(w,z)=>d.random()*(z-w)+w,u=class{constructor(w,{x:z=t(0,p),y:A=q}={},B=t(0,360),C=t(50,60)){for(h=this,j=t(0,g),k=15*d.cos(t(0,g)),h.R=w,h.p={x:z,y:A},h.v={x:w?t(-3,3):d.cos(j)*k,y:w?t(-10,-4):d.sin(j)*k},h.S=w?0.999:t(0,0.05)+0.93,h.g=w?0.01:0.2,h.r=w?1:0.92,h.s=3,h.h=B,h.b=C,h.P=[],m=3;m--;)h.P.push({x:z,y:A})}u(w){if(h=this,n=h.P.pop(),c.beginPath(),c.moveTo(n.x,n.y),c.lineTo(h.p.x,h.p.y),c.lineWidth=h.s,c.strokeStyle=`hsla(${h.h},100%,${h.b}%,1)`,c.stroke(),h.P.unshift({x:h.p.x,y:h.p.y}),h.v.x*=h.r,h.v.y*=h.r,h.v.y+=h.g,h.p.x+=h.v.x,h.p.y+=h.v.y,h.s*=h.S,1>=h.s||h.p.x>p||0>h.p.x||h.p.y>q||0>h.p.y)o[f](w,1);else if(h.R&&h.p.y<=0.5*q&&0.08>=t(0,1)){for(l=t(0,10)+100,s=0;s<l;s+=1)o.push(new u(!1,h.p,h.h,h.b));o[f](w,1)}}},v=()=>{for(c.fillStyle='#000',c.fillRect(0,0,p,q),r=o[e];r--;)o[r].u(r);5>o.filter(w=>w.R)[e]&&o.push(new u(!0)),b(v)};b(v)
var raf = requestAnimationFrame
var Maths = Math
var length = 'length'
var splice = 'splice'
var TAU = Maths.PI * 2;
var that
var angle
var speed
var count
var positionCount
var lastPosition
var elements = [];
var cw = a.width;
var ch = a.height;
var x
var i
var random = (min, max) => Maths.random() * (max - min) + min
// isRocket = R
// position = p
// positions = P
// velocity = v
// size = s
// hue = h
// brightness = b
// shrink = S
// gravity = g
// resistance = r
var Particle = class {
constructor(
isRocket,
{
x = random(0, cw),
y = ch
} = {},
hue = random(0, 360),
brightness = random(50, 60)
) {
that = this
angle = random(0, TAU);
speed = Maths.cos(random(0, TAU)) * 15;
that.R = isRocket
that.p = {x, y};
that.v = {
x: isRocket ? random(-3, 3) : (Maths.cos(angle) * speed),
y: isRocket ? random(-10, -4) : (Maths.sin(angle) * speed)
};
that.S = isRocket ? 0.999 : (random(0, 0.05) + 0.93);
that.g = isRocket ? 0.01 : 0.2;
that.r = isRocket ? 1 : 0.92;
that.s = 3;
that.h = hue
that.b = brightness
that.P = [];
positionCount = 3;
while (positionCount--) {
that.P.push({x, y});
}
}
u (index) {
that = this
lastPosition = that.P.pop()
c.beginPath();
c.moveTo(lastPosition.x, lastPosition.y);
c.lineTo(that.p.x, that.p.y);
c.lineWidth = that.s;
c.strokeStyle = `hsla(${that.h},100%,${that.b}%,1)`;
c.stroke();
that.P.unshift({ x: that.p.x, y: that.p.y });
that.v.x *= that.r;
that.v.y *= that.r;
that.v.y += that.g;
that.p.x += that.v.x;
that.p.y += that.v.y;
that.s *= that.S;
if (
that.s <= 1
|| that.p.x > cw || that.p.x < 0
|| that.p.y > ch || that.p.y < 0
) {
elements[splice](index, 1);
}
else if (that.R) {
if (that.p.y <= ch * 0.5 && random(0, 1) <= 0.08) {
count = random(0, 10) + 100;
for (i = 0; i < count; i += 1) {
elements.push(new Particle(false, that.p, that.h, that.b));
}
elements[splice](index, 1);
}
}
}
}
var update = () => {
c.fillStyle = '#000';
c.fillRect(0, 0, cw, ch);
x = elements[length];
while (x--) {
elements[x].u(x);
}
if (elements.filter(x => x.R)[length] < 5) {
elements.push(new Particle(true));
}
raf(update)
}
raf(update)