refactor: separate js code

This commit is contained in:
2026-06-25 05:58:51 +05:00
parent ddc8b93804
commit b3b0c645e9
13 changed files with 1182 additions and 1444 deletions
+28
View File
@@ -0,0 +1,28 @@
class Particle {
constructor(x, y, color) {
this.x = x;
this.y = y;
this.vx = (Math.random() - 0.5) * S.particleVel;
this.vy = (Math.random() - 0.5) * S.particleVel;
this.life = 1;
this.decay = S.particleDecayBase + Math.random() * S.particleDecayRange;
this.color = color;
this.size = S.particleSizeMin + Math.random() * (S.particleSizeMax - S.particleSizeMin);
}
update() {
this.x += this.vx;
this.y += this.vy;
this.life -= this.decay;
this.vx *= S.particleDamping;
this.vy *= S.particleDamping;
}
draw() {
ctx.save();
ctx.globalAlpha = this.life;
ctx.fillStyle = this.color;
ctx.shadowColor = this.color;
ctx.shadowBlur = S.particleGlow;
ctx.fillRect(this.x - this.size / 2, this.y - this.size / 2, this.size, this.size);
ctx.restore();
}
}