birth: Flickering Neural Webs
This commit is contained in:
parent
a060e941f4
commit
0e25305416
1 changed files with 199 additions and 0 deletions
199
index.html
Normal file
199
index.html
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
<!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;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
.attribution {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
color: #555;
|
||||
font-family: monospace;
|
||||
font-size: 12px;
|
||||
z-index: 100;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div class="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 mapped from abstract input
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.08, min: 1.05, max: 1.1 }
|
||||
};
|
||||
|
||||
// Network graph simulation
|
||||
const nodes = [];
|
||||
const edges = [];
|
||||
const maxNodes = Math.floor(params.density * 200 + 100);
|
||||
const maxEdges = Math.floor(params.connectedness * 1000);
|
||||
|
||||
// Initialize random nodes with pulsating properties
|
||||
for (let i = 0; i < maxNodes; i++) {
|
||||
nodes.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: Math.random() * canvas.height,
|
||||
radius: 2 + Math.random() * 5 * params.complexity,
|
||||
energy: 0.5 + Math.random() * 0.5,
|
||||
pulse: params.pulse.avg + (Math.random() * 2 - 1) * (params.pulse.max - params.pulse.min),
|
||||
lifespan: params.lifespan * 200 + 50
|
||||
});
|
||||
}
|
||||
|
||||
// Create connections based on proximity and connectedness
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
for (let j = i + 1; j < Math.min(i + 10, nodes.length); j++) {
|
||||
const dist = Math.sqrt((nodes[i].x - nodes[j].x) ** 2 + (nodes[i].y - nodes[j].y) ** 2);
|
||||
if (dist < 150 * (1 - params.connectedness)) {
|
||||
edges.push({
|
||||
from: i,
|
||||
to: j,
|
||||
strength: 0.3 + Math.random() * 0.7 * params.connectedness,
|
||||
phase: Math.random() * Math.PI * 2
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simulation variables
|
||||
let time = 0;
|
||||
const targetFPS = 60;
|
||||
let lastTime = performance.now();
|
||||
|
||||
function animate(currentTime) {
|
||||
// Throttle to target FPS
|
||||
if (currentTime - lastTime < 1000 / targetFPS) {
|
||||
requestAnimationFrame(animate);
|
||||
return;
|
||||
}
|
||||
lastTime = currentTime;
|
||||
|
||||
// Clear with semi-transparent to create trails
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Update nodes
|
||||
nodes.forEach((node, i) => {
|
||||
// Apply pulsation
|
||||
node.radius = 2 + 3 * node.energy * (1 + 0.1 * Math.sin(time * node.pulse));
|
||||
|
||||
// Apply small random movement based on motion parameter
|
||||
const moveAmount = params.motion * 0.5;
|
||||
node.x += (Math.random() - 0.5) * moveAmount;
|
||||
node.y += (Math.random() - 0.5) * moveAmount;
|
||||
|
||||
// Keep within bounds
|
||||
node.x = Math.max(0, Math.min(canvas.width, node.x));
|
||||
node.y = Math.max(0, Math.min(canvas.height, node.y));
|
||||
|
||||
// Draw node
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, node.radius, 0, Math.PI * 2);
|
||||
ctx.fillStyle = `hsl(0, 0%, ${50 + node.energy * 20}%)`;
|
||||
ctx.fill();
|
||||
|
||||
// Update energy based on connectedness
|
||||
const connectedEdges = edges.filter(e => e.from === i || e.to === i);
|
||||
node.energy = 0.3 + 0.7 * (connectedEdges.length / 10) * params.connectedness;
|
||||
});
|
||||
|
||||
// Update and draw edges
|
||||
edges.forEach(edge => {
|
||||
const nodeA = nodes[edge.from];
|
||||
const nodeB = nodes[edge.to];
|
||||
|
||||
if (!nodeA || !nodeB) return;
|
||||
|
||||
// Calculate distance and angle
|
||||
const dx = nodeB.x - nodeA.x;
|
||||
const dy = nodeB.y - nodeA.y;
|
||||
const dist = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
// Only draw if within reasonable distance
|
||||
if (dist < 300) {
|
||||
// Create wavy effect
|
||||
const steps = Math.floor(dist * 0.1);
|
||||
const segmentLength = dist / steps;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(nodeA.x, nodeA.y);
|
||||
|
||||
for (let i = 1; i <= steps; i++) {
|
||||
const progress = i / steps;
|
||||
const nx = nodeA.x + dx * progress;
|
||||
const ny = nodeA.y + dy * progress;
|
||||
|
||||
// Add sine wave distortion
|
||||
const offsetX = Math.sin(time * 0.5 + progress * Math.PI * 10) * 10 * edge.strength;
|
||||
const offsetY = Math.cos(time * 0.5 + progress * Math.PI * 10) * 10 * edge.strength;
|
||||
|
||||
ctx.lineTo(nx + offsetX, ny + offsetY);
|
||||
}
|
||||
|
||||
// Set edge color and width based on strength
|
||||
const gray = 60 + edge.strength * 30;
|
||||
ctx.strokeStyle = `hsl(0, 0%, ${gray}%)`;
|
||||
ctx.lineWidth = 0.5 + edge.strength * 2;
|
||||
ctx.stroke();
|
||||
}
|
||||
});
|
||||
|
||||
// Add new random nodes periodically
|
||||
if (Math.random() < 0.02 * params.density && nodes.length < maxNodes) {
|
||||
nodes.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: Math.random() * canvas.height,
|
||||
radius: 2 + Math.random() * 5 * params.complexity,
|
||||
energy: 0.5 + Math.random() * 0.5,
|
||||
pulse: params.pulse.avg + (Math.random() * 2 - 1) * (params.pulse.max - params.pulse.min),
|
||||
lifespan: params.lifespan * 200 + 50
|
||||
});
|
||||
}
|
||||
|
||||
// Randomly remove nodes based on lifespan
|
||||
if (Math.random() < 0.01 * (1 - params.lifespan) && nodes.length > maxNodes * 0.5) {
|
||||
nodes.splice(Math.floor(Math.random() * nodes.length), 1);
|
||||
}
|
||||
|
||||
time += 0.01;
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Start animation
|
||||
animate(performance.now());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue