Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const canvas = document.createElement('canvas');
+ document.body.appendChild(canvas);
+ const ctx = canvas.getContext('2d');
+
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+
+ const particles = [];
+ const particleCount = 100;
+
+ class Particle {
+ constructor() {
+ this.x = Math.random() * canvas.width;
+ this.y = Math.random() * canvas.height;
+ this.size = Math.random() * 5 + 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.fillStyle = 'rgba(255, 255, 255, 0.8)';
+ ctx.strokeStyle = 'rgba(255, 255, 255, 0.8)';
+ ctx.lineWidth = 2;
+ ctx.beginPath();
+ ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
+ ctx.closePath();
+ ctx.fill();
+ }
+ }
+
+ function init() {
+ particles.length = 0;
+ for (let i = 0; i < particleCount; i++) {
+ particles.push(new Particle());
+ }
+ }
+
+ function animate() {
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ particles.forEach(particle => {
+ particle.update();
+ particle.draw();
+ });
+ requestAnimationFrame(animate);
+ }
+
+ init();
+ animate();
+
+ window.addEventListener('resize', () => {
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+ init();
+ });
+
+ canvas.addEventListener('mousemove', (e) => {
+ const mouseX = e.clientX;
+ const mouseY = e.clientY;
+
+ particles.forEach(particle => {
+ const dx = mouseX - particle.x;
+ const dy = mouseY - particle.y;
+ const dist = Math.sqrt(dx * dx + dy * dy);
+
+ if (dist < 100) {
+ particle.speedX = dx * 0.05;
+ particle.speedY = dy * 0.05;
+ }
+ });
+ });
+ });