Pulsating Flowers - 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>Pulsating Flowers</title> <style> body { margin: 0; padding: 0; overflow: hidden; background: #2e2e2e; } canvas { display: block; } </style> </head> <body> <canvas id="flowerCanvas"></canvas> <script> const canvas = document.getElementById('flowerCanvas'); const ctx = canvas.getContext('2d'); canvas.width = window.innerWidth; canvas.height = window.innerHeight; class Flower { constructor(x, y, size, color) { this.x = x; this.y = y; this.size = size; this.color = color; this.growth = Math.random() * 0.02 + 0.01; this.maxSize = size * 1.5; this.minSize = size * 0.5; } draw() { ctx.save(); ctx.translate(this.x, this.y); ctx.fillStyle = this.color; for (let i = 0; i < 8; i++) { ctx.beginPath(); ctx.arc(this.size, 0, this.size / 2, 0, Math.PI * 2); ctx.fill(); ctx.rotate(Math.PI / 4); } ctx.restore(); } update() { this.size += this.growth; if (this.size > this.maxSize || this.size < this.minSize) { this.growth *= -1; } this.draw(); } } const flowers = []; for (let i = 0; i < 100; i++) { const x = Math.random() * canvas.width; const y = Math.random() * canvas.height; const size = 10 + Math.random() * 20; const color = `hsl(${Math.random() * 360}, 100%, 50%)`; flowers.push(new Flower(x, y, size, color)); } function animate() { ctx.clearRect(0, 0, canvas.width, canvas.height); flowers.forEach(flower => flower.update()); requestAnimationFrame(animate); } animate(); </script> </body> </html>