graph-woven-in-static-57o3/index.html

174 lines
No EOL
5.5 KiB
HTML

<!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-color: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
color: #555;
font-size: 10px;
font-family: monospace;
}
</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
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: 1.08,
tone: { dryness: 0.8, curiosity: 0.1 },
maxNodes: 150,
maxConnections: 300,
nodeSize: 2.5,
connectionWidth: 1.2,
colorScheme: '#d0d0d0'
};
// Node structure
class Node {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = (Math.random() - 0.5) * params.motion * 2;
this.vy = (Math.random() - 0.5) * params.motion * 2;
this.size = params.nodeSize * (0.8 + Math.random() * 0.4);
this.connections = [];
this.age = 0;
this.maxAge = 50 + Math.random() * 100;
}
update() {
this.x += this.vx;
this.y += this.vy;
// Boundary check
const margin = 50;
if (this.x < -margin) this.x = canvas.width + margin;
if (this.x > canvas.width + margin) this.x = -margin;
if (this.y < -margin) this.y = canvas.height + margin;
if (this.y > canvas.height + margin) this.y = -margin;
this.age++;
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = params.colorScheme;
ctx.fill();
}
}
// Network structure
class Network {
constructor() {
this.nodes = [];
this.time = 0;
this.initNodes();
}
initNodes() {
const count = Math.floor(params.maxNodes * params.density * 0.8) + 5;
for (let i = 0; i < count; i++) {
this.nodes.push(new Node());
}
this.connectNodes();
}
connectNodes() {
const connections = Math.floor(params.maxConnections * params.connectedness * 0.8) + 10;
for (let i = 0; i < connections; i++) {
const from = Math.floor(Math.random() * this.nodes.length);
const to = Math.floor(Math.random() * this.nodes.length);
if (from !== to && !this.nodes[from].connections.includes(to)) {
this.nodes[from].connections.push(to);
}
}
}
update() {
// Age nodes
for (let i = this.nodes.length - 1; i >= 0; i--) {
this.nodes[i].update();
if (this.nodes[i].age > this.nodes[i].maxAge) {
this.nodes.splice(i, 1);
}
}
// Add new nodes if space allows
if (this.nodes.length < params.maxNodes * params.density * 1.2 && Math.random() < 0.05) {
this.nodes.push(new Node());
}
this.time++;
}
draw() {
// Draw connections first (so they appear beneath nodes)
ctx.strokeStyle = params.colorScheme + '20';
ctx.lineWidth = params.connectionWidth;
for (const node of this.nodes) {
for (const targetIdx of node.connections) {
if (targetIdx < this.nodes.length) {
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(this.nodes[targetIdx].x, this.nodes[targetIdx].y);
ctx.stroke();
}
}
}
// Draw nodes
for (const node of this.nodes) {
node.draw();
}
}
}
const network = new Network();
function animate() {
// Clear with slight blur for motion trails
ctx.fillStyle = '#080808';
ctx.fillRect(0, 0, canvas.width, canvas.height);
network.update();
network.draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>