flickering-web-of-echoes-0h8x/index.html

144 lines
No EOL
4.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Network Constellation</title>
<style>
body { margin: 0; overflow: hidden; background: #0a0a0a; }
canvas { display: block; }
#attr { position: absolute; bottom: 10px; right: 10px; color: #333; font-family: monospace; font-size: 10px; }
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="attr">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();
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.05, min: 1.00, max: 1.10 },
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 }
};
class Node {
constructor(x, y) {
this.x = x;
this.y = y;
this.size = 1;
this.vx = (Math.random() - 0.5) * params.motion * 2;
this.vy = (Math.random() - 0.5) * params.motion * 2;
this.lifetime = 0;
this.maxLifetime = 100 + Math.random() * 200;
this.connections = [];
this.color = `hsl(0, 0%, ${50 + Math.random() * 20}%)`;
}
update() {
this.x += this.vx;
this.y += this.vy;
this.lifetime++;
if (this.lifetime > this.maxLifetime) {
this.size *= 0.95;
}
if (this.size < 0.1) return false;
return true;
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size * params.pulse.avg, 0, Math.PI * 2);
ctx.fillStyle = this.color;
ctx.fill();
}
}
class Network {
constructor() {
this.nodes = [];
this.createNodes();
this.createConnections();
}
createNodes() {
const count = 50 + Math.floor(params.density * 200);
for (let i = 0; i < count; i++) {
this.nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
}
createConnections() {
const connectionCount = 100 + Math.floor(params.connectedness * 200);
for (let i = 0; i < connectionCount; i++) {
const a = this.nodes[Math.floor(Math.random() * this.nodes.length)];
const b = this.nodes[Math.floor(Math.random() * this.nodes.length)];
if (a !== b && !a.connections.includes(b)) {
a.connections.push(b);
}
}
}
update() {
this.nodes = this.nodes.filter(node => node.update());
this.nodes.forEach(node => {
node.connections = node.connections.filter(conn =>
this.nodes.includes(conn) && Math.random() > 0.1
);
});
}
draw() {
// Draw connections
ctx.strokeStyle = `rgba(255, 255, 255, ${0.3 * params.pulse.avg})`;
ctx.lineWidth = 0.5;
this.nodes.forEach(node => {
node.connections.forEach(conn => {
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(conn.x, conn.y);
ctx.stroke();
});
});
// Draw nodes
this.nodes.forEach(node => node.draw());
}
}
let network = new Network();
function animate() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
network.update();
if (network.nodes.length < 10) {
network = new Network();
}
network.draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>