birth: Fractured Light Networks

This commit is contained in:
motd_admin 2026-07-21 09:47:18 +00:00
parent 5b0beccfa7
commit 1df22e8478

133
index.html Normal file
View file

@ -0,0 +1,133 @@
```html
<!DOCTYPE html>
<html>
<head>
<title>Voronoi Organism</title>
<style>
body { margin: 0; overflow: hidden; background: #000; }
canvas { display: block; }
#attr { position: absolute; bottom: 10px; right: 10px; color: #444; font-family: monospace; font-size: 12px; }
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="attr">neurameba · motd.social</div>
<script>
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.05, min: 1.0, max: 1.1 },
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.9, playfulness: 0, tension: 0 }
};
const points = [];
const edges = [];
const maxPoints = 200;
const maxEdges = 1000;
function init() {
for (let i = 0; i < maxPoints * params.density; i++) {
points.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
vx: (Math.random() - 0.5) * params.motion,
vy: (Math.random() - 0.5) * params.motion,
size: 1 + Math.random() * 2,
life: 0
});
}
}
function update() {
// Pulse effect
const pulse = params.pulse.avg + (Math.random() * 2 - 1) * params.pulse.range;
params.motion = (pulse + params.pulse.min) / 2;
// Update points
points.forEach(p => {
p.x += p.vx;
p.y += p.vy;
// Boundary collision
if (p.x < 0 || p.x > canvas.width) p.vx *= -1;
if (p.y < 0 || p.y > canvas.height) p.vy *= -1;
p.life += 0.01 * (pulse * 0.5 + 0.5);
});
// Generate voronoi edges
edges.length = 0;
for (let i = 0; i < points.length; i++) {
for (let j = i + 1; j < points.length && edges.length < maxEdges; j++) {
const p1 = points[i];
const p2 = points[j];
const dx = p2.x - p1.x;
const dy = p2.y - p1.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 100 * params.complexity) {
edges.push({
p1: i,
p2: j,
dist: dist,
age: 0
});
}
}
}
}
function draw() {
// Fade background
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw edges
ctx.strokeStyle = `rgba(255, 255, 255, ${0.2 + params.tone.curiosity * 0.3})`;
ctx.lineWidth = 0.5 + params.complexity * 1.5;
edges.forEach(e => {
const p1 = points[e.p1];
const p2 = points[e.p2];
ctx.beginPath();
ctx.moveTo(p1.x, p1.y);
ctx.lineTo(p2.x, p2.y);
ctx.stroke();
e.age += 0.01;
});
// Draw points
points.forEach(p => {
const alpha = Math.min(1, p.life * 0.5) * (0.5 + params.tone.dryness * 0.5);
ctx.fillStyle = `rgba(255, 255, 255, ${alpha})`;
ctx.beginPath();
ctx.arc(p.x, p.y, p.size * (0.5 + params.tone.dryness * 0.5), 0, Math.PI * 2);
ctx.fill();
});
}
function animate() {
update();
draw();
requestAnimationFrame(animate);
}
init();
animate();
</script>
</body>
</html>
```