172 lines
No EOL
5.6 KiB
HTML
172 lines
No EOL
5.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>Neural Mesh</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
#canvas {
|
|
display: block;
|
|
}
|
|
#attribution {
|
|
position: fixed;
|
|
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 derived from abstract specs
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.06, min: 0.9, max: 1.2 },
|
|
tone: { dryness: 0.8, curiosity: 0.1 }
|
|
};
|
|
|
|
// Network graph setup
|
|
const nodes = [];
|
|
const edges = [];
|
|
const maxNodes = Math.floor(200 + params.density * 300);
|
|
const maxEdges = Math.floor(300 + params.connectedness * 700);
|
|
const nodeSize = 2 + params.density * 3;
|
|
const edgeThickness = 0.5 + params.connectedness * 1.5;
|
|
|
|
// Create nodes
|
|
for (let i = 0; i < maxNodes; i++) {
|
|
nodes.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
size: nodeSize * (0.8 + Math.random() * 0.4),
|
|
vx: (Math.random() - 0.5) * params.motion * 2,
|
|
vy: (Math.random() - 0.5) * params.motion * 2,
|
|
color: `rgba(200, 200, 200, 0.8)`,
|
|
lifetime: params.lifespan * (50 + Math.random() * 50)
|
|
});
|
|
}
|
|
|
|
// Create edges
|
|
for (let i = 0; i < maxEdges; i++) {
|
|
if (nodes.length < 2) break;
|
|
const a = Math.floor(Math.random() * nodes.length);
|
|
const b = Math.floor(Math.random() * nodes.length);
|
|
if (a !== b) {
|
|
edges.push({
|
|
from: a,
|
|
to: b,
|
|
thickness: edgeThickness * (0.7 + Math.random() * 0.6),
|
|
color: `rgba(150, 150, 150, 0.5)`,
|
|
length: 100 + Math.random() * 200
|
|
});
|
|
}
|
|
}
|
|
|
|
// Animation
|
|
let time = 0;
|
|
const decay = 0.99;
|
|
|
|
function animate() {
|
|
// Clear with fade
|
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.08)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Update nodes
|
|
nodes.forEach(node => {
|
|
node.x += node.vx;
|
|
node.y += node.vy;
|
|
|
|
// Boundary check with wrap
|
|
if (node.x < 0) node.x = canvas.width;
|
|
if (node.x > canvas.width) node.x = 0;
|
|
if (node.y < 0) node.y = canvas.height;
|
|
if (node.y > canvas.height) node.y = 0;
|
|
|
|
// Fade over time
|
|
node.color = `rgba(200, 200, 200, ${Math.min(0.8, node.lifetime / 100)})`;
|
|
node.lifetime -= 0.5;
|
|
});
|
|
|
|
// Remove dead nodes
|
|
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
if (nodes[i].lifetime <= 0) {
|
|
nodes.splice(i, 1);
|
|
}
|
|
}
|
|
|
|
// Update edges
|
|
edges.forEach(edge => {
|
|
const fromNode = nodes[edge.from];
|
|
const toNode = nodes[edge.to];
|
|
|
|
if (!fromNode || !toNode) return;
|
|
|
|
// Calculate distance and draw edge
|
|
const dx = toNode.x - fromNode.x;
|
|
const dy = toNode.y - fromNode.y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
const alpha = Math.min(0.8, dist / edge.length);
|
|
|
|
if (alpha > 0.1) {
|
|
ctx.strokeStyle = edge.color.replace('0.5', alpha.toFixed(2));
|
|
ctx.lineWidth = edge.thickness * (0.5 + 0.5 * alpha);
|
|
ctx.beginPath();
|
|
ctx.moveTo(fromNode.x, fromNode.y);
|
|
ctx.lineTo(toNode.x, toNode.y);
|
|
ctx.stroke();
|
|
}
|
|
});
|
|
|
|
// Draw nodes
|
|
nodes.forEach(node => {
|
|
ctx.beginPath();
|
|
ctx.arc(node.x, node.y, node.size, 0, Math.PI * 2);
|
|
ctx.fillStyle = node.color;
|
|
ctx.fill();
|
|
});
|
|
|
|
// Occasionally add new nodes
|
|
if (Math.random() < 0.02 && nodes.length < maxNodes) {
|
|
nodes.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
size: nodeSize * (0.8 + Math.random() * 0.4),
|
|
vx: (Math.random() - 0.5) * params.motion * 2,
|
|
vy: (Math.random() - 0.5) * params.motion * 2,
|
|
color: `rgba(200, 200, 200, 0.8)`,
|
|
lifetime: params.lifespan * (50 + Math.random() * 50)
|
|
});
|
|
}
|
|
|
|
time++;
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |