birth: Pulsing Neural Constellations

This commit is contained in:
motd_admin 2026-11-08 10:21:41 +00:00
parent fac87c3f06
commit 08e9e396d0

272
index.html Normal file
View file

@ -0,0 +1,272 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neurameba Network</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background: #111;
color: #aaa;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
font-size: 10px;
color: #555;
text-align: right;
}
</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 from prompt
const params = {
motion: 0.528,
density: 0.575,
complexity: 0.667,
connectedness: 0.829,
lifespan: 0.450,
pulse: { avg: 0.40, min: 0.30, max: 1.25 },
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 },
topology: {
nodes: 6,
branches: 6,
loops: 40,
maxDepth: 4,
thicknessRatio: 1.25,
fractalDim: 1.000,
energy: 37.4
}
};
// Network graph implementation
class NetworkNode {
constructor(x, y, id) {
this.x = x;
this.y = y;
this.id = id;
this.vx = 0;
this.vy = 0;
this.radius = 2 + Math.random() * 3;
this.color = `hsl(200, ${50 + Math.random() * 50}%, ${70 + Math.random() * 30}%)`;
this.connections = new Set();
this.pulse = 0;
this.targetPulse = 0.5 + Math.random() * 0.5;
}
connectTo(node) {
if (node !== this && Math.random() > 0.3) {
this.connections.add(node);
node.connections.add(this);
}
}
update() {
// Pulse variation
this.pulse += (this.targetPulse - this.pulse) * 0.05;
this.targetPulse = 0.3 + Math.random() * 0.4;
// Movement
this.vx += (Math.random() - 0.5) * params.motion * 0.5;
this.vy += (Math.random() - 0.5) * params.motion * 0.5;
this.vx *= 0.9;
this.vy *= 0.9;
this.x += this.vx;
this.y += this.vy;
// Boundary check
if (this.x < 0 || this.x > canvas.width) this.vx *= -0.5;
if (this.y < 0 || this.y > canvas.height) this.vy *= -0.5;
this.x = Math.max(0, Math.min(canvas.width, this.x));
this.y = Math.max(0, Math.min(canvas.height, this.y));
}
}
class NetworkGraph {
constructor() {
this.nodes = [];
this.edges = [];
this.initNodes();
this.initConnections();
}
initNodes() {
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
const radius = Math.min(canvas.width, canvas.height) * 0.3;
for (let i = 0; i < params.topology.nodes; i++) {
const angle = (i / params.topology.nodes) * Math.PI * 2;
const x = centerX + Math.cos(angle) * radius;
const y = centerY + Math.sin(angle) * radius;
this.nodes.push(new NetworkNode(x, y, i));
}
}
initConnections() {
// Primary connections (ring)
for (let i = 0; i < this.nodes.length; i++) {
const next = (i + 1) % this.nodes.length;
this.nodes[i].connections.add(this.nodes[next]);
this.nodes[next].connections.add(this.nodes[i]);
}
// Secondary connections (random)
for (let i = 0; i < this.nodes.length; i++) {
for (let j = 0; j < this.nodes.length; j++) {
if (i !== j && Math.random() > 0.5) {
this.nodes[i].connections.add(this.nodes[j]);
}
}
}
// Create edge list from connections
const edgesSet = new Set();
for (const node of this.nodes) {
for (const connectedNode of node.connections) {
if (node.id < connectedNode.id) { // Avoid duplicate edges
edgesSet.add(`${node.id}-${connectedNode.id}`);
}
}
}
this.edges = Array.from(edgesSet).map(edge => {
const [a, b] = edge.split('-').map(Number);
return {
from: this.nodes[a],
to: this.nodes[b],
weight: 1 + Math.random() * params.topology.thicknessRatio
};
});
}
update() {
this.nodes.forEach(node => node.update());
// Apply small attractive/repulsive forces between connected nodes
for (let i = 0; i < this.nodes.length; i++) {
for (let j = i + 1; j < this.nodes.length; j++) {
const nodeA = this.nodes[i];
const nodeB = this.nodes[j];
const hasConnection = nodeA.connections.has(nodeB);
const dx = nodeB.x - nodeA.x;
const dy = nodeB.y - nodeA.y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (hasConnection) {
// Attract connected nodes
if (distance > 50) {
const force = 0.1 * params.connectedness * (distance - 50);
nodeA.vx += dx / distance * force;
nodeA.vy += dy / distance * force;
nodeB.vx -= dx / distance * force;
nodeB.vy -= dy / distance * force;
}
// Repel if too close
if (distance < 30) {
const force = 0.2 * params.connectedness * (30 - distance);
nodeA.vx -= dx / distance * force;
nodeA.vy -= dy / distance * force;
nodeB.vx += dx / distance * force;
nodeB.vy += dy / distance * force;
}
}
}
}
}
draw() {
// Draw edges
ctx.strokeStyle = `rgba(200, 220, 255, ${0.3 + params.tone.dryness * 0.4})`;
ctx.lineWidth = params.topology.thicknessRatio * 0.5;
this.edges.forEach(edge => {
ctx.beginPath();
ctx.moveTo(edge.from.x, edge.from.y);
ctx.lineTo(edge.to.x, edge.to.y);
ctx.stroke();
});
// Draw nodes
this.nodes.forEach(node => {
const size = node.radius * (0.8 + node.pulse * 0.2);
const alpha = 0.7 + node.pulse * 0.3;
// Draw node core
ctx.beginPath();
ctx.arc(node.x, node.y, size, 0, Math.PI * 2);
ctx.fillStyle = node.color;
ctx.globalAlpha = alpha;
ctx.fill();
// Draw pulse ring
ctx.beginPath();
ctx.arc(node.x, node.y, size * 1.2, 0, Math.PI * 2);
ctx.strokeStyle = node.color;
ctx.lineWidth = 0.5;
ctx.globalAlpha = alpha * 0.3;
ctx.stroke();
ctx.globalAlpha = 1;
});
// Draw loops (highlighted connections)
if (params.topology.loops > 0) {
const loopCount = Math.min(params.topology.loops, this.edges.length * 0.5);
for (let i = 0; i < loopCount; i++) {
const edge = this.edges[i % this.edges.length];
ctx.beginPath();
ctx.moveTo(edge.from.x, edge.from.y);
ctx.quadraticCurveTo(
canvas.width * 0.5,
canvas.height * 0.5,
edge.to.x,
edge.to.y
);
ctx.strokeStyle = `rgba(255, 255, 255, ${0.1 + params.tone.dryness * 0.2})`;
ctx.lineWidth = edge.weight * 0.8;
ctx.stroke();
}
}
}
}
const network = new NetworkGraph();
function animate() {
ctx.fillStyle = 'rgba(17, 17, 20, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
network.update();
network.draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>