frayed-circuits-breathe-z5xq/index.html

216 lines
No EOL
7.1 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: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: fixed;
bottom: 10px;
right: 10px;
color: #555;
font-size: 10px;
pointer-events: none;
text-shadow: 0 0 5px rgba(0,0,0,0.7);
}
</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();
// Network Graph Parameters
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: 1.08,
tone: { dryness: 0.9, curiosity: 0.1 },
maxNodes: 30,
maxConnections: 5,
nodeSize: 1.5,
edgeWidth: 1,
decayRate: 0.98,
pulseVariation: 0.05
};
// Node structure
class Node {
constructor(x, y) {
this.x = x;
this.y = y;
this.vx = (Math.random() - 0.5) * params.motion;
this.vy = (Math.random() - 0.5) * params.motion;
this.size = params.nodeSize * (0.8 + Math.random() * 0.4);
this.connections = [];
this.energy = 1;
this.lifespan = params.lifespan;
this.age = 0;
this.pulse = params.pulse * (0.95 + Math.random() * params.pulseVariation);
}
update(nodes) {
this.age++;
this.energy *= params.decayRate;
this.size = params.nodeSize * this.energy * (0.8 + Math.random() * 0.4);
// Movement with boundary checks
this.x += this.vx;
this.y += this.vy;
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
// Connection aging
this.connections.forEach(conn => {
conn.strength *= params.decayRate;
});
// Natural decay
if (this.energy < 0.1) {
return false; // Mark for removal
}
return true;
}
connect(other) {
if (this === other) return;
if (this.connections.length >= params.maxConnections) return;
const existing = this.connections.find(c => c.target === other);
if (existing) {
existing.strength = 1;
} else {
this.connections.push({
target: other,
strength: 1
});
}
}
}
// Network simulation
let nodes = [];
const targetNodeCount = Math.floor(params.density * params.maxNodes);
function initNetwork() {
nodes = [];
// Create initial nodes
for (let i = 0; i < targetNodeCount; i++) {
nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
// Create connections based on proximity
for (let i = 0; i < nodes.length; i++) {
for (let j = i + 1; j < nodes.length; j++) {
const dx = nodes[i].x - nodes[j].x;
const dy = nodes[i].y - nodes[j].y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 300 * params.connectedness) {
nodes[i].connect(nodes[j]);
}
}
}
}
initNetwork();
// Animation loop
function animate() {
// Clear with dark background
ctx.fillStyle = 'rgba(10, 10, 10, 0.9)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update nodes
for (let i = nodes.length - 1; i >= 0; i--) {
if (!nodes[i].update(nodes)) {
nodes.splice(i, 1);
}
}
// Add new nodes occasionally
if (nodes.length < targetNodeCount * 0.5 || Math.random() < 0.01) {
nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
// Reconnect nodes occasionally
if (Math.random() < 0.02 * params.connectedness) {
const a = Math.floor(Math.random() * nodes.length);
const b = Math.floor(Math.random() * nodes.length);
nodes[a].connect(nodes[b]);
}
// Draw connections
ctx.strokeStyle = `rgba(255, 255, 255, ${0.1 * params.tone.dryness})`;
ctx.lineWidth = params.edgeWidth * params.tone.dryness;
for (const node of nodes) {
for (const conn of node.connections) {
if (conn.strength > 0.1) {
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(conn.target.x, conn.target.y);
ctx.stroke();
// Pulse effect on connections
const pulse = 1 + 0.2 * Math.sin(Date.now() * 0.002 * node.pulse);
ctx.strokeStyle = `rgba(255, 255, 255, ${0.15 * params.tone.dryness * conn.strength * pulse})`;
ctx.lineWidth = params.edgeWidth * 0.5 * params.tone.dryness * conn.strength * pulse;
ctx.stroke();
}
}
}
// Draw nodes
for (const node of nodes) {
ctx.fillStyle = `rgba(255, 255, 255, ${node.energy * params.tone.dryness})`;
ctx.beginPath();
ctx.arc(node.x, node.y, node.size, 0, Math.PI * 2);
ctx.fill();
// Small pulse effect
const pulse = 1 + 0.1 * Math.sin(Date.now() * 0.003 * node.pulse);
ctx.beginPath();
ctx.arc(node.x, node.y, node.size * 0.7 * pulse, 0, Math.PI * 2);
ctx.fillStyle = `rgba(150, 255, 255, ${0.3 * node.energy * params.tone.dryness})`;
ctx.fill();
}
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>