birth: Neural Nebula Pulse
This commit is contained in:
parent
af352a8d39
commit
0d71394e9a
1 changed files with 191 additions and 0 deletions
191
index.html
Normal file
191
index.html
Normal file
|
|
@ -0,0 +1,191 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neural Nebula</title>
|
||||||
|
<style>
|
||||||
|
body { margin: 0; overflow: hidden; background: #0a0a0a; }
|
||||||
|
canvas { display: block; }
|
||||||
|
#info { position: absolute; bottom: 10px; right: 10px; color: #444; font-family: monospace; font-size: 10px; }
|
||||||
|
</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');
|
||||||
|
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters derived from the specification
|
||||||
|
const params = {
|
||||||
|
motion: 0.511,
|
||||||
|
density: 0.504,
|
||||||
|
complexity: 0.472,
|
||||||
|
connectedness: 0.479,
|
||||||
|
lifespan: 0.545,
|
||||||
|
pulse: { avg: 0.40, min: 0.30, max: 1.60 },
|
||||||
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.20, dryness: 0.80, playfulness: 0.10, tension: 0.00 },
|
||||||
|
topology: {
|
||||||
|
nodes: 145,
|
||||||
|
branches: 132,
|
||||||
|
loops: 1191,
|
||||||
|
maxDepth: 26,
|
||||||
|
thicknessRatio: 1.75,
|
||||||
|
fractalDim: 0.868,
|
||||||
|
finalEnergy: 935.0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Color palette based on tone
|
||||||
|
const palette = {
|
||||||
|
bg: '#0a0a0a',
|
||||||
|
node: params.tone.dryness > 0.7 ? '#cccccc' : '#a0a0a0',
|
||||||
|
edge: params.tone.dryness > 0.7 ? '#666666' : '#888888',
|
||||||
|
pulse: params.tone.playfulness > 0.2 ? '#aaffff' : '#999999',
|
||||||
|
highlight: params.tone.curiosity > 0.1 ? '#44ffaa' : '#777777'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Network graph nodes and edges
|
||||||
|
const nodes = [];
|
||||||
|
const edges = [];
|
||||||
|
|
||||||
|
// Initialize network
|
||||||
|
function initNetwork() {
|
||||||
|
// Create nodes with random positions
|
||||||
|
for (let i = 0; i < params.topology.nodes; i++) {
|
||||||
|
nodes.push({
|
||||||
|
x: Math.random() * canvas.width,
|
||||||
|
y: Math.random() * canvas.height,
|
||||||
|
vx: (Math.random() - 0.5) * 2,
|
||||||
|
vy: (Math.random() - 0.5) * 2,
|
||||||
|
size: 1 + Math.random() * 2,
|
||||||
|
depth: 0,
|
||||||
|
energy: Math.random() * 100 + 50
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create edges based on connectedness
|
||||||
|
const targetEdges = Math.floor(params.topology.nodes * params.connectedness * 1.5);
|
||||||
|
for (let i = 0; i < targetEdges; i++) {
|
||||||
|
const a = Math.floor(Math.random() * nodes.length);
|
||||||
|
const b = Math.floor(Math.random() * nodes.length);
|
||||||
|
if (a !== b) {
|
||||||
|
edges.push({
|
||||||
|
from: a,
|
||||||
|
to: b,
|
||||||
|
strength: 0.5 + Math.random() * 0.5,
|
||||||
|
age: 0,
|
||||||
|
maxAge: 100 + Math.random() * 200
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pulse effect
|
||||||
|
let pulsePhase = 0;
|
||||||
|
let pulseDirection = 1;
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
// Clear with slightly transparent background for trails
|
||||||
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Update pulse phase
|
||||||
|
pulsePhase += pulseDirection * 0.01;
|
||||||
|
if (pulsePhase > 1.6 || pulsePhase < 0.3) pulseDirection *= -1;
|
||||||
|
|
||||||
|
// Update nodes with motion based on pulse
|
||||||
|
nodes.forEach(node => {
|
||||||
|
node.x += node.vx * params.motion * pulsePhase;
|
||||||
|
node.y += node.vy * params.motion * pulsePhase;
|
||||||
|
|
||||||
|
// Boundary collision
|
||||||
|
if (node.x < 0 || node.x > canvas.width) node.vx *= -0.8;
|
||||||
|
if (node.y < 0 || node.y > canvas.height) node.vy *= -0.8;
|
||||||
|
|
||||||
|
// Energy dissipation
|
||||||
|
node.energy -= 0.1;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update edges with age
|
||||||
|
edges.forEach(edge => {
|
||||||
|
edge.age++;
|
||||||
|
if (edge.age > edge.maxAge) {
|
||||||
|
// Replace old edges
|
||||||
|
const a = Math.floor(Math.random() * nodes.length);
|
||||||
|
const b = Math.floor(Math.random() * nodes.length);
|
||||||
|
if (a !== b) {
|
||||||
|
edge.from = a;
|
||||||
|
edge.to = b;
|
||||||
|
edge.age = 0;
|
||||||
|
edge.maxAge = 100 + Math.random() * 200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Draw edges
|
||||||
|
ctx.lineWidth = 0.5 * params.topology.thicknessRatio;
|
||||||
|
edges.forEach(edge => {
|
||||||
|
const from = nodes[edge.from];
|
||||||
|
const to = nodes[edge.to];
|
||||||
|
|
||||||
|
// Pulse effect on edge strength
|
||||||
|
const pulseStrength = 1 + (pulsePhase - params.pulse.min) / (params.pulse.max - params.pulse.min) * 0.5;
|
||||||
|
const alpha = 0.3 + edge.age / edge.maxAge * 0.7;
|
||||||
|
|
||||||
|
ctx.strokeStyle = `rgba(${parseInt(palette.edge.substring(1,3),16)}, ${parseInt(palette.edge.substring(3,5),16)}, ${parseInt(palette.edge.substring(5,7),16)}, ${alpha})`;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(from.x, from.y);
|
||||||
|
ctx.lineTo(to.x, to.y);
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Draw nodes
|
||||||
|
nodes.forEach(node => {
|
||||||
|
if (node.energy <= 0) return;
|
||||||
|
|
||||||
|
// Size based on energy
|
||||||
|
const size = node.size * (0.5 + node.energy / 200);
|
||||||
|
|
||||||
|
// Color based on lifespan (older nodes are dimmer)
|
||||||
|
const energyRatio = node.energy / 100;
|
||||||
|
const r = parseInt(palette.node.substring(1,3),16) * energyRatio;
|
||||||
|
const g = parseInt(palette.node.substring(3,5),16) * energyRatio;
|
||||||
|
const b = parseInt(palette.node.substring(5,7),16) * energyRatio;
|
||||||
|
|
||||||
|
ctx.fillStyle = `rgba(${Math.floor(r)}, ${Math.floor(g)}, ${Math.floor(b)}, ${energyRatio})`;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(node.x, node.y, size, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add occasional new nodes based on lifespan
|
||||||
|
if (Math.random() < params.lifespan * 0.002) {
|
||||||
|
nodes.push({
|
||||||
|
x: Math.random() * canvas.width,
|
||||||
|
y: Math.random() * canvas.height,
|
||||||
|
vx: (Math.random() - 0.5) * 2,
|
||||||
|
vy: (Math.random() - 0.5) * 2,
|
||||||
|
size: 1 + Math.random() * 2,
|
||||||
|
depth: 0,
|
||||||
|
energy: 150 + Math.random() * 50
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
initNetwork();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue