birth: Sparse Pulse Networks
This commit is contained in:
parent
852065000f
commit
00ea1d7ee9
1 changed files with 250 additions and 0 deletions
250
index.html
Normal file
250
index.html
Normal file
|
|
@ -0,0 +1,250 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba System</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 10px;
|
||||||
|
color: #555;
|
||||||
|
font-size: 10px;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
</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');
|
||||||
|
|
||||||
|
// Set canvas to full window size
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters adjusted from input
|
||||||
|
const params = {
|
||||||
|
motion: 0.514,
|
||||||
|
density: 0.528,
|
||||||
|
complexity: 0.506,
|
||||||
|
connectedness: 0.456,
|
||||||
|
lifespan: 0.480,
|
||||||
|
survivingNodes: 78,
|
||||||
|
branchCount: 70,
|
||||||
|
loops: 434,
|
||||||
|
maxDepth: 17,
|
||||||
|
thicknessRatio: 1.5,
|
||||||
|
fractalDimension: 1.743,
|
||||||
|
finalEnergy: 401.7,
|
||||||
|
pulse: { avg: 0.47, min: 0.3, max: 1.75 },
|
||||||
|
tone: { anger: 0.0, sadness: 0.0, curiosity: 0.3, dryness: 0.8, playfulness: 0.1, tension: 0.0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Network graph implementation
|
||||||
|
class NetworkNode {
|
||||||
|
constructor(x, y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.vx = 0;
|
||||||
|
this.vy = 0;
|
||||||
|
this.size = 0.5 + Math.random() * 1.5;
|
||||||
|
this.connectionCount = 0;
|
||||||
|
this.lifetime = 0;
|
||||||
|
this.maxLifetime = 100 + Math.random() * 200;
|
||||||
|
this.pulse = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(neighbors) {
|
||||||
|
this.lifetime++;
|
||||||
|
this.pulse = Math.sin(this.lifetime * 0.1) * 0.5 + 0.5;
|
||||||
|
|
||||||
|
// Simple repulsion/attraction based on connection count
|
||||||
|
const repulsion = 0.05;
|
||||||
|
const attraction = 0.02;
|
||||||
|
const maxConnections = 6;
|
||||||
|
|
||||||
|
this.vx *= 0.9;
|
||||||
|
this.vy *= 0.9;
|
||||||
|
|
||||||
|
// Connected nodes attract each other
|
||||||
|
for (const n of neighbors) {
|
||||||
|
if (n !== this) {
|
||||||
|
const dx = n.x - this.x;
|
||||||
|
const dy = n.y - this.y;
|
||||||
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (this.connectionCount < maxConnections) {
|
||||||
|
// Stronger attraction if not at max connections
|
||||||
|
this.vx += dx * attraction * (1 + (maxConnections - this.connectionCount) * 0.1);
|
||||||
|
this.vy += dy * attraction * (1 + (maxConnections - this.connectionCount) * 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repulsion from all nodes
|
||||||
|
this.vx -= dx * repulsion / (dist * dist + 1);
|
||||||
|
this.vy -= dy * repulsion / (dist * dist + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dampening
|
||||||
|
this.x += this.vx;
|
||||||
|
this.y += this.vy;
|
||||||
|
|
||||||
|
// Boundary check
|
||||||
|
if (this.x < 0) this.x = canvas.width;
|
||||||
|
if (this.x > canvas.width) this.x = 0;
|
||||||
|
if (this.y < 0) this.y = canvas.height;
|
||||||
|
if (this.y > canvas.height) this.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
const opacity = Math.min(1, this.lifetime / this.maxLifetime);
|
||||||
|
const colorValue = 100 + Math.random() * 50; // Gray scale with slight variation
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.size * this.pulse * 2, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `rgba(${colorValue}, ${colorValue}, ${colorValue}, ${opacity * 0.7})`;
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
// Draw connections
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.strokeStyle = `rgba(${colorValue}, ${colorValue}, ${colorValue}, ${opacity * 0.3})`;
|
||||||
|
ctx.lineWidth = this.size * this.pulse * params.thicknessRatio;
|
||||||
|
ctx.moveTo(this.x, this.y);
|
||||||
|
// Connections will be drawn in the main drawing function
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NetworkGraph {
|
||||||
|
constructor() {
|
||||||
|
this.nodes = [];
|
||||||
|
this.connections = [];
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
// Create nodes
|
||||||
|
const nodeCount = params.survivingNodes;
|
||||||
|
|
||||||
|
for (let i = 0; i < nodeCount; i++) {
|
||||||
|
const angle = (i / nodeCount) * Math.PI * 2;
|
||||||
|
const radius = Math.min(canvas.width, canvas.height) * 0.3;
|
||||||
|
const x = canvas.width / 2 + Math.cos(angle) * radius;
|
||||||
|
const y = canvas.height / 2 + Math.sin(angle) * radius;
|
||||||
|
this.nodes.push(new NetworkNode(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create connections ensuring some loops
|
||||||
|
const targetConnections = params.branchCount;
|
||||||
|
const maxConnections = 6;
|
||||||
|
|
||||||
|
for (let i = 0; i < this.nodes.length; i++) {
|
||||||
|
const nodeA = this.nodes[i];
|
||||||
|
const possibleConnections = this.nodes.slice();
|
||||||
|
possibleConnections.sort(() => Math.random() - 0.5);
|
||||||
|
|
||||||
|
let connectionsMade = 0;
|
||||||
|
|
||||||
|
for (const nodeB of possibleConnections) {
|
||||||
|
if (nodeA === nodeB) continue;
|
||||||
|
if (connectionsMade >= targetConnections) break;
|
||||||
|
if (nodeA.connectionCount >= maxConnections || nodeB.connectionCount >= maxConnections) continue;
|
||||||
|
|
||||||
|
// Ensure we don't create duplicates
|
||||||
|
const exists = this.connections.some(conn =>
|
||||||
|
(conn[0] === nodeA && conn[1] === nodeB) ||
|
||||||
|
(conn[0] === nodeB && conn[1] === nodeA));
|
||||||
|
|
||||||
|
if (!exists) {
|
||||||
|
this.connections.push([nodeA, nodeB]);
|
||||||
|
nodeA.connectionCount++;
|
||||||
|
nodeB.connectionCount++;
|
||||||
|
connectionsMade++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
for (const node of this.nodes) {
|
||||||
|
const neighbors = [];
|
||||||
|
|
||||||
|
for (const conn of this.connections) {
|
||||||
|
if (conn[0] === node) neighbors.push(conn[1]);
|
||||||
|
if (conn[1] === node) neighbors.push(conn[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
node.update(neighbors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
// Draw connections first
|
||||||
|
for (const conn of this.connections) {
|
||||||
|
ctx.beginPath();
|
||||||
|
const nodeA = conn[0];
|
||||||
|
const nodeB = conn[1];
|
||||||
|
|
||||||
|
const opacity = Math.min(1,
|
||||||
|
nodeA.lifetime / nodeA.maxLifetime,
|
||||||
|
nodeB.lifetime / nodeB.maxLifetime);
|
||||||
|
|
||||||
|
const colorValue = 120 + Math.random() * 30;
|
||||||
|
ctx.strokeStyle = `rgba(${colorValue}, ${colorValue}, ${colorValue}, ${opacity * 0.2})`;
|
||||||
|
ctx.lineWidth = Math.min(4,
|
||||||
|
nodeA.size * nodeA.pulse * params.thicknessRatio,
|
||||||
|
nodeB.size * nodeB.pulse * params.thicknessRatio);
|
||||||
|
|
||||||
|
ctx.moveTo(nodeA.x, nodeA.y);
|
||||||
|
ctx.lineTo(nodeB.x, nodeB.y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw nodes
|
||||||
|
for (const node of this.nodes) {
|
||||||
|
node.draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let graph = new NetworkGraph();
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
// Fade effect for trail
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
graph.update();
|
||||||
|
graph.draw();
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
|
||||||
|
// Pulse effect on connections based on params.pulse
|
||||||
|
setInterval(() => {
|
||||||
|
for (const conn of graph.connections) {
|
||||||
|
conn[0].pulse = params.pulse.avg;
|
||||||
|
conn[1].pulse = params.pulse.avg;
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue