birth: Pulsing Network Web
This commit is contained in:
parent
6d911e1115
commit
21123a8029
1 changed files with 177 additions and 0 deletions
177
index.html
Normal file
177
index.html
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Graph Study</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
left: 20px;
|
||||
color: #555;
|
||||
font-size: 12px;
|
||||
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');
|
||||
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Parameters from description
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulseAvg: 1.1,
|
||||
pulseMin: 1.0,
|
||||
pulseMax: 1.2,
|
||||
dryness: 0.9,
|
||||
curiosity: 0.1
|
||||
};
|
||||
|
||||
// Generate graph structure
|
||||
function generateGraph() {
|
||||
const nodes = [];
|
||||
const edges = [];
|
||||
const nodeCount = Math.floor(100 + 200 * params.density);
|
||||
const complexityFactor = params.complexity * 0.8 + 0.2;
|
||||
|
||||
// Create nodes with varying influence
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
const angle = (i / nodeCount) * Math.PI * 2;
|
||||
const distance = 0.3 + 0.7 * params.connectedness;
|
||||
const x = canvas.width/2 + Math.cos(angle) * distance * canvas.width/3;
|
||||
const y = canvas.height/2 + Math.sin(angle) * distance * canvas.height/3;
|
||||
|
||||
nodes.push({
|
||||
x, y,
|
||||
size: 2 + 4 * Math.random() * params.complexity,
|
||||
speed: 0.1 + 0.5 * params.motion * (0.5 + Math.random()),
|
||||
angle: angle + (Math.random() - 0.5) * 0.1,
|
||||
targetSize: 2 + 4 * Math.random() * params.complexity,
|
||||
connected: []
|
||||
});
|
||||
}
|
||||
|
||||
// Create edges based on connectedness
|
||||
const edgeCount = Math.floor(nodeCount * params.connectedness * 2);
|
||||
for (let i = 0; i < edgeCount; i++) {
|
||||
const from = Math.floor(Math.random() * nodeCount);
|
||||
const to = Math.floor(Math.random() * nodeCount);
|
||||
if (from !== to) {
|
||||
edges.push({
|
||||
from, to,
|
||||
strength: 0.3 + 0.7 * params.connectedness * (0.5 + Math.random()/2),
|
||||
distance: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Create some hub nodes
|
||||
const hubCount = Math.floor(5 + 10 * params.complexity * params.connectedness);
|
||||
for (let i = 0; i < hubCount; i++) {
|
||||
const angle = (i / hubCount) * Math.PI * 2;
|
||||
const x = canvas.width/2 + Math.cos(angle) * 0.6 * canvas.width/3;
|
||||
const y = canvas.height/2 + Math.sin(angle) * 0.6 * canvas.height/3;
|
||||
nodes.push({
|
||||
x, y,
|
||||
size: 6 + 8 * params.complexity,
|
||||
speed: 0.05 + 0.2 * params.motion,
|
||||
angle: angle + (Math.random() - 0.5) * 0.1,
|
||||
targetSize: 6 + 8 * params.complexity,
|
||||
isHub: true,
|
||||
connected: []
|
||||
});
|
||||
}
|
||||
|
||||
return { nodes, edges };
|
||||
}
|
||||
|
||||
let graph = generateGraph();
|
||||
let time = 0;
|
||||
const pulse = params.pulseAvg + (Math.random() * 0.2 - 0.1);
|
||||
|
||||
function animate() {
|
||||
// Clear with semi-transparent background for trails
|
||||
ctx.fillStyle = `rgba(10, 10, 10, ${0.05 + 0.1 * params.lifespan})`;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw nodes
|
||||
graph.nodes.forEach(node => {
|
||||
// Update node position
|
||||
node.x += Math.cos(node.angle) * node.speed * pulse;
|
||||
node.y += Math.sin(node.angle) * node.speed * pulse;
|
||||
|
||||
// Bounce off edges
|
||||
if (node.x < 0 || node.x > canvas.width) node.angle = Math.PI - node.angle;
|
||||
if (node.y < 0 || node.y > canvas.height) node.angle = -node.angle;
|
||||
|
||||
// Update size smoothly
|
||||
node.size += (node.targetSize - node.size) * 0.05;
|
||||
|
||||
// Draw node
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, node.size, 0, Math.PI * 2);
|
||||
ctx.fillStyle = `hsl(0, 0%, ${80 + 20 * Math.random() * params.dryness}%)`;
|
||||
ctx.fill();
|
||||
});
|
||||
|
||||
// Draw edges with dynamic width
|
||||
graph.edges.forEach(edge => {
|
||||
const node1 = graph.nodes[edge.from];
|
||||
const node2 = graph.nodes[edge.to];
|
||||
|
||||
// Calculate distance and apply strength
|
||||
edge.distance = Math.sqrt(
|
||||
Math.pow(node2.x - node1.x, 2) +
|
||||
Math.pow(node2.y - node1.y, 2)
|
||||
) * 0.01;
|
||||
|
||||
// Draw edge if not too far
|
||||
if (edge.distance < 0.3 + 0.7 * params.connectedness) {
|
||||
const width = edge.strength * (0.5 + 0.5 * params.complexity) * 2;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(node1.x, node1.y);
|
||||
ctx.lineTo(node2.x, node2.y);
|
||||
ctx.strokeStyle = `rgba(150, 150, 150, ${0.2 + 0.8 * edge.strength})`;
|
||||
ctx.lineWidth = width;
|
||||
ctx.stroke();
|
||||
}
|
||||
});
|
||||
|
||||
// Occasionally regenerate graph
|
||||
if (Math.random() < 0.002 * params.motion * (1 - params.lifespan)) {
|
||||
graph = generateGraph();
|
||||
}
|
||||
|
||||
time += 0.01;
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue