birth: flickering neural fabric

This commit is contained in:
motd_admin 2026-08-12 06:21:20 +00:00
parent c9c233d2a1
commit 2cef9bef94

172
index.html Normal file
View file

@ -0,0 +1,172 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>neural meander</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
color: #333;
font-size: 10px;
font-family: 'Courier New', monospace;
pointer-events: none;
}
</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();
// Parameters derived from the brief
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.1, min: 1.0, max: 1.3 },
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.8, playfulness: 0.1, tension: 0 }
};
// Network graph parameters
const nodeCount = Math.floor(100 + params.density * 300);
const baseLinkCount = Math.floor(nodeCount * params.connectedness * 3);
const maxLinkLength = 300;
const nodeSize = 2 + (1 - params.dryness) * 3;
const linkWidth = 0.5 + (1 - params.dryness) * 1.5;
const linkAlpha = 0.3 + (1 - params.dryness) * 0.4;
const pulseSpeed = 0.05 + params.motion * 0.05;
const pulseVariation = params.pulse.avg + (Math.random() * (params.pulse.max - params.pulse.min) - (params.pulse.max - params.pulse.min)/2);
// Node properties
const nodes = Array.from({ length: nodeCount }, () => ({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
vx: (Math.random() - 0.5) * 2,
vy: (Math.random() - 0.5) * 2,
energy: Math.random(),
pulse: 1,
size: nodeSize
}));
// Links
const links = [];
for (let i = 0; i < baseLinkCount; i++) {
const a = Math.floor(Math.random() * nodeCount);
const b = Math.floor(Math.random() * nodeCount);
if (a !== b) {
links.push({
source: a,
target: b,
distance: Math.random() * maxLinkLength,
strength: 0.1 + Math.random() * 0.9
});
}
}
// Palette based on tone
const palette = {
r: Math.floor(255 * (1 - params.tone.dryness)),
g: Math.floor(255 * (1 - params.tone.dryness)),
b: Math.floor(255 * (1 - params.tone.dryness))
};
// Animation
let time = 0;
function animate() {
ctx.fillStyle = `rgba(10, 10, 10, ${0.1 + params.tone.dryness * 0.2})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update nodes
nodes.forEach(node => {
node.x += node.vx * (0.5 + params.motion * 0.5);
node.y += node.vy * (0.5 + params.motion * 0.5);
// Boundary collision
if (node.x < 0) {
node.x = canvas.width;
node.vx = Math.abs(node.vx);
} else if (node.x > canvas.width) {
node.x = 0;
node.vx = -Math.abs(node.vx);
}
if (node.y < 0) {
node.y = canvas.height;
node.vy = Math.abs(node.vy);
} else if (node.y > canvas.height) {
node.y = 0;
node.vy = -Math.abs(node.vy);
}
// Pulse effect
node.pulse = 1 + Math.sin(time * pulseSpeed) * 0.1 * pulseVariation;
});
// Update links
links.forEach(link => {
const source = nodes[link.source];
const target = nodes[link.target];
const dx = target.x - source.x;
const dy = target.y - source.y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance > link.distance) {
// Apply repulsion force
const angle = Math.atan2(dy, dx);
source.vx -= Math.cos(angle) * link.strength * 0.01;
source.vy -= Math.sin(angle) * link.strength * 0.01;
target.vx += Math.cos(angle) * link.strength * 0.01;
target.vy += Math.sin(angle) * link.strength * 0.01;
}
});
// Draw links
ctx.strokeStyle = `rgba(${palette.r}, ${palette.g}, ${palette.b}, ${linkAlpha})`;
ctx.lineWidth = linkWidth;
links.forEach(link => {
const source = nodes[link.source];
const target = nodes[link.target];
ctx.beginPath();
ctx.moveTo(source.x, source.y);
ctx.lineTo(target.x, target.y);
ctx.stroke();
});
// Draw nodes
nodes.forEach(node => {
ctx.beginPath();
ctx.arc(node.x, node.y, node.size * node.pulse, 0, Math.PI * 2);
ctx.fillStyle = `rgba(${palette.r}, ${palette.g}, ${palette.b}, ${0.6 + 0.4 * node.energy})`;
ctx.fill();
});
time += 0.01;
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>