birth: Pulsing Neural Constellations

This commit is contained in:
motd_admin 2026-05-08 01:47:19 +00:00
parent ca98509850
commit b847ef3d18

178
index.html Normal file
View file

@ -0,0 +1,178 @@
<!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;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
color: #888;
}
canvas {
display: block;
}
#info {
position: absolute;
bottom: 10px;
left: 10px;
font-size: 10px;
opacity: 0.7;
}
</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');
// Set canvas to full window size
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Parameters from the prompt
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.12, min: 0.9, max: 1.3 },
tone: { anger: 0, sadness: 0, curiosity: 0.7, dryness: 0.8, playfulness: 0.1, tension: 0 }
};
// Network graph implementation
class Node {
constructor(x, y) {
this.x = x;
this.y = y;
this.vx = 0;
this.vy = 0;
this.size = 2 + Math.random() * 3;
this.color = `hsl(${Math.random() * 60 + 180}, 80%, ${70 + Math.random() * 10}%)`;
this.lifetime = 0;
this.connections = [];
}
update() {
// Motion with pulse variation
const pulseFactor = params.pulse.avg + (Math.random() * (params.pulse.max - params.pulse.min) - (params.pulse.max - params.pulse.min)/2);
this.x += this.vx * params.motion * pulseFactor;
this.y += this.vy * params.motion * pulseFactor;
// Add slight random movement
this.x += (Math.random() - 0.5) * 0.5 * params.motion;
this.y += (Math.random() - 0.5) * 0.5 * params.motion;
// Boundary check
if (this.x < 0 || this.x > canvas.width) this.vx *= -0.8;
if (this.y < 0 || this.y > canvas.height) this.vy *= -0.8;
this.lifetime++;
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = this.color;
ctx.fill();
}
}
class Network {
constructor() {
this.nodes = [];
this.maxNodes = 50 + Math.floor(params.density * 100);
this.edgeThreshold = 150 + (1 - params.connectedness) * 200;
this.initNodes();
this.initConnections();
}
initNodes() {
for (let i = 0; i < this.maxNodes; i++) {
this.nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
}
initConnections() {
for (let i = 0; i < this.nodes.length; i++) {
for (let j = i + 1; j < this.nodes.length; j++) {
const dx = this.nodes[i].x - this.nodes[j].x;
const dy = this.nodes[i].y - this.nodes[j].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < this.edgeThreshold && Math.random() < params.connectedness) {
this.nodes[i].connections.push(j);
this.nodes[j].connections.push(i);
}
}
}
}
update() {
this.nodes.forEach(node => node.update());
}
draw() {
// Draw connections first (so nodes appear on top)
ctx.strokeStyle = `rgba(200, 230, 255, ${0.3 * params.tone.dryness})`;
ctx.lineWidth = 0.5 + params.complexity;
this.nodes.forEach(node => {
node.connections.forEach(connIndex => {
if (connIndex < this.nodes.length) {
const other = this.nodes[connIndex];
if (this.calculateDistance(node, other) < this.edgeThreshold) {
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(other.x, other.y);
ctx.stroke();
}
}
});
});
// Draw nodes
this.nodes.forEach(node => node.draw());
}
calculateDistance(a, b) {
const dx = a.x - b.x;
const dy = a.y - b.y;
return Math.sqrt(dx * dx + dy * dy);
}
}
// Create network
const network = new Network();
// Animation loop
function animate() {
// Fade background slightly each frame
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
network.update();
network.draw();
requestAnimationFrame(animate);
}
// Start animation
animate();
</script>
</body>
</html>