birth: Pulsing Neural Echoes

This commit is contained in:
motd_admin 2026-10-14 10:21:24 +00:00
parent 350eb5be6b
commit f33e37e40c

208
index.html Normal file
View file

@ -0,0 +1,208 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neurameba · Pulse</title>
<style>
body { margin: 0; overflow: hidden; background: #000; }
canvas { display: block; }
#info { position: absolute; bottom: 10px; left: 10px; color: #aaa; font-family: monospace; font-size: 12px; }
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="info">neurameba · motd.social</div>
<script>
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
// Set canvas to full window size
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Parameters mapped from generative art builder
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.1, min: 0.9, max: 1.2 },
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.8, playfulness: 0, tension: 0 }
};
// Network graph simulation
class Node {
constructor(x, y) {
this.x = x;
this.y = y;
this.vx = (Math.random() - 0.5) * params.motion * 4;
this.vy = (Math.random() - 0.5) * params.motion * 4;
this.size = (0.5 + Math.random() * 0.5) * params.density * 8;
this.life = 0;
this.maxLife = 100 + Math.random() * 100;
this.color = `hsl(0, 0%, ${50 + Math.random() * 30}%)`;
}
update(nodes, links) {
// Apply small random variations to motion
this.vx += (Math.random() - 0.5) * params.motion * 0.1;
this.vy += (Math.random() - 0.5) * params.motion * 0.1;
// Boundary check
if (this.x < 0 || this.x > canvas.width) this.vx *= -0.5;
if (this.y < 0 || this.y > canvas.height) this.vy *= -0.5;
this.x += this.vx;
this.y += this.vy;
this.life++;
// Fade out old nodes
if (this.life > this.maxLife * (1 - params.lifespan)) {
this.size *= 0.95;
this.color = `hsl(0, 0%, ${Math.max(10, parseInt(this.color.match(/\d+/)[0]) - 1)}%)`;
}
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = this.color;
ctx.fill();
}
}
class Link {
constructor(a, b) {
this.a = a;
this.b = b;
this.age = 0;
this.maxAge = 200;
this.strength = 0.5 + Math.random() * 0.5;
}
update() {
this.age++;
// Links dissolve over time
return this.age < this.maxAge * params.connectedness;
}
draw() {
const alpha = Math.min(1, (1 - this.age / this.maxAge) * this.strength * 2);
ctx.strokeStyle = `rgba(180, 180, 180, ${alpha})`;
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(this.a.x, this.a.y);
ctx.lineTo(this.b.x, this.b.y);
ctx.stroke();
}
}
// Simulation state
const nodes = [];
const links = [];
let lastTime = 0;
// Initialize with density parameter
function initNodes() {
const count = Math.floor(params.density * 200 + 10);
for (let i = 0; i < count; i++) {
nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
}
// Pulse animation
function getPulseScale(time) {
const pulse = params.pulse;
const t = time * 0.001;
const base = pulse.avg;
const variation = (Math.sin(t * 2) * 0.1 + Math.random() * 0.05);
return Math.max(pulse.min, Math.min(pulse.max, base + variation));
}
// Create new links based on proximity and connectedness
function createLinks() {
const maxDist = params.density * 300;
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 dist = Math.sqrt(dx * dx + dy * dy);
if (dist < maxDist) {
const linkage = Math.random() * params.connectedness;
if (linkage < 0.7) {
links.push(new Link(nodes[i], nodes[j]));
}
}
}
}
}
function animate(time) {
// Clear with semi-transparent to create trails
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Apply pulse scaling
const scale = getPulseScale(time);
ctx.save();
ctx.scale(scale, scale);
const offsetX = (1 - scale) * canvas.width / 2 / scale;
const offsetY = (1 - scale) * canvas.height / 2 / scale;
ctx.translate(offsetX, offsetY);
// Update and draw nodes
for (let i = nodes.length - 1; i >= 0; i--) {
nodes[i].update(nodes, links);
nodes[i].draw();
// Remove dead nodes
if (nodes[i].size < 0.5) {
nodes.splice(i, 1);
}
}
// Update and draw links
for (let i = links.length - 1; i >= 0; i--) {
if (links[i].update()) {
links[i].draw();
} else {
links.splice(i, 1);
}
}
// Periodically add new nodes to maintain density
if (time - lastTime > params.pulse.avg * 1000 && Math.random() < 0.3) {
nodes.push(new Node(
Math.random() * canvas.width,
Math.random() * canvas.height
));
lastTime = time;
}
// Periodically create new links
if (time % 5000 < 100) {
createLinks();
}
ctx.restore();
requestAnimationFrame(animate);
}
// Initialize and start animation
initNodes();
createLinks();
requestAnimationFrame(animate);
</script>
</body>
</html>