182 lines
No EOL
6.3 KiB
HTML
182 lines
No EOL
6.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Recursive Networks</title>
|
|
<style>
|
|
body { margin: 0; overflow: hidden; background: #0a0a1a; }
|
|
canvas { display: block; }
|
|
#attribution {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
color: #555;
|
|
font-family: monospace;
|
|
font-size: 12px;
|
|
text-shadow: 0 0 5px rgba(0,0,0,0.5);
|
|
}
|
|
</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');
|
|
|
|
// Set canvas to full window size
|
|
function resizeCanvas() {
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
}
|
|
window.addEventListener('resize', resizeCanvas);
|
|
resizeCanvas();
|
|
|
|
// Parameters from prompt
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.03, min: 0.8, max: 1.2 },
|
|
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.9, playfulness: 0, tension: 0 }
|
|
};
|
|
|
|
// Derived values
|
|
const nodeCount = Math.floor(200 + params.density * 400);
|
|
const branchProb = 0.3 + params.connectedness * 0.4;
|
|
const maxDepth = 3 + Math.floor(params.complexity * 5);
|
|
const baseSize = 1 + params.complexity * 3;
|
|
const decayRate = 0.95 - params.lifespan * 0.2;
|
|
|
|
// Network nodes
|
|
const nodes = [];
|
|
for (let i = 0; i < nodeCount; i++) {
|
|
nodes.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
size: baseSize * (0.5 + Math.random() * 0.5),
|
|
connections: [],
|
|
depth: 0,
|
|
energy: Math.random()
|
|
});
|
|
}
|
|
|
|
// Build network connections
|
|
for (let node of nodes) {
|
|
// Connect to nearby nodes based on connectedness
|
|
const nearby = nodes.filter(n =>
|
|
n !== node &&
|
|
Math.abs(n.x - node.x) < 100 * params.connectedness &&
|
|
Math.abs(n.y - node.y) < 100 * params.connectedness &&
|
|
Math.random() < branchProb
|
|
);
|
|
|
|
for (let target of nearby) {
|
|
const angle = Math.atan2(target.y - node.y, target.x - node.x);
|
|
node.connections.push({
|
|
target,
|
|
angle,
|
|
distance: Math.hypot(target.x - node.x, target.y - node.y),
|
|
strength: 0.5 + Math.random() * 0.5,
|
|
depth: 1
|
|
});
|
|
}
|
|
}
|
|
|
|
// Recursive branch deepening
|
|
function deepenConnections(nodes, currentDepth = 0) {
|
|
if (currentDepth >= maxDepth) return;
|
|
|
|
for (let node of nodes) {
|
|
for (let conn of node.connections) {
|
|
if (conn.depth <= currentDepth) continue;
|
|
|
|
const target = conn.target;
|
|
if (!target.connections.some(c => c.target === node)) {
|
|
target.connections.push({
|
|
target: node,
|
|
angle: Math.atan2(node.y - target.y, node.x - target.x),
|
|
distance: conn.distance,
|
|
strength: conn.strength * 0.8,
|
|
depth: conn.depth - 1
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
deepenConnections(nodes, currentDepth + 1);
|
|
}
|
|
deepenConnections(nodes);
|
|
|
|
// Animation state
|
|
let time = 0;
|
|
const nodeStates = new Map();
|
|
|
|
function animate() {
|
|
// Clear with fade
|
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Pulse effect
|
|
const pulse = params.pulse.avg + Math.sin(time * 0.002) * params.pulse.max * 0.1;
|
|
|
|
// Draw connections with dryness tone
|
|
ctx.strokeStyle = `rgba(255, 255, 255, ${0.2 * params.tone.dryness})`;
|
|
ctx.lineWidth = 0.5 * params.tone.dryness;
|
|
|
|
// Update node states
|
|
for (let node of nodes) {
|
|
// Store previous energy
|
|
nodeStates.set(node, (nodeStates.get(node) || 1) * decayRate);
|
|
|
|
// Random energy fluctuations
|
|
if (Math.random() < 0.02) {
|
|
node.energy = 0.8 + Math.random() * 0.4;
|
|
} else {
|
|
node.energy *= 0.99;
|
|
}
|
|
|
|
// Pulse multiplier
|
|
const energy = node.energy * pulse;
|
|
nodeStates.set(node, nodeStates.get(node) + energy * 0.01);
|
|
}
|
|
|
|
// Draw connections with energy-based opacity
|
|
for (let node of nodes) {
|
|
const state = nodeStates.get(node) || 0;
|
|
for (let conn of node.connections) {
|
|
const targetState = nodeStates.get(conn.target) || 0;
|
|
const avgState = (state + targetState) / 2;
|
|
const opacity = avgState * conn.strength * 0.7;
|
|
if (opacity > 0.01) {
|
|
ctx.globalAlpha = opacity;
|
|
ctx.beginPath();
|
|
ctx.moveTo(node.x, node.y);
|
|
ctx.lineTo(conn.target.x, conn.target.y);
|
|
ctx.stroke();
|
|
}
|
|
}
|
|
}
|
|
ctx.globalAlpha = 1;
|
|
|
|
// Draw nodes
|
|
for (let node of nodes) {
|
|
const state = nodeStates.get(node) || 0;
|
|
const size = node.size * state;
|
|
ctx.fillStyle = `rgba(255, 255, 255, ${state * params.tone.dryness})`;
|
|
ctx.beginPath();
|
|
ctx.arc(node.x, node.y, size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
}
|
|
|
|
time++;
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |