birth: Flowing Curiosity Fields

This commit is contained in:
motd_admin 2026-10-08 06:21:25 +00:00
parent b9fbd13cd9
commit e68b0d98e9

212
index.html Normal file
View file

@ -0,0 +1,212 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flow Field Organism</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
color: rgba(255, 255, 255, 0.2);
font-size: 10px;
font-family: 'Courier New', monospace;
}
</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');
// Set canvas to full window size
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Parameters
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.08, min: 0.95, max: 1.20 },
tone: {
anger: 0.00,
sadness: 0.00,
curiosity: 0.70,
dryness: 0.90,
playfulness: 0.10,
tension: 0.00
}
};
// Flow field grid
const gridSize = 50;
const cols = Math.ceil(canvas.width / gridSize) + 2;
const rows = Math.ceil(canvas.height / gridSize) + 2;
const field = [];
// Particles
const particles = [];
const particleCount = 500;
// Initialize flow field
function initField() {
field.length = 0;
for (let y = 0; y < rows; y++) {
field[y] = [];
for (let x = 0; x < cols; x++) {
// Base flow direction (slightly angled)
const baseAngle = (Math.sin(x * 0.1) * Math.PI / 4) + (Math.cos(y * 0.1) * Math.PI / 6);
const baseForce = 0.5 + (Math.sin(x * 0.03) * 0.1) + (Math.cos(y * 0.03) * 0.1);
field[y][x] = {
angle: baseAngle,
force: baseForce * params.motion,
influence: params.connectedness * 0.3 + 0.2
};
}
}
}
// Initialize particles
function initParticles() {
particles.length = 0;
for (let i = 0; i < particleCount * params.density; i++) {
particles.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
size: 1 + Math.random() * 2,
speed: 0.3 + Math.random() * 0.5,
lifespan: params.lifespan * 100 + 50 + Math.random() * 50,
life: 0,
hue: 180 + Math.random() * 30,
saturation: 50 + Math.random() * 20,
lightness: 60 + Math.random() * 10,
prevX: null,
prevY: null
});
}
}
// Update flow field based on pulse
function updateField() {
const pulseFactor = params.pulse.avg * (0.8 + Math.sin(Date.now() * 0.002) * 0.2);
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
// Add some organic variation
const variation = Math.sin(x * 0.2 + Date.now() * 0.001) * 0.1 +
Math.cos(y * 0.2 + Date.now() * 0.0015) * 0.1;
field[y][x].angle += variation * pulseFactor;
}
}
}
// Update particle positions
function updateParticles() {
particles.forEach(p => {
// Move particle
const gridX = Math.floor(p.x / gridSize);
const gridY = Math.floor(p.y / gridSize);
const fieldCell = field[gridY][gridX];
p.x += Math.cos(fieldCell.angle) * p.speed * fieldCell.force;
p.y += Math.sin(fieldCell.angle) * p.speed * fieldCell.force;
// Wrap around edges
if (p.x < 0) p.x = canvas.width;
if (p.x > canvas.width) p.x = 0;
if (p.y < 0) p.y = canvas.height;
if (p.y > canvas.height) p.y = 0;
p.life++;
p.brightness = 100 * (1 - (p.life / p.lifespan));
});
// Remove dead particles and add new ones based on density
for (let i = particles.length - 1; i >= 0; i--) {
if (particles[i].life > particles[i].lifespan) {
particles.splice(i, 1);
}
}
// Add new particles to maintain density
while (particles.length < particleCount * params.density) {
particles.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
size: 1 + Math.random() * 2,
speed: 0.3 + Math.random() * 0.5,
lifespan: params.lifespan * 100 + 50 + Math.random() * 50,
life: 0,
hue: 180 + Math.random() * 30,
saturation: 50 + Math.random() * 20,
lightness: 60 + Math.random() * 10,
prevX: null,
prevY: null
});
}
}
// Draw particles
function drawParticles() {
ctx.strokeStyle = `hsla(${params.tone.curiosity * 180 + 180}, ${60 + params.tone.playfulness * 20}%, ${70 - params.tone.dryness * 30}%, ${0.7 + params.tone.playfulness * 0.3})`;
ctx.lineWidth = 1;
particles.forEach(p => {
// Draw a trail
if (p.prevX && p.prevY) {
ctx.beginPath();
ctx.moveTo(p.prevX, p.prevY);
ctx.lineTo(p.x, p.y);
ctx.stroke();
}
p.prevX = p.x;
p.prevY = p.y;
// Draw particle
ctx.beginPath();
ctx.arc(p.x, p.y, p.size * (0.5 + p.life / p.lifespan * 0.5), 0, Math.PI * 2);
ctx.fillStyle = `hsla(${p.hue + params.tone.playfulness * 20}, ${p.saturation}, ${Math.min(90, p.lightness + p.life / p.lifespan * 10)}, ${0.3 + params.tone.dryness * 0.4})`;
ctx.fill();
});
}
// Animation loop
function animate() {
// Clear with slight fade
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
updateField();
updateParticles();
drawParticles();
requestAnimationFrame(animate);
}
// Initialize and start
initField();
initParticles();
animate();
</script>
</body>
</html>