// Finish the background draw function ctx.fill(); } function drawRitual() { // Draw each particle with a slight alpha based on time and position fluidParticles.forEach((particle, index) => { const alpha = 0.1 + (index / fluidParticles.length) * 0.3; ctx.globalAlpha = alpha; ctx.beginPath(); ctx.arc(particle.x, particle.y, particle.radius, 0, Math.PI * 2); ctx.fillStyle = particle.color; ctx.fill(); ctx.closePath(); ctx.globalAlpha = 1; // Reset alpha for the next particle }); // Update particles position and apply 'autonomy' fluidParticles.forEach(particle => { const { x, y, speed, angle } = particle; // Autonomous movement - slight random drift + a weighted direction towards center const autonomyWeight = (800 - x) * 0.001 + (600 - y) * 0.001; const autonomousStepX = Math.cos(angle) * speed * autonomyWeight; const autonomousStepY = Math.sin(angle) * speed * autonomyWeight; particle.x += autonomousStepX; particle.y += autonomousStepY; // Simple edge detection - bounce or fade out if (particle.x < 0 || particle.x > canvas.width) { particle.speed *=