birth: pulsing synaptic lattice
This commit is contained in:
parent
e219359d98
commit
dfe2745d8b
1 changed files with 199 additions and 0 deletions
199
index.html
Normal file
199
index.html
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>neurameba · motd.social</title>
|
||||
<style>
|
||||
* { margin: 0; overflow: hidden; }
|
||||
canvas { display: block; background: #0a0a0a; }
|
||||
#attr { position: fixed; bottom: 12px; left: 12px; color: #444; font-family: monospace; font-size: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="c"></canvas>
|
||||
<div id="attr">neurameba · motd.social</div>
|
||||
<script>
|
||||
const c = document.getElementById('c');
|
||||
const ctx = c.getContext('2d');
|
||||
|
||||
function resize() {
|
||||
c.width = window.innerWidth;
|
||||
c.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resize);
|
||||
resize();
|
||||
|
||||
// Parameters derived from input
|
||||
const params = {
|
||||
motion: 0.517,
|
||||
density: 0.485,
|
||||
complexity: 0.535,
|
||||
connectedness: 0.468,
|
||||
lifespan: 0.501,
|
||||
survivingNodes: 73,
|
||||
branchCount: 60,
|
||||
loops: 205,
|
||||
maxDepth: 15,
|
||||
thicknessRatio: 1.25,
|
||||
fractalDim: 1.828,
|
||||
finalEnergy: 385.5,
|
||||
pulseAvg: 0.66,
|
||||
pulseMin: 0.30,
|
||||
pulseMax: 1.85,
|
||||
tone: { anger: 0, sadness: 0, curiosity: 0.6, dryness: 0.8, playfulness: 0.1, tension: 0 }
|
||||
};
|
||||
|
||||
// Network graph with evolving connections and pulse-driven dynamics
|
||||
class Node {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.vx = (Math.random() - 0.5) * 0.5;
|
||||
this.vy = (Math.random() - 0.5) * 0.5;
|
||||
this.size = 1 + Math.random() * 2 * params.thicknessRatio;
|
||||
this.connections = [];
|
||||
this.age = 0;
|
||||
this.maxAge = 100 + Math.random() * 200;
|
||||
this.pulse = params.pulseMin + (params.pulseMax - params.pulseMin) * Math.random();
|
||||
this.targetPulse = this.pulse;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.age++;
|
||||
if (this.age > this.maxAge * params.lifespan) {
|
||||
this.size *= 0.95;
|
||||
}
|
||||
|
||||
// Pulse-driven motion
|
||||
this.pulse += (this.targetPulse - this.pulse) * 0.05;
|
||||
const pulseScale = 0.5 + 0.5 * Math.sin(Date.now() * 0.001 * this.pulse);
|
||||
this.x += this.vx * pulseScale;
|
||||
this.y += this.vy * pulseScale;
|
||||
|
||||
// Wrap around edges
|
||||
if (this.x < 0) this.x = c.width;
|
||||
if (this.x > c.width) this.x = 0;
|
||||
if (this.y < 0) this.y = c.height;
|
||||
if (this.y > c.height) this.y = 0;
|
||||
}
|
||||
|
||||
draw() {
|
||||
const opacity = Math.min(1, this.age / 100);
|
||||
ctx.globalAlpha = opacity * 0.8;
|
||||
ctx.fillStyle = `hsl(180, 30%, ${60 + Math.sin(this.age * 0.1) * 10}%)`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, this.size * (0.8 + 0.2 * Math.sin(this.age * 0.05)), 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
class Connection {
|
||||
constructor(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.thickness = 0.5 + 1.5 * params.thicknessRatio;
|
||||
this.age = 0;
|
||||
this.maxAge = 200 + Math.random() * 300;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.age++;
|
||||
}
|
||||
|
||||
draw() {
|
||||
const progress = Math.min(1, this.age / this.maxAge);
|
||||
const fade = Math.pow(progress, 0.5);
|
||||
ctx.globalAlpha = 0.3 * fade;
|
||||
ctx.lineWidth = this.thickness * (0.5 + 0.5 * Math.sin(this.age * 0.03));
|
||||
ctx.strokeStyle = `hsl(180, 30%, ${60 + Math.sin(this.age * 0.1) * 10}%)`;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.a.x, this.a.y);
|
||||
ctx.lineTo(this.b.x, this.b.y);
|
||||
ctx.stroke();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
const nodes = [];
|
||||
const connections = [];
|
||||
|
||||
// Initialize nodes with density-based distribution
|
||||
const nodeCount = Math.floor(params.survivingNodes * (0.5 + 0.5 * params.density));
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
nodes.push(new Node(
|
||||
Math.random() * c.width,
|
||||
Math.random() * c.height
|
||||
));
|
||||
}
|
||||
|
||||
// Create initial connections based on complexity and connectedness
|
||||
function createConnections() {
|
||||
connections.length = 0;
|
||||
|
||||
// Create some initial connections
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const connectionsThisNode = Math.floor(params.branchCount * params.connectedness / nodes.length);
|
||||
|
||||
for (let j = 0; j < connectionsThisNode; j++) {
|
||||
const other = nodes[Math.floor(Math.random() * nodes.length)];
|
||||
if (other !== nodes[i] && !connections.some(c => (c.a === nodes[i] && c.b === other) || (c.a === other && c.b === nodes[i]))) {
|
||||
connections.push(new Connection(nodes[i], other));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add new connections probabilistically based on loops
|
||||
function addLoops() {
|
||||
const targetLoops = Math.floor(params.loops * params.complexity);
|
||||
while (connections.length < targetLoops && nodes.length > 1) {
|
||||
const a = nodes[Math.floor(Math.random() * nodes.length)];
|
||||
const b = nodes[Math.floor(Math.random() * nodes.length)];
|
||||
if (a !== b && !connections.some(c => (c.a === a && c.b === b) || (c.a === b && c.b === a))) {
|
||||
connections.push(new Connection(a, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createConnections();
|
||||
addLoops();
|
||||
|
||||
function animate() {
|
||||
ctx.clearRect(0, 0, c.width, c.height);
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, c.width, c.height);
|
||||
|
||||
// Update and draw nodes
|
||||
for (const node of nodes) {
|
||||
node.update();
|
||||
node.draw();
|
||||
}
|
||||
|
||||
// Update and draw connections
|
||||
for (const conn of connections) {
|
||||
conn.update();
|
||||
conn.draw();
|
||||
}
|
||||
|
||||
// Occasionally add new connections to maintain complexity
|
||||
if (Math.random() < 0.02 * params.complexity) {
|
||||
addLoops();
|
||||
}
|
||||
|
||||
// Occasionally remove old connections
|
||||
if (Math.random() < 0.01) {
|
||||
if (connections.length > 0) {
|
||||
connections.splice(Math.floor(Math.random() * connections.length), 1);
|
||||
}
|
||||
}
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue