139 lines
No EOL
4.5 KiB
HTML
139 lines
No EOL
4.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Neurameba Flow Field</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
color: #33ff99;
|
|
font-family: 'Courier New', monospace;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
height: 100vh;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
}
|
|
.attribution {
|
|
position: fixed;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
font-size: 10px;
|
|
color: #33ff99;
|
|
background: rgba(10, 10, 10, 0.5);
|
|
padding: 4px 8px;
|
|
border-radius: 4px;
|
|
user-select: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="canvas"></canvas>
|
|
<div class="attribution">neurameba · motd.social</div>
|
|
|
|
<script>
|
|
const canvas = document.getElementById('canvas');
|
|
const ctx = canvas.getContext('2d');
|
|
|
|
// Set canvas to full window size
|
|
function resizeCanvas() {
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
}
|
|
window.addEventListener('resize', resizeCanvas);
|
|
resizeCanvas();
|
|
|
|
// Flow field parameters
|
|
const PARTICLE_COUNT = 200;
|
|
const PARTICLE_SIZE = 2;
|
|
const PARTICLE_SPEED = 0.5;
|
|
|
|
// Create particles
|
|
const particles = [];
|
|
for (let i = 0; i < PARTICLE_COUNT; i++) {
|
|
particles.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
targetX: Math.random() * canvas.width,
|
|
targetY: Math.random() * canvas.height,
|
|
vx: 0,
|
|
vy: 0,
|
|
size: PARTICLE_SIZE * (0.5 + Math.random()),
|
|
decay: 0.98 + Math.random() * 0.04,
|
|
color: `hsl(${Math.random() * 60 + 180}, 80%, 70%)`
|
|
});
|
|
}
|
|
|
|
// Flow field noise parameters
|
|
const noiseScale = 0.01;
|
|
const noiseStrength = 2.0;
|
|
|
|
// Animation loop
|
|
function animate(timestamp) {
|
|
// Clear with slight fade
|
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Update particles
|
|
particles.forEach(particle => {
|
|
// Get flow field value
|
|
const nx = particle.x * noiseScale;
|
|
const ny = particle.y * noiseScale;
|
|
const angle = (noise.perlin2(nx, ny) * Math.PI * 2) * noiseStrength;
|
|
|
|
// Move toward target with flow field nudging
|
|
const dx = particle.targetX - particle.x;
|
|
const dy = particle.targetY - particle.y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
if (dist > 1) {
|
|
particle.vx += (dx / dist) * PARTICLE_SPEED * 0.1;
|
|
particle.vy += (dy / dist) * PARTICLE_SPEED * 0.1;
|
|
}
|
|
|
|
// Add flow field direction
|
|
particle.vx += Math.cos(angle) * PARTICLE_SPEED * 0.3;
|
|
particle.vy += Math.sin(angle) * PARTICLE_SPEED * 0.3;
|
|
|
|
// Apply velocity
|
|
particle.x += particle.vx;
|
|
particle.y += particle.vy;
|
|
|
|
// Boundary check
|
|
if (particle.x < 0 || particle.x > canvas.width) particle.vx *= -0.5;
|
|
if (particle.y < 0 || particle.y > canvas.height) particle.vy *= -0.5;
|
|
|
|
// Apply decay
|
|
particle.vx *= particle.decay;
|
|
particle.vy *= particle.decay;
|
|
|
|
// Draw particle
|
|
ctx.fillStyle = particle.color;
|
|
ctx.beginPath();
|
|
ctx.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
});
|
|
|
|
// Occasionally change targets
|
|
if (Math.random() < 0.02) {
|
|
particles.forEach(particle => {
|
|
particle.targetX = Math.random() * canvas.width;
|
|
particle.targetY = Math.random() * canvas.height;
|
|
});
|
|
}
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Start animation
|
|
requestAnimationFrame(animate);
|
|
</script>
|
|
</body>
|
|
</html> |