pulsing-neural-web-u71p/index.html

182 lines
No EOL
6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Organic Network</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
color: #ccc;
font-family: 'Courier New', monospace;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
font-size: 10px;
color: #555;
text-align: center;
}
</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 the brief
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.05, min: 1.0, max: 1.1 },
tone: { anger: 0.0, sadness: 0.0, curiosity: 0.1, dryness: 0.9, playfulness: 0.0, tension: 0.0 }
};
// Network graph implementation
class Node {
constructor(x, y) {
this.x = x;
this.y = y;
this.vx = (Math.random() - 0.5) * params.motion * 2;
this.vy = (Math.random() - 0.5) * params.motion * 2;
this.size = 2 + Math.random() * 3;
this.connections = [];
this.age = 0;
this.maxAge = 1000 + Math.random() * 500;
this.energy = 0;
}
update() {
this.x += this.vx;
this.y += this.vy;
// Boundary check with bounce
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
this.age++;
this.energy = Math.min(1, this.age / this.maxAge);
// Fade out at end of life
if (this.age > this.maxAge * 0.8) {
this.size *= 0.98;
}
}
draw() {
const hue = 200 + Math.sin(this.age * 0.01) * 20;
const saturation = 10 + this.energy * 80;
const brightness = 20 + this.energy * 50;
const alpha = 0.2 + this.energy * 0.8;
ctx.fillStyle = `hsla(${hue}, ${saturation}%, ${brightness}%, ${alpha})`;
ctx.beginPath();
ctx.arc(this.x, this.y, this.size * this.energy, 0, Math.PI * 2);
ctx.fill();
}
}
class Network {
constructor() {
this.nodes = [];
this.links = [];
this.nodeCount = Math.floor(50 + params.density * 150);
// Create nodes
for (let i = 0; i < this.nodeCount; i++) {
this.nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
// Create connections based on connectedness
const avgConnections = 2 + params.connectedness * 5;
for (let i = 0; i < this.nodeCount * 1.5; i++) {
const a = this.nodes[Math.floor(Math.random() * this.nodes.length)];
const b = this.nodes[Math.floor(Math.random() * this.nodes.length)];
if (a !== b && !a.connections.includes(b)) {
const distance = Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
if (distance < 200 || Math.random() < params.connectedness) {
a.connections.push(b);
b.connections.push(a);
this.links.push({
from: a,
to: b,
strength: 0.2 + Math.random() * 0.8
});
}
}
}
}
update() {
// Pulse effect
const pulse = params.pulse.avg + (Math.random() - 0.5) * 0.1;
this.nodes.forEach(node => node.update());
// Update links with pulse effect
this.links.forEach(link => {
ctx.strokeStyle = `hsla(200, 80%, 70%, ${0.1 + link.strength * pulse * 0.3})`;
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(link.from.x, link.from.y);
ctx.lineTo(link.to.x, link.to.y);
ctx.stroke();
});
// Draw nodes
this.nodes.forEach(node => node.draw());
// Occasionally add new nodes/links based on complexity
if (Math.random() < params.complexity * 0.005) {
this.nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
this.nodeCount++;
}
}
}
let network = new Network();
function animate() {
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
network.update();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>