birth: Fractal Connections in Motion
This commit is contained in:
parent
04742c9035
commit
21fe46f192
1 changed files with 209 additions and 0 deletions
209
index.html
Normal file
209
index.html
Normal file
|
|
@ -0,0 +1,209 @@
|
||||||
|
<!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>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: flex-end;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
color: #555555;
|
||||||
|
font-size: 10px;
|
||||||
|
user-select: none;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
</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 mapped from generative input
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.07, min: 1.0, max: 1.1 },
|
||||||
|
tone: {
|
||||||
|
anger: 0.0,
|
||||||
|
sadness: 0.0,
|
||||||
|
curiosity: 0.7,
|
||||||
|
dryness: 0.8,
|
||||||
|
playfulness: 0.3,
|
||||||
|
tension: 0.0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Network graph simulation
|
||||||
|
const nodes = [];
|
||||||
|
const edges = [];
|
||||||
|
const maxNodes = Math.floor(100 + params.density * 200);
|
||||||
|
const nodeSizeFactor = 1 + params.complexity * 4;
|
||||||
|
const edgeThickness = 0.5 + params.connectedness * 1.5;
|
||||||
|
const pulseFactor = params.pulse.avg;
|
||||||
|
|
||||||
|
class Node {
|
||||||
|
constructor() {
|
||||||
|
this.x = Math.random() * canvas.width;
|
||||||
|
this.y = Math.random() * canvas.height;
|
||||||
|
this.vx = (Math.random() - 0.5) * 0.5 * params.motion;
|
||||||
|
this.vy = (Math.random() - 0.5) * 0.5 * params.motion;
|
||||||
|
this.size = 1 + Math.random() * nodeSizeFactor;
|
||||||
|
this.color = `hsl(180, 30%, ${20 + Math.random() * 30}%)`;
|
||||||
|
this.lifespan = params.lifespan * 100 + Math.random() * 100;
|
||||||
|
this.age = 0;
|
||||||
|
this.energy = Math.random();
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.x += this.vx * pulseFactor;
|
||||||
|
this.y += this.vy * pulseFactor;
|
||||||
|
|
||||||
|
// Boundary collision
|
||||||
|
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.size *= 0.999; // Slow decay
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = this.color;
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
// Highlight active nodes
|
||||||
|
if (this.age < 20) {
|
||||||
|
ctx.strokeStyle = 'rgba(255, 255, 255, 0.8)';
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Edge {
|
||||||
|
constructor(a, b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.length = Math.sqrt(
|
||||||
|
Math.pow(b.x - a.x, 2) + Math.pow(b.y - a.y, 2)
|
||||||
|
);
|
||||||
|
this.color = `hsl(180, 20%, ${30 + Math.random() * 20}%)`;
|
||||||
|
this.thickness = edgeThickness * (0.5 + Math.random() * 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
// Pulse effect
|
||||||
|
const pulse = 1 + 0.1 * (Math.sin(Date.now() * 0.002) * 0.5 + 0.5);
|
||||||
|
this.length = Math.sqrt(
|
||||||
|
Math.pow(this.b.x - this.a.x, 2) + Math.pow(this.b.y - this.a.y, 2)
|
||||||
|
) * pulse * 0.95 + this.length * 0.05;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.a.x, this.a.y);
|
||||||
|
ctx.lineTo(this.b.x, this.b.y);
|
||||||
|
ctx.strokeStyle = this.color;
|
||||||
|
ctx.lineWidth = this.thickness;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize network
|
||||||
|
function initNetwork() {
|
||||||
|
nodes.length = 0;
|
||||||
|
edges.length = 0;
|
||||||
|
|
||||||
|
// Create nodes
|
||||||
|
for (let i = 0; i < maxNodes; i++) {
|
||||||
|
nodes.push(new Node());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create edges with probability based on connectedness
|
||||||
|
const targetEdges = maxNodes * params.connectedness * 2;
|
||||||
|
for (let i = 0; i < nodes.length && edges.length < targetEdges; i++) {
|
||||||
|
const closest = [];
|
||||||
|
for (let j = 0; j < nodes.length; j++) {
|
||||||
|
if (i !== j) {
|
||||||
|
const dx = nodes[j].x - nodes[i].x;
|
||||||
|
const dy = nodes[j].y - nodes[i].y;
|
||||||
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
closest.push({ node: nodes[j], dist });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by distance and add edges to nearest nodes
|
||||||
|
closest.sort((a, b) => a.dist - b.dist);
|
||||||
|
const neighbors = Math.min(3 + Math.floor(params.complexity * 3), closest.length);
|
||||||
|
for (let k = 0; k < neighbors && edges.length < targetEdges; k++) {
|
||||||
|
const existing = edges.find(e =>
|
||||||
|
(e.a === nodes[i] && e.b === closest[k].node) ||
|
||||||
|
(e.a === closest[k].node && e.b === nodes[i])
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
edges.push(new Edge(nodes[i], closest[k].node));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Dim background
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Update and draw edges
|
||||||
|
edges.forEach(edge => {
|
||||||
|
edge.update();
|
||||||
|
edge.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update and draw nodes
|
||||||
|
nodes.forEach(node => {
|
||||||
|
node.update();
|
||||||
|
node.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize and start
|
||||||
|
initNetwork();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue