birth: Pulsing Nerve Web
This commit is contained in:
parent
397a870d13
commit
389a829541
1 changed files with 236 additions and 0 deletions
236
index.html
Normal file
236
index.html
Normal file
|
|
@ -0,0 +1,236 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba · motd.social</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
color: #aaa;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
#canvas {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
text-align: right;
|
||||||
|
padding: 8px 16px;
|
||||||
|
font-size: 12px;
|
||||||
|
background: rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
|
</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 derived from the abstract specs
|
||||||
|
const params = {
|
||||||
|
motion: 0.540,
|
||||||
|
density: 0.544,
|
||||||
|
complexity: 0.504,
|
||||||
|
connectedness: 0.522,
|
||||||
|
lifespan: 0.545,
|
||||||
|
pulseAvg: 0.40,
|
||||||
|
pulseMin: 0.30,
|
||||||
|
pulseMax: 1.50,
|
||||||
|
energy: 413.7,
|
||||||
|
loops: 484,
|
||||||
|
nodes: 90,
|
||||||
|
branches: 81,
|
||||||
|
thickness: 1.25,
|
||||||
|
fractalDim: 1.421
|
||||||
|
};
|
||||||
|
|
||||||
|
// Network graph simulation
|
||||||
|
class Node {
|
||||||
|
constructor(id) {
|
||||||
|
this.id = id;
|
||||||
|
this.x = Math.random() * canvas.width;
|
||||||
|
this.y = Math.random() * canvas.height;
|
||||||
|
this.vx = (Math.random() - 0.5) * params.motion;
|
||||||
|
this.vy = (Math.random() - 0.5) * params.motion;
|
||||||
|
this.radius = 2 + Math.random() * 5 * params.density;
|
||||||
|
this.connections = [];
|
||||||
|
this.energy = 50 + Math.random() * 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
// Apply pulse influence
|
||||||
|
const pulseFactor = params.pulseAvg + (Math.random() * (params.pulseMax - params.pulseMin) - (params.pulseMax - params.pulseMin)/2);
|
||||||
|
this.vx += (Math.random() - 0.5) * params.motion * 0.5 * pulseFactor;
|
||||||
|
this.vy += (Math.random() - 0.5) * params.motion * 0.5 * pulseFactor;
|
||||||
|
|
||||||
|
// Boundary checks
|
||||||
|
this.x += this.vx;
|
||||||
|
this.y += this.vy;
|
||||||
|
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; }
|
||||||
|
|
||||||
|
// Energy decay
|
||||||
|
this.energy -= 0.05 * (1 - params.lifespan);
|
||||||
|
this.radius = 2 + (5 * params.density) * (this.energy / 100);
|
||||||
|
|
||||||
|
// Connection management
|
||||||
|
this.connections = this.connections.filter(conn => {
|
||||||
|
return conn.target.energy > 10;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `rgba(200, 200, 200, ${this.energy / 100})`;
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Connection {
|
||||||
|
constructor(source, target, strength) {
|
||||||
|
this.source = source;
|
||||||
|
this.target = target;
|
||||||
|
this.strength = strength;
|
||||||
|
this.energy = 200 + Math.random() * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.energy -= 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
const opacity = this.energy / 200;
|
||||||
|
const dist = Math.sqrt(
|
||||||
|
Math.pow(this.target.x - this.source.x, 2) +
|
||||||
|
Math.pow(this.target.y - this.source.y, 2)
|
||||||
|
);
|
||||||
|
const thickness = 0.2 + this.strength * params.thickness * 2;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.source.x, this.source.y);
|
||||||
|
ctx.lineTo(this.target.x, this.target.y);
|
||||||
|
|
||||||
|
// Gradient for connection
|
||||||
|
const gradient = ctx.createLinearGradient(
|
||||||
|
this.source.x, this.source.y,
|
||||||
|
this.target.x, this.target.y
|
||||||
|
);
|
||||||
|
gradient.addColorStop(0, `rgba(200, 200, 255, ${opacity})`);
|
||||||
|
gradient.addColorStop(1, `rgba(150, 150, 200, ${opacity})`);
|
||||||
|
ctx.strokeStyle = gradient;
|
||||||
|
ctx.lineWidth = thickness;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NetworkGraph {
|
||||||
|
constructor() {
|
||||||
|
this.nodes = [];
|
||||||
|
this.connections = [];
|
||||||
|
this.time = 0;
|
||||||
|
|
||||||
|
// Create nodes
|
||||||
|
for (let i = 0; i < params.nodes; i++) {
|
||||||
|
this.nodes.push(new Node(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create connections
|
||||||
|
for (let i = 0; i < params.nodes; i++) {
|
||||||
|
for (let j = i + 1; j < Math.min(i + 3 + Math.floor(params.connectedness * 10), params.nodes); j++) {
|
||||||
|
const strength = 0.3 + Math.random() * 0.7;
|
||||||
|
const conn = new Connection(this.nodes[i], this.nodes[j], strength);
|
||||||
|
this.connections.push(conn);
|
||||||
|
this.nodes[i].connections.push(conn);
|
||||||
|
this.nodes[j].connections.push(conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
// Node updates
|
||||||
|
this.nodes.forEach(node => node.update());
|
||||||
|
|
||||||
|
// Connection updates
|
||||||
|
this.connections.forEach(conn => {
|
||||||
|
conn.update();
|
||||||
|
// Energy sharing between connected nodes
|
||||||
|
conn.source.energy += conn.strength * 0.1;
|
||||||
|
conn.target.energy += conn.strength * 0.1;
|
||||||
|
conn.source.energy = Math.min(conn.source.energy, 100);
|
||||||
|
conn.target.energy = Math.min(conn.target.energy, 100);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove dead connections
|
||||||
|
this.connections = this.connections.filter(conn => conn.energy > 5);
|
||||||
|
|
||||||
|
// Periodically create new connections based on network density
|
||||||
|
this.time++;
|
||||||
|
if (this.time % Math.floor(60 * (1 - params.connectedness)) === 0 && this.connections.length < 500) {
|
||||||
|
const available = this.nodes.filter(n => n.connections.length < 5);
|
||||||
|
if (available.length >= 2) {
|
||||||
|
const a = available[Math.floor(Math.random() * available.length)];
|
||||||
|
const b = available[Math.floor(Math.random() * available.length)];
|
||||||
|
if (a !== b) {
|
||||||
|
const strength = 0.2 + Math.random() * 0.6;
|
||||||
|
const conn = new Connection(a, b, strength);
|
||||||
|
this.connections.push(conn);
|
||||||
|
a.connections.push(conn);
|
||||||
|
b.connections.push(conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
// Clear with dark background
|
||||||
|
ctx.fillStyle = '#0a0a0a';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Draw connections first (background)
|
||||||
|
ctx.lineCap = 'round';
|
||||||
|
this.connections.forEach(conn => conn.draw());
|
||||||
|
|
||||||
|
// Draw nodes (foreground)
|
||||||
|
this.nodes.forEach(node => node.draw());
|
||||||
|
|
||||||
|
// Draw loops indicator occasionally
|
||||||
|
if (this.time % 120 === 0) {
|
||||||
|
ctx.fillStyle = 'rgba(255, 255, 255, 0.2)';
|
||||||
|
ctx.font = '12px monospace';
|
||||||
|
ctx.textAlign = 'right';
|
||||||
|
ctx.fillText(`loops: ${this.connections.length}`, canvas.width - 20, canvas.height - 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
let network = new NetworkGraph();
|
||||||
|
function animate() {
|
||||||
|
network.update();
|
||||||
|
network.draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue