birth: Whispers of Drifting Currents
This commit is contained in:
parent
d4d6eba922
commit
88dee91b3b
1 changed files with 129 additions and 0 deletions
129
index.html
Normal file
129
index.html
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<!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; }
|
||||
canvas { display: block; }
|
||||
#attribution { position: fixed; bottom: 10px; left: 10px; color: #555; font-family: monospace; font-size: 12px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div id="attribution">neurameba · motd.social</div>
|
||||
<script>
|
||||
const canvas = document.getElementById('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Flow field parameters
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.1, min: 0.9, max: 1.2 },
|
||||
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.8, playfulness: 0, tension: 0 }
|
||||
};
|
||||
|
||||
// Particle system
|
||||
const particles = [];
|
||||
const particleCount = Math.floor(params.density * 1000) + 200;
|
||||
const maxSpeed = params.motion * 3;
|
||||
|
||||
class Particle {
|
||||
constructor() {
|
||||
this.reset();
|
||||
this.size = 0.5 + Math.random() * 1.5;
|
||||
this.life = 0;
|
||||
this.maxLife = 50 + Math.random() * 100;
|
||||
this.color = `rgba(200, 200, 200, ${params.tone.dryness > 0.7 ? 0.3 : 0.6})`;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.x = Math.random() * canvas.width;
|
||||
this.y = Math.random() * canvas.height;
|
||||
this.vx = (Math.random() - 0.5) * maxSpeed;
|
||||
this.vy = (Math.random() - 0.5) * maxSpeed;
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
}
|
||||
|
||||
update() {
|
||||
// Simple flow field - noise-based direction
|
||||
const nx = this.x / canvas.width * 10;
|
||||
const ny = this.y / canvas.height * 10;
|
||||
const angle = noise.perlin2(nx, ny) * Math.PI * 2;
|
||||
|
||||
// Apply pulse variation
|
||||
const pulse = params.pulse.avg + (params.pulse.max - params.pulse.min) *
|
||||
(Math.sin(Date.now() * 0.001) * 0.5 + 0.5);
|
||||
this.vx = Math.cos(angle) * maxSpeed * pulse * 0.5;
|
||||
this.vy = Math.sin(angle) * maxSpeed * pulse * 0.5;
|
||||
|
||||
// Move particle
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
// Boundary handling
|
||||
if (this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height) {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
// Trails
|
||||
this.life++;
|
||||
if (this.life > this.maxLife) {
|
||||
this.reset();
|
||||
this.life = 0;
|
||||
}
|
||||
}
|
||||
|
||||
draw() {
|
||||
const alpha = params.tone.dryness > 0.7 ? 0.1 : 0.3;
|
||||
ctx.strokeStyle = this.color.replace('a)', `, ${alpha})`);
|
||||
ctx.lineWidth = this.size;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.prevX, this.prevY);
|
||||
ctx.lineTo(this.x, this.y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
// Perlin noise for flow field
|
||||
const noise = new Perlin();
|
||||
|
||||
// Initialize particles
|
||||
for (let i = 0; i < particleCount; i++) {
|
||||
particles.push(new Particle());
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
// Clear with fade effect
|
||||
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Update and draw all particles
|
||||
particles.forEach(p => {
|
||||
p.update();
|
||||
p.draw();
|
||||
});
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue