birth: Whispering Web of Echoes

This commit is contained in:
motd_admin 2026-07-19 21:47:23 +00:00
parent ede9041beb
commit 7caf7e0ac7

233
index.html Normal file
View file

@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recursive Networks</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: monospace;
color: #555;
}
#canvas {
display: block;
}
#info {
position: absolute;
bottom: 20px;
left: 0;
right: 0;
text-align: center;
font-size: 10px;
opacity: 0.5;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="info">neurameba · motd.social</div>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
// Parameters derived from input
const motion = 0.5;
const density = 0.5;
const complexity = 0.5;
const connectedness = 0.5;
const lifespan = 0.5;
const pulseAvg = 1.05;
const pulseMin = 1.0;
const pulseMax = 1.1;
const dryness = 0.8;
// Network parameters
const nodeCount = Math.floor(100 + density * 400);
const maxConnections = Math.floor(1 + connectedness * 5);
const branchFactor = 1 + complexity * 1.5;
const reconnectionProb = 0.3;
// Network state
const nodes = [];
const edges = [];
let time = 0;
// Initialize network
for (let i = 0; i < nodeCount; i++) {
nodes.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
radius: 2 + Math.random() * 4 * density,
vx: (Math.random() - 0.5) * motion * 2,
vy: (Math.random() - 0.5) * motion * 2,
connections: [],
energy: 0.5 + Math.random() * 0.5 * lifespan
});
}
// Connect nodes
for (let i = 0; i < nodeCount; i++) {
const node = nodes[i];
const connectionCount = Math.floor(Math.random() * maxConnections);
const neighbors = [];
for (let j = 0; j < nodeCount; j++) {
if (i === j) continue;
const dist = Math.hypot(nodes[j].x - node.x, nodes[j].y - node.y);
if (dist < 200 * (1 - density)) {
neighbors.push(j);
}
}
// Sort by proximity
neighbors.sort((a, b) => {
const distA = Math.hypot(nodes[a].x - node.x, nodes[a].y - node.y);
const distB = Math.hypot(nodes[b].x - node.x, nodes[b].y - node.y);
return distA - distB;
});
// Take closest ones
for (let j = 0; j < Math.min(connectionCount, neighbors.length); j++) {
const target = neighbors[j];
if (!nodes[target].connections.includes(i) &&
node.connections.length < maxConnections) {
node.connections.push(target);
nodes[target].connections.push(i);
edges.push({
from: i,
to: target,
strength: 0.5 + Math.random() * 0.5,
birth: time
});
}
}
}
// Age edges
function ageEdges() {
for (let i = edges.length - 1; i >= 0; i--) {
if (Math.random() < 0.01) {
edges.splice(i, 1);
}
}
}
// Network update
function update() {
time += 0.016;
// Pulse
const pulse = pulseMin + (pulseMax - pulseMin) * 0.5 * (1 + Math.sin(time * 0.5));
// Update nodes
for (const node of nodes) {
// Movement
node.x += node.vx * pulse;
node.y += node.vy * pulse;
// Boundary check
if (node.x < 0) { node.x = canvas.width; node.vx *= -1; }
if (node.x > canvas.width) { node.x = 0; node.vx *= -1; }
if (node.y < 0) { node.y = canvas.height; node.vy *= -1; }
if (node.y > canvas.height) { node.y = 0; node.vy *= -1; }
// Energy decay
node.energy *= 0.998;
}
// Add new edges based on proximity and connectedness
for (let i = 0; i < nodeCount; i++) {
const node = nodes[i];
if (Math.random() < 0.01 * reconnectionProb) {
// Find closest node not already connected
let closest = null;
let closestDist = Infinity;
for (let j = 0; j < nodeCount; j++) {
if (i === j) continue;
if (node.connections.includes(j)) continue;
const dist = Math.hypot(nodes[j].x - node.x, nodes[j].y - node.y);
if (dist < 200 * (1 - density) && dist < closestDist) {
closest = j;
closestDist = dist;
}
}
if (closest !== null && node.connections.length < maxConnections) {
node.connections.push(closest);
nodes[closest].connections.push(i);
edges.push({
from: i,
to: closest,
strength: 0.3 + Math.random() * 0.7,
birth: time
});
}
}
}
ageEdges();
}
// Drawing
function draw() {
// Clear with slight trail
ctx.fillStyle = `rgba(10, 10, 10, ${0.9 - lifespan * 0.4})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw edges
ctx.lineWidth = 1;
for (const edge of edges) {
const fromNode = nodes[edge.from];
const toNode = nodes[edge.to];
const age = time - edge.birth;
const strength = edge.strength * (1 - age * 0.001);
if (strength <= 0) continue;
// Fade based on node energy
const energy = (fromNode.energy + toNode.energy) * 0.5;
const alpha = strength * energy * (1 - dryness * 0.3);
ctx.strokeStyle = `rgba(220, 220, 220, ${alpha})`;
ctx.beginPath();
ctx.moveTo(fromNode.x, fromNode.y);
ctx.lineTo(toNode.x, toNode.y);
ctx.stroke();
}
// Draw nodes
for (const node of nodes) {
const pulse = pulseMin + (pulseMax - pulseMin) * 0.5 * (1 + Math.sin(time * 0.5));
const radius = node.radius * pulse * node.energy;
// Fade based on energy
const alpha = node.energy * (1 - dryness * 0.5);
ctx.fillStyle = `rgba(255, 255, 255, ${alpha})`;
ctx.beginPath();
ctx.arc(node.x, node.y, radius, 0, Math.PI * 2);
ctx.fill();
}
}
function animate() {
update();
draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>