frayed-neural-drift-hcm3/index.html

215 lines
No EOL
6.9 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 Pulse Network</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #000;
color: #333;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 20px;
left: 20px;
font-size: 12px;
color: #555;
z-index: 10;
}
</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();
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 parameters
const nodeCount = Math.floor(50 + params.density * 150);
const edgeCount = Math.floor(nodeCount * 1.5 * params.connectedness);
const nodes = [];
const edges = [];
const colors = [
'#f0f0f0', // dryness
'#a0a0a0', // dryness
'#808080' // dryness
];
// Node class
class Node {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = (Math.random() - 0.5) * 2 * params.motion;
this.vy = (Math.random() - 0.5) * 2 * params.motion;
this.fixed = Math.random() < 0.1;
this.radius = 1 + Math.random() * 5 * params.density;
this.lifespan = 1;
this.age = 0;
this.pulse = 1;
}
update() {
if (!this.fixed) {
this.x += this.vx;
this.y += this.vy;
// Bounce off edges
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
}
// Pulse effect
this.pulse = params.pulse.avg + (Math.random() * (params.pulse.max - params.pulse.min) - (params.pulse.max - params.pulse.min)/2);
this.radius *= this.pulse;
// Age and fade
this.age += 0.001;
this.lifespan = Math.max(0, this.lifespan - 0.0001 * (1 - params.lifespan));
}
draw() {
const alpha = this.lifespan * (0.5 + Math.sin(this.age * 2) * 0.3);
const radius = this.radius * (0.8 + Math.sin(this.age * 3) * 0.2);
ctx.beginPath();
ctx.arc(this.x, this.y, radius, 0, Math.PI * 2);
ctx.fillStyle = colors[0] + Math.floor(alpha * 255).toString(16).padStart(2, '0');
ctx.fill();
}
}
// Edge class
class Edge {
constructor(a, b) {
this.a = a;
this.b = b;
this.length = Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
this.strength = 0.1 + Math.random() * 0.3 * params.connectedness;
this.age = 0;
this.lifespan = 1;
}
update() {
this.age += 0.001;
this.lifespan = Math.max(0, this.lifespan - 0.00005 * (1 - params.lifespan));
}
draw() {
const alpha = this.lifespan * 0.5;
if (alpha <= 0) return;
const gradient = ctx.createLinearGradient(this.a.x, this.a.y, this.b.x, this.b.y);
gradient.addColorStop(0, colors[1] + Math.floor(alpha * 255 * this.strength).toString(16).padStart(2, '0'));
gradient.addColorStop(1, colors[2] + Math.floor(alpha * 255 * this.strength).toString(16).padStart(2, '0'));
ctx.beginPath();
ctx.moveTo(this.a.x, this.a.y);
ctx.lineTo(this.b.x, this.b.y);
ctx.strokeStyle = gradient;
ctx.lineWidth = 0.5 * this.strength;
ctx.stroke();
// Draw nodes if their edges are visible
this.a.draw();
this.b.draw();
}
}
// Initialize nodes
for (let i = 0; i < nodeCount; i++) {
nodes.push(new Node());
}
// Create edges based on proximity
for (let i = 0; i < nodeCount; i++) {
for (let j = i + 1; j < nodeCount; 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 < 100 * params.connectedness) {
edges.push(new Edge(nodes[i], nodes[j]));
}
}
}
// Add some fixed central nodes
for (let i = 0; i < 3; i++) {
const node = new Node();
node.fixed = true;
node.x = canvas.width / 2 + (Math.random() - 0.5) * 100;
node.y = canvas.height / 2 + (Math.random() - 0.5) * 100;
node.radius *= 2;
nodes.push(node);
}
// Animation loop
function animate() {
ctx.fillStyle = '#000000';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update and draw edges first (so nodes appear on top)
edges.forEach(edge => {
edge.update();
edge.draw();
});
// Update and draw nodes
nodes.forEach(node => {
node.update();
node.draw();
});
// Occasionally add new nodes and edges
if (Math.random() < 0.01 * params.density) {
nodes.push(new Node());
}
if (Math.random() < 0.02 * params.connectedness && nodes.length > 1) {
const a = nodes[Math.floor(Math.random() * nodes.length)];
const b = nodes[Math.floor(Math.random() * nodes.length)];
if (a !== b) {
edges.push(new Edge(a, b));
}
}
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>