birth: Whispering Node Constellations
This commit is contained in:
parent
a84bc5e7bb
commit
ea4db438b5
1 changed files with 225 additions and 0 deletions
225
index.html
Normal file
225
index.html
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba System</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
#info {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
color: #555;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="c"></canvas>
|
||||
<div id="info">neurameba · motd.social</div>
|
||||
<script>
|
||||
const c = document.getElementById('c');
|
||||
const ctx = c.getContext('2d');
|
||||
|
||||
// Set canvas to full window size
|
||||
function resizeCanvas() {
|
||||
c.width = window.innerWidth;
|
||||
c.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Parameters adjusted from abstract values
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: {
|
||||
avg: 1.08,
|
||||
min: 1.05,
|
||||
max: 1.10
|
||||
},
|
||||
tone: {
|
||||
anger: 0.0,
|
||||
sadness: 0.0,
|
||||
curiosity: 0.2,
|
||||
dryness: 0.8,
|
||||
playfulness: 0.0,
|
||||
tension: 0.0
|
||||
}
|
||||
};
|
||||
|
||||
// Calculate derived values
|
||||
const nodeCount = Math.floor(params.density * 200) + 50;
|
||||
const maxLinks = Math.floor(params.connectedness * 10 + 2);
|
||||
const linkDistance = params.complexity * 200 + 50;
|
||||
const linkWidth = params.tone.dryness > 0.7 ? 1 : 2;
|
||||
const repulsion = params.motion * 200 + 50;
|
||||
|
||||
// Initialize nodes
|
||||
let nodes = [];
|
||||
let links = [];
|
||||
|
||||
class Node {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.vx = 0;
|
||||
this.vy = 0;
|
||||
this.radius = params.dryness > 0.7 ? 2 : 3;
|
||||
this.lifespan = 1;
|
||||
this.maxLinks = maxLinks;
|
||||
this.links = [];
|
||||
}
|
||||
|
||||
update() {
|
||||
// Simple physics
|
||||
this.vx *= 0.9;
|
||||
this.vy *= 0.9;
|
||||
|
||||
// Repel from center
|
||||
const dx = this.x - c.width/2;
|
||||
const dy = this.y - c.height/2;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
if (dist > 10) {
|
||||
this.vx -= dx * 0.001 * repulsion;
|
||||
this.vy -= dy * 0.001 * repulsion;
|
||||
}
|
||||
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
// Lifespan decay
|
||||
this.lifespan *= 0.99;
|
||||
}
|
||||
|
||||
draw() {
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, this.radius * this.lifespan, 0, Math.PI*2);
|
||||
ctx.fillStyle = `rgba(180, 200, 180, ${this.lifespan * 0.5})`;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
class Link {
|
||||
constructor(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.strength = 0.5;
|
||||
this.age = 0;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.age++;
|
||||
// Links decay over time
|
||||
if (this.age > 1000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
draw() {
|
||||
const opacity = 1 - (this.age / 200);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.a.x, this.a.y);
|
||||
ctx.lineTo(this.b.x, this.b.y);
|
||||
ctx.strokeStyle = `rgba(150, 200, 150, ${opacity * 0.3})`;
|
||||
ctx.lineWidth = linkWidth;
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize network
|
||||
function initNetwork() {
|
||||
nodes = [];
|
||||
links = [];
|
||||
|
||||
// Create nodes in spiral pattern
|
||||
const centerX = c.width/2;
|
||||
const centerY = c.height/2;
|
||||
const maxRadius = Math.min(c.width, c.height) * 0.4;
|
||||
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
const angle = (i / nodeCount) * Math.PI * 2 * 10;
|
||||
const radius = maxRadius * Math.sqrt(i / nodeCount);
|
||||
const x = centerX + Math.cos(angle) * radius;
|
||||
const y = centerY + Math.sin(angle) * radius;
|
||||
nodes.push(new Node(x, y));
|
||||
}
|
||||
|
||||
// Create initial links
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const node = nodes[i];
|
||||
const others = nodes.filter((n, j) => j !== i);
|
||||
|
||||
// Sort by distance
|
||||
others.sort((a, b) => {
|
||||
const da = Math.hypot(a.x - node.x, a.y - node.y);
|
||||
const db = Math.hypot(b.x - node.x, b.y - node.y);
|
||||
return da - db;
|
||||
});
|
||||
|
||||
// Connect to nearest nodes
|
||||
const count = Math.min(node.maxLinks, others.length);
|
||||
for (let j = 0; j < count; j++) {
|
||||
links.push(new Link(node, others[j]));
|
||||
node.links.push(links[links.length-1]);
|
||||
others[j].links.push(links[links.length-1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
// Clear with fade effect
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, c.width, c.height);
|
||||
|
||||
// Update and draw nodes
|
||||
nodes.forEach(node => {
|
||||
node.update();
|
||||
node.draw();
|
||||
});
|
||||
|
||||
// Update and draw links
|
||||
for (let i = links.length-1; i >= 0; i--) {
|
||||
if (!links[i].update()) {
|
||||
// Remove dead links
|
||||
const a = links[i].a;
|
||||
const b = links[i].b;
|
||||
a.links = a.links.filter(l => l !== links[i]);
|
||||
b.links = b.links.filter(l => l !== links[i]);
|
||||
links.splice(i, 1);
|
||||
} else {
|
||||
links[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
// Occasionally add new links
|
||||
if (Math.random() < 0.01) {
|
||||
const a = nodes[Math.floor(Math.random() * nodes.length)];
|
||||
const b = nodes[Math.floor(Math.random() * nodes.length)];
|
||||
if (a !== b && a.links.length < maxLinks && b.links.length < maxLinks) {
|
||||
links.push(new Link(a, b));
|
||||
a.links.push(links[links.length-1]);
|
||||
b.links.push(links[links.length-1]);
|
||||
}
|
||||
}
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Initialize and start
|
||||
initNetwork();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue