Changed around line 1
+ class Particle {
+ constructor(x, y) {
+ this.x = x;
+ this.y = y;
+ this.size = Math.random() * 3 + 1;
+ this.speedX = Math.random() * 3 - 1.5;
+ this.speedY = Math.random() * 3 - 1.5;
+ }
+
+ update() {
+ this.x += this.speedX;
+ this.y += this.speedY;
+
+ if (this.size > 0.2) this.size -= 0.1;
+ }
+
+ draw(ctx) {
+ ctx.fillStyle = 'rgba(255,255,255,0.8)';
+ ctx.beginPath();
+ ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
+ ctx.fill();
+ }
+ }
+
+ class ParticleSystem {
+ constructor() {
+ this.canvas = document.getElementById('particleCanvas');
+ this.ctx = this.canvas.getContext('2d');
+ this.particles = [];
+ this.mouse = {
+ x: null,
+ y: null,
+ radius: 150
+ };
+
+ this.init();
+ this.animate();
+ this.setupEventListeners();
+ }
+
+ init() {
+ this.resizeCanvas();
+ window.addEventListener('resize', () => this.resizeCanvas());
+ }
+
+ resizeCanvas() {
+ this.canvas.width = this.canvas.offsetWidth;
+ this.canvas.height = this.canvas.offsetHeight;
+ }
+
+ setupEventListeners() {
+ ['mousemove', 'touchmove'].forEach(eventType => {
+ this.canvas.addEventListener(eventType, (e) => {
+ if (eventType === 'mousemove') {
+ this.mouse.x = e.x;
+ this.mouse.y = e.y;
+ } else {
+ this.mouse.x = e.touches[0].clientX;
+ this.mouse.y = e.touches[0].clientY;
+ }
+
+ for (let i = 0; i < 5; i++) {
+ this.particles.push(new Particle(this.mouse.x, this.mouse.y));
+ }
+ });
+ });
+ }
+
+ animate() {
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
+
+ this.particles.forEach((particle, index) => {
+ particle.update();
+ particle.draw(this.ctx);
+
+ if (particle.size <= 0.2) {
+ this.particles.splice(index, 1);
+ }
+ });
+
+ requestAnimationFrame(() => this.animate());
+ }
+ }
+
+ window.addEventListener('load', () => {
+ new ParticleSystem();
+ });