birth: Threaded Luminescence

This commit is contained in:
motd_admin 2026-10-09 14:21:24 +00:00
parent de42718956
commit 31bd0cfb57

206
index.html Normal file
View file

@ -0,0 +1,206 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Network Bloom</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
left: 10px;
color: rgba(255, 255, 255, 0.3);
font-size: 10px;
pointer-events: none;
}
</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();
// Network parameters
const params = {
nodes: 50 + Math.floor(200 * 0.5),
connections: 0.5 * 500,
motion: 0.5,
complexity: 0.5,
density: 0.5,
lifespan: 0.5,
pulse: 1.03
};
// Node class
class Node {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = (Math.random() - 0.5) * 2 * params.motion;
this.vy = (Math.random() - 0.5) * 2 * params.motion;
this.radius = 1 + Math.random() * 3;
this.maxRadius = 5;
this.life = Math.random();
this.targetConnections = Math.floor(3 * params.complexity);
this.connections = [];
this.color = `rgba(200, 200, 200, ${0.5 + 0.5 * params.density})`;
this.pulseScale = 0.8 + 0.4 * Math.random();
}
update() {
// Movement with slight wobble
this.x += this.vx * (0.8 + 0.4 * Math.random());
this.y += this.vy * (0.8 + 0.4 * Math.random());
// Boundary check
if (this.x < 0) {
this.x = canvas.width;
} else if (this.x > canvas.width) {
this.x = 0;
}
if (this.y < 0) {
this.y = canvas.height;
} else if (this.y > canvas.height) {
this.y = 0;
}
// Connections
this.connections = this.connections.filter(conn =>
conn.target.life > 0.1 &&
distance(this, conn.target) < 200 * params.density
);
// Radius based on complexity
this.radius = this.maxRadius * (0.5 + 0.5 * params.complexity) * (0.7 + 0.3 * this.life);
// Lifespan
this.life -= 0.0005 * (1 - params.lifespan);
if (this.life < 0) {
this.life = 0;
}
}
draw() {
const pulse = 0.9 + 0.2 * Math.sin(Date.now() * 0.002) * params.pulse;
const glow = this.life > 0.5 ? 20 * pulse * this.pulseScale : 10 * pulse * this.pulseScale;
const alpha = this.life * (0.5 + 0.5 * params.density);
// Glow effect
ctx.save();
ctx.globalAlpha = 0.1 * alpha;
ctx.filter = `blur(${glow}px)`;
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius * 1.5, 0, Math.PI * 2);
ctx.fillStyle = this.color;
ctx.fill();
ctx.restore();
// Node
ctx.globalAlpha = alpha;
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
ctx.fillStyle = this.color;
ctx.fill();
}
}
function distance(a, b) {
return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
}
let nodes = [];
for (let i = 0; i < params.nodes; i++) {
nodes.push(new Node());
}
// Create connections
function createConnections() {
nodes.forEach(node => {
if (node.connections.length >= node.targetConnections) return;
// Find nearest compatible nodes
const candidates = nodes
.filter(n =>
n !== node &&
n.connections.length < n.targetConnections &&
distance(node, n) < 200 * params.density * (0.5 + 0.5 * params.connectedness)
)
.sort((a, b) => distance(node, a) - distance(node, b));
const targetCount = Math.min(
Math.floor(params.complexity * 5),
candidates.length
);
for (let i = 0; i < targetCount && node.connections.length < node.targetConnections; i++) {
const target = candidates[i];
if (!node.connections.some(conn => conn.target === target)) {
node.connections.push({ target, strength: 0.3 + 0.7 * Math.random() });
target.connections.push({ target: node, strength: 0.3 + 0.7 * Math.random() });
}
}
});
}
createConnections();
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw connections first
nodes.forEach(node => {
node.connections.forEach(conn => {
const alpha = conn.strength * 0.3 * (0.5 + 0.5 * params.complexity);
if (alpha > 0) {
ctx.globalAlpha = alpha;
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(conn.target.x, conn.target.y);
ctx.strokeStyle = `rgba(200, 200, 200, ${alpha})`;
ctx.lineWidth = 1 * (0.5 + 0.5 * params.connectedness);
ctx.stroke();
}
});
});
// Update and draw nodes
nodes.forEach((node, i) => {
node.update();
node.draw();
// Occasionally remove dead nodes
if (node.life <= 0 && Math.random() < 0.01) {
nodes.splice(i, 1);
}
});
// Add new nodes to maintain density
while (nodes.length < params.nodes * (0.8 + 0.4 * params.density)) {
nodes.push(new Node());
}
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>