dry-pulse-network-xocy/index.html

160 lines
No EOL
5.2 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 Pulse</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#info {
position: absolute;
bottom: 20px;
right: 20px;
color: #555;
font-size: 10px;
text-align: right;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="info">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 input
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: {
avg: 1.08,
min: 1.05,
max: 1.10
},
tone: {
anger: 0.00,
sadness: 0.00,
curiosity: 0.10,
dryness: 0.80,
playfulness: 0.00,
tension: 0.00
}
};
// Network generation parameters
const nodeCount = Math.floor(200 + params.density * 300);
const edgeDensity = params.connectedness * 0.8 + 0.2;
const maxNodesPerEdge = 3;
const basePulseSpeed = 0.002 * params.motion;
const pulseVariation = 0.001 * params.motion;
const baseThickness = 1 * (1 - params.dryness);
const maxThickness = baseThickness * 3;
// Network graph structure
class Node {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.baseSize = 2 + Math.random() * 4;
this.pulsePhase = Math.random();
this.pulseSpeed = basePulseSpeed + (Math.random() * 2 - 1) * pulseVariation;
this.connections = [];
this.maxConnections = 2 + Math.floor(Math.random() * maxNodesPerEdge);
}
connect(other) {
if (this.connections.length >= this.maxConnections || other.connections.length >= other.maxConnections) {
return false;
}
if (Math.random() > edgeDensity) {
return false;
}
this.connections.push(other);
other.connections.push(this);
return true;
}
pulse(t) {
const pulseFactor = 0.5 + 0.5 * Math.sin(this.pulsePhase + t * this.pulseSpeed);
return pulseFactor;
}
draw(ctx, t) {
const pulseFactor = this.pulse(t);
const size = this.baseSize * pulseFactor;
ctx.beginPath();
ctx.arc(this.x, this.y, size, 0, Math.PI * 2);
ctx.fillStyle = `hsl(0, 0%, ${60 + pulseFactor * 20}%)`;
ctx.fill();
}
}
// Create network
const nodes = Array.from({length: nodeCount}, () => new Node());
for (let i = 0; i < nodeCount; i++) {
for (let j = i + 1; j < nodeCount && nodes[i].connections.length < nodes[i].maxConnections; j++) {
nodes[i].connect(nodes[j]);
}
}
// Main animation loop
let t = 0;
function animate() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw connections
const now = Date.now() * 0.001;
nodes.forEach(node => {
const pulseFactor = node.pulse(now);
node.connections.forEach(conn => {
const connFactor = conn.pulse(now);
const combinedFactor = (pulseFactor + connFactor) * 0.5;
// Calculate connection thickness based on pulse
const thickness = baseThickness + (maxThickness - baseThickness) * combinedFactor;
// Draw with additive blending for glow effect
ctx.globalCompositeOperation = 'lighter';
ctx.strokeStyle = `rgba(255, 255, 255, ${combinedFactor * 0.6})`;
ctx.lineWidth = thickness;
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(conn.x, conn.y);
ctx.stroke();
ctx.globalCompositeOperation = 'source-over';
});
});
// Draw nodes
nodes.forEach(node => node.draw(ctx, now));
t += 0.01;
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>