149 lines
No EOL
4.8 KiB
HTML
149 lines
No EOL
4.8 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: absolute;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
color: #444;
|
|
font-size: 10px;
|
|
mix-blend-mode: difference;
|
|
}
|
|
</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
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulseAvg: 1.11,
|
|
pulseMin: 0.95,
|
|
pulseMax: 1.30,
|
|
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.9, playfulness: 0, tension: 0 }
|
|
};
|
|
|
|
// Network graph implementation
|
|
class Node {
|
|
constructor(x, y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.vx = (Math.random() - 0.5) * 2 * params.motion;
|
|
this.vy = (Math.random() - 0.5) * 2 * params.motion;
|
|
this.size = 2 + Math.random() * 3 * params.density;
|
|
this.connections = [];
|
|
this.life = 0;
|
|
this.maxLife = 500 + Math.random() * 500 * params.lifespan;
|
|
this.pulse = params.pulseAvg * (0.9 + Math.random() * 0.2);
|
|
this.energy = 0;
|
|
}
|
|
|
|
update() {
|
|
// Movement
|
|
this.x += this.vx;
|
|
this.y += this.vy;
|
|
|
|
// Boundary check
|
|
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
|
|
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
|
|
|
|
// Connections
|
|
if (params.connectedness > 0.7 && Math.random() < 0.05 * params.connectedness) {
|
|
if (this.connections.length < 5 * params.complexity) {
|
|
const target = nodes[Math.floor(Math.random() * nodes.length)];
|
|
if (target !== this && !this.connections.includes(target)) {
|
|
this.connections.push(target);
|
|
target.connections.push(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Life and energy
|
|
this.life++;
|
|
this.energy = this.life / this.maxLife * params.pulseAvg;
|
|
}
|
|
|
|
draw() {
|
|
const alpha = Math.min(1, this.life / 100);
|
|
ctx.globalAlpha = alpha * 0.8;
|
|
|
|
// Node color based on tone
|
|
const hue = 180 + 50 * params.tone.curiosity; // Teal range
|
|
ctx.fillStyle = `hsl(${hue}, ${20 * params.tone.dryness}%, ${50 + 10 * params.tone.dryness}%)`;
|
|
|
|
// Draw connections first
|
|
ctx.lineWidth = 0.5 * params.connectedness;
|
|
ctx.strokeStyle = `hsla(${hue}, ${20 * params.tone.dryness}%, ${50 + 10 * params.tone.dryness}%, 0.3)`;
|
|
ctx.beginPath();
|
|
for (const conn of this.connections) {
|
|
ctx.moveTo(this.x, this.y);
|
|
ctx.lineTo(conn.x, conn.y);
|
|
}
|
|
ctx.stroke();
|
|
|
|
// Draw node
|
|
ctx.beginPath();
|
|
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
}
|
|
}
|
|
|
|
let nodes = [];
|
|
function initNodes() {
|
|
nodes = [];
|
|
const count = Math.floor(50 + 200 * params.density);
|
|
for (let i = 0; i < count; i++) {
|
|
nodes.push(new Node(
|
|
Math.random() * canvas.width,
|
|
Math.random() * canvas.height
|
|
));
|
|
}
|
|
}
|
|
initNodes();
|
|
|
|
function animate() {
|
|
// Fade effect
|
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Update and draw nodes
|
|
ctx.globalAlpha = 1;
|
|
for (const node of nodes) {
|
|
node.update();
|
|
node.draw();
|
|
}
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |