Wind Whirls - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Wind Whirls</title> <style> body { margin: 0; padding: 0; overflow: hidden; background: #f0f8ff; } canvas { display: block; } </style> </head> <body> <canvas id="windWhirls"></canvas> <script> const canvas = document.getElementById('windWhirls'); const ctx = canvas.getContext('2d'); canvas.width = window.innerWidth; canvas.height = window.innerHeight; const particles = []; class Particle { constructor(x, y, speedX, speedY, size, color) { this.x = x; this.y = y; this.size = size; this.color = color; this.speedX = speedX; this.speedY = speedY; this.angle = Math.random() * Math.PI * 2; this.spin = Math.random() * 0.05 + 0.01; } update() { this.x += this.speedX; this.y += this.speedY; this.angle += this.spin; if (this.x > canvas.width || this.x < 0 || this.y > canvas.height || this.y < 0) { this.reset(); } } draw() { ctx.save(); ctx.translate(this.x, this.y); ctx.rotate(this.angle); ctx.fillStyle = this.color; ctx.beginPath(); ctx.arc(0, 0, this.size, 0, Math.PI * 2); ctx.fill(); ctx.restore(); } reset() { this.x = Math.random() * canvas.width; this.y = Math.random() * canvas.height; this.speedX = Math.random() * 4 - 2; this.speedY = Math.random() * 4 - 2; } } function createParticles() { for (let i = 0; i < 100; i++) { const x = Math.random() * canvas.width; const y = Math.random() * canvas.height; const speedX = Math.random() * 4 - 2; const speedY = Math.random() * 4 - 2; const size = Math.random() * 5 + 2; const color = 'rgba(173, 216, 230, 0.5)'; const particle = new Particle(x, y, speedX, speedY, size, color); particles.push(particle); } } function animateParticles() { ctx.clearRect(0, 0, canvas.width, canvas.height); for (let i = 0; i < particles.length; i++) { particles[i].update(); particles[i].draw(); } requestAnimationFrame(animateParticles); } window.onload = function() { createParticles(); animateParticles(); }; </script> </body> </html>