birth: Monochrome Pulse Networks

This commit is contained in:
motd_admin 2026-10-24 22:21:24 +00:00
parent 017a00690d
commit 5a68448e81

183
index.html Normal file
View file

@ -0,0 +1,183 @@
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neurameba Graph</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 20px;
right: 20px;
color: #666;
font-size: 11px;
mix-blend-mode: difference;
}
</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 input
const motion = 0.5;
const density = 0.5;
const complexity = 0.5;
const connectedness = 0.5;
const lifespan = 0.5;
const pulse = {avg: 1.05, min: 1.0, max: 1.1};
const tone = {anger: 0.0, sadness: 0.0, curiosity: 0.1, dryness: 0.9, playfulness: 0.0, tension: 0.0};
// Generate network
const nodes = [];
const edges = [];
const nodeCount = Math.floor(100 + 400 * density);
const edgeChance = 0.3 * connectedness;
const maxConnections = Math.floor(2 + 8 * connectedness);
const complexityFactor = 1 + 2 * complexity;
// Create nodes
for (let i = 0; i < nodeCount; i++) {
nodes.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
radius: 1 + Math.random() * 3 * complexityFactor,
pulse: 1 + (Math.random() * 0.2 - 0.1) * (pulse.max - pulse.min),
baseRadius: 1 + Math.random() * 3 * complexityFactor,
connections: [],
age: 0,
maxAge: 100 + Math.random() * 200 * lifespan
});
}
// Create edges
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
const possibleConnections = nodes.filter(n =>
n !== node &&
!n.connections.includes(i) &&
node.connections.length < maxConnections &&
Math.random() < edgeChance
);
const connectionCount = Math.floor(Math.random() * maxConnections * connectedness);
for (let j = 0; j < Math.min(connectionCount, possibleConnections.length); j++) {
const other = possibleConnections[j];
const existingEdge = edges.find(e =>
(e.from === i && e.to === nodes.indexOf(other)) ||
(e.from === nodes.indexOf(other) && e.to === i)
);
if (!existingEdge) {
edges.push({
from: i,
to: nodes.indexOf(other),
strength: 0.3 + Math.random() * 0.7 * connectedness,
length: 0,
maxLength: Math.sqrt(
Math.pow(node.x - other.x, 2) +
Math.pow(node.y - other.y, 2)
) * 0.8
});
node.connections.push(nodes.indexOf(other));
other.connections.push(i);
}
}
}
// Animation
function drawNetwork(timestamp) {
// Clear with low alpha for trail effect
ctx.fillStyle = `rgba(10, 10, 10, ${0.1 * motion})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update nodes
nodes.forEach(node => {
node.age++;
node.radius = node.baseRadius * node.pulse;
});
// Update edges
edges.forEach(edge => {
const fromNode = nodes[edge.from];
const toNode = nodes[edge.to];
const dx = toNode.x - fromNode.x;
const dy = toNode.y - fromNode.y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
edge.length += (distance - edge.length) * 0.05 * motion;
}
// Draw edges with pulse effect
const alpha = 0.3 + 0.7 * Math.min(1, edge.length / edge.maxLength);
ctx.strokeStyle = `rgba(255, 255, 255, ${alpha * motion})`;
ctx.lineWidth = 0.5 + 1.5 * edge.strength * motion;
ctx.beginPath();
ctx.moveTo(fromNode.x, fromNode.y);
ctx.lineTo(fromNode.x + dx * (edge.length / distance),
fromNode.y + dy * (edge.length / distance));
ctx.stroke();
});
// Draw nodes
nodes.forEach(node => {
if (node.age > node.maxAge) return;
// Pulse effect
const pulseFactor = 1 + 0.1 * Math.sin(timestamp * 0.003) * motion;
node.pulse = pulse.avg * pulseFactor;
// Draw with dryness-based style (monochrome)
ctx.fillStyle = `hsl(0, 0%, ${90 + 10 * Math.sin(timestamp * 0.001)}%)`;
ctx.beginPath();
ctx.arc(node.x, node.y, node.radius * node.pulse, 0, Math.PI * 2);
ctx.fill();
// Draw connection points
ctx.fillStyle = `hsl(0, 0%, ${30 + 20 * Math.sin(timestamp * 0.002 + node.x * 0.01)}%)`;
node.connections.forEach(connIndex => {
const connNode = nodes[connIndex];
const dx = connNode.x - node.x;
const dy = connNode.y - node.y;
const dist = Math.sqrt(dx * dx + dy * dy);
const midX = node.x + dx * 0.5;
const midY = node.y + dy * 0.5;
ctx.save();
ctx.translate(midX, midY);
ctx.rotate(Math.atan2(dy, dx) + Math.PI / 2);
ctx.fillRect(-1, -3, 2, 6);
ctx.restore();
});
});
requestAnimationFrame(drawNetwork);
}
drawNetwork(0);
</script>
</body>
</html>
```