fractal-currents-in-silence.../index.html

260 lines
No EOL
9.4 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: Molecular Drift</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
left: 10px;
color: #555;
font-size: 10px;
pointer-events: none;
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');
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Parameters derived from input
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.07, min: 1.0, max: 1.1 },
tone: { curiosity: 0.7, dryness: 0.8, playfulness: 0.2 }
};
// Network graph implementation
class NetworkNode {
constructor(x, y) {
this.x = x;
this.y = y;
this.baseX = x;
this.baseY = y;
this.vx = 0;
this.vy = 0;
this.friction = 0.95;
this.connections = [];
this.life = 0.5 + Math.random() * 0.5;
this.maxConnections = 2 + Math.floor(Math.random() * 3);
this.size = params.dryness > 0.7 ? 1 : 1.5 + Math.random() * 0.5;
}
update(pulse) {
// Simple physics for node movement
this.vx += (Math.random() - 0.5) * params.motion * pulse;
this.vy += (Math.random() - 0.5) * params.motion * pulse;
this.vx *= this.friction;
this.vy *= this.friction;
this.x += this.vx;
this.y += this.vy;
// Constrain to canvas
this.x = Math.max(this.size, Math.min(canvas.width - this.size, this.x));
this.y = Math.max(this.size, Math.min(canvas.height - this.size, this.y));
this.life += 0.0001;
}
draw() {
// Draw node
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = `rgba(100, 200, 180, ${this.life * 0.7})`;
ctx.fill();
// Draw connections
this.connections.forEach(conn => {
const lineWidth = 0.3 + conn.strength * 0.7;
ctx.beginPath();
ctx.moveTo(this.x, this.y);
ctx.lineTo(conn.target.x, conn.target.y);
ctx.strokeStyle = `rgba(100, 200, 180, ${conn.strength * 0.3})`;
ctx.lineWidth = lineWidth;
ctx.stroke();
});
}
}
class NetworkConnection {
constructor(source, target, strength) {
this.source = source;
this.target = target;
this.strength = strength;
this.age = 0;
}
update() {
this.age++;
this.strength *= 0.999; // Fading connections
}
}
const nodes = [];
const connections = [];
function initNetwork() {
const count = 50 + Math.floor(params.density * 100);
// Create nodes
for (let i = 0; i < count; i++) {
nodes.push(new NetworkNode(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
// Create initial connections
for (let i = 0; i < nodes.length; i++) {
for (let j = i + 1; j < nodes.length; j++) {
if (Math.random() < params.connectedness * 0.3) {
const dist = distance(nodes[i], nodes[j]);
if (dist < 200) {
connections.push(new NetworkConnection(
nodes[i],
nodes[j],
1 - (dist / 200)
));
if (nodes[i].connections.length < nodes[i].maxConnections) {
nodes[i].connections.push({
target: nodes[j],
strength: 1 - (dist / 200)
});
}
if (nodes[j].connections.length < nodes[j].maxConnections) {
nodes[j].connections.push({
target: nodes[i],
strength: 1 - (dist / 200)
});
}
}
}
}
}
}
function distance(a, b) {
return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
}
function updateNetwork(pulse) {
// Update nodes
nodes.forEach(node => node.update(pulse));
// Update connections
connections.forEach(conn => conn.update());
// Add new connections based on proximity
if (Math.random() < params.connectedness * 0.01) {
const a = nodes[Math.floor(Math.random() * nodes.length)];
const b = nodes[Math.floor(Math.random() * nodes.length)];
if (distance(a, b) < 150 && !connections.some(c => (c.source === a && c.target === b) || (c.source === b && c.target === a))) {
const strength = 1 - (distance(a, b) / 150);
connections.push(new NetworkConnection(a, b, strength));
if (a.connections.length < a.maxConnections) {
a.connections.push({ target: b, strength });
}
if (b.connections.length < b.maxConnections) {
b.connections.push({ target: a, strength });
}
}
}
// Prune weak connections
for (let i = connections.length - 1; i >= 0; i--) {
if (connections[i].strength < 0.1) {
connections.splice(i, 1);
// Remove from nodes' connections
const aConns = connections[i].source.connections;
const bConns = connections[i].target.connections;
connections[i].source.connections = aConns.filter(c => c.target !== connections[i].target);
connections[i].target.connections = bConns.filter(c => c.target !== connections[i].source);
}
}
// Occasionally add new nodes
if (Math.random() < 0.005 && nodes.length < 200) {
const newNode = new NetworkNode(
canvas.width * 0.5 + (Math.random() - 0.5) * 100,
canvas.height * 0.5 + (Math.random() - 0.5) * 100
);
nodes.push(newNode);
// Connect to nearby nodes
nodes.forEach(node => {
if (node !== newNode && distance(node, newNode) < 150) {
const strength = 1 - (distance(node, newNode) / 150);
connections.push(new NetworkConnection(newNode, node, strength));
if (newNode.connections.length < newNode.maxConnections) {
newNode.connections.push({ target: node, strength });
}
if (node.connections.length < node.maxConnections) {
node.connections.push({ target: newNode, strength });
}
}
});
}
}
function drawNetwork() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw connections first (behind nodes)
connections.forEach(conn => {
ctx.beginPath();
ctx.moveTo(conn.source.x, conn.source.y);
ctx.lineTo(conn.target.x, conn.target.y);
ctx.strokeStyle = `rgba(100, 200, 180, ${conn.strength * 0.2 * params.tone.dryness})`;
ctx.lineWidth = 0.3 + conn.strength * 0.7;
ctx.stroke();
});
// Draw nodes (on top)
nodes.forEach(node => node.draw());
}
let time = 0;
function animate() {
const pulse = params.pulse.min + (params.pulse.max - params.pulse.min) * 0.5 * (1 + Math.sin(time * 0.001));
updateNetwork(pulse);
drawNetwork();
time += 16; // ~60fps
requestAnimationFrame(animate);
}
initNetwork();
animate();
</script>
</body>
</html>