birth: Fractal Breath of Depth

This commit is contained in:
motd_admin 2026-09-25 22:21:24 +00:00
parent 825013bf3a
commit dfba73259d

202
index.html Normal file
View file

@ -0,0 +1,202 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neurameba Fractal Motion</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #0a0a0a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
display: block;
}
#attribution {
position: fixed;
bottom: 10px;
right: 10px;
color: #555;
font-family: monospace;
font-size: 10px;
text-shadow: 0 0 5px rgba(0,0,0,0.5);
}
</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();
// Fractal parameters derived from input
const params = {
motion: 0.521,
density: 0.485,
complexity: 0.533,
connectedness: 0.505,
lifespan: 0.402,
survivingNodes: 88,
branchCount: 79,
loops: 1324,
maxDepth: 21,
thicknessRatio: 1.50,
fractalDimension: 1.535,
pulse: { avg: 0.36, min: 0.30, max: 1.65 },
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 }
};
// Fractal system
const fractalSystem = {
roots: [],
maxDepth: params.maxDepth,
branchAngle: Math.PI * 0.4,
branchLength: 5,
branchWidth: 1,
branchDecay: 0.7,
pulseFactor: 1.0,
seed: Math.random() * 1000,
lastUpdate: 0,
init() {
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
const rootCount = Math.max(2, Math.floor(params.survivingNodes * 0.1));
for (let i = 0; i < rootCount; i++) {
const angle = (i / rootCount) * Math.PI * 2;
const x = centerX + Math.cos(angle) * canvas.width * 0.2;
const y = centerY + Math.sin(angle) * canvas.height * 0.2;
this.roots.push({
x, y,
angle,
depth: 0,
branches: [],
pulse: Math.random() * 0.5 + 0.5
});
}
},
update(time) {
const dt = (time - this.lastUpdate) / 1000;
this.lastUpdate = time;
this.pulseFactor = params.pulse.avg + Math.sin(time * 0.0005) * params.pulse.avg * 0.5;
// Update all roots and branches
this.roots.forEach(root => this.processBranch(root, dt));
},
processBranch(branch, dt) {
if (branch.depth >= this.maxDepth) return;
const decay = Math.pow(this.branchDecay, branch.depth);
const maxBranches = Math.floor(params.branchCount * decay * 0.01 * this.pulseFactor);
// Create new branches
if (branch.branches.length < maxBranches && branch.depth < this.maxDepth) {
const angleVariation = this.branchAngle * (0.5 + Math.sin(this.seed + branch.depth * 0.3) * 0.5);
const newAngle1 = branch.angle + angleVariation;
const newAngle2 = branch.angle - angleVariation * 0.7;
const length = this.branchLength * decay * this.pulseFactor;
const newX1 = branch.x + Math.cos(newAngle1) * length;
const newY1 = branch.y + Math.sin(newAngle1) * length;
const newX2 = branch.x + Math.cos(newAngle2) * length * 0.8;
const newY2 = branch.y + Math.sin(newAngle2) * length * 0.8;
const newBranch1 = {
x: newX1, y: newY1,
angle: newAngle1,
parent: branch,
depth: branch.depth + 1,
branches: [],
pulse: branch.pulse * 0.9 + Math.random() * 0.2
};
const newBranch2 = {
x: newX2, y: newY2,
angle: newAngle2,
parent: branch,
depth: branch.depth + 1,
branches: [],
pulse: branch.pulse * 0.9 + Math.random() * 0.2
};
branch.branches.push(newBranch1, newBranch2);
}
// Apply pulse variation
branch.pulse += (Math.random() - 0.5) * 0.02;
branch.pulse = Math.max(0.1, Math.min(1.2, branch.pulse));
// Process child branches
branch.branches.forEach(b => this.processBranch(b, dt));
},
draw() {
ctx.strokeStyle = `hsl(0, 0%, ${10 + params.tone.dryness * 80}%)`;
ctx.lineWidth = this.branchWidth * params.thicknessRatio;
const drawBranch = (branch) => {
ctx.beginPath();
ctx.moveTo(branch.x, branch.y);
// Draw line to parent with pulse variation
const pulse = branch.pulse * this.pulseFactor;
const endX = branch.x;
const endY = branch.y;
// Draw forked appearance
const leftX = endX + Math.cos(branch.angle) * -3 * pulse;
const leftY = endY + Math.sin(branch.angle) * -3 * pulse;
const rightX = endX + Math.cos(branch.angle + Math.PI) * -2 * pulse;
const rightY = endY + Math.sin(branch.angle + Math.PI) * -2 * pulse;
ctx.lineTo(leftX, leftY);
ctx.lineTo(endX, endY);
ctx.lineTo(rightX, rightY);
ctx.stroke();
// Draw branches
branch.branches.forEach(drawBranch);
};
this.roots.forEach(drawBranch);
}
};
// Animation loop
function animate(time) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Fade background slightly
ctx.fillStyle = `rgba(0, 0, 0, 0.05)`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update and draw fractal system
fractalSystem.update(time);
fractalSystem.draw();
requestAnimationFrame(animate);
}
fractalSystem.init();
animate(0);
</script>
</body>
</html>