birth: Fractal Breaths of Time

This commit is contained in:
motd_admin 2026-08-12 14:21:22 +00:00
parent 481515cd0f
commit 02cc1dafe6

206
index.html Normal file
View file

@ -0,0 +1,206 @@
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recursive Pulses</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #0a0a1a;
font-family: 'Courier New', monospace;
color: #555;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
font-size: 10px;
opacity: 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();
// Parameters derived from your specifications
const params = {
motion: 0.527,
density: 0.455,
complexity: 0.521,
connectedness: 0.452,
lifespan: 0.582,
pulse: { avg: 0.48, min: 0.30, max: 1.75 }
};
// Fractal generation parameters
const maxDepth = Math.floor(13 * params.complexity);
const minSize = 2 * params.density;
const branchAngle = Math.PI * 0.4 * params.connectedness;
const branchLength = 40 * (1 - params.density);
const thickness = 1.5 * params.density;
// Color palette based on tone
const palette = {
bg: '#0a0a1a',
main: '#aaffff',
secondary: '#55aaff',
accent: '#003355'
};
// Fractal node
class FractalNode {
constructor(x, y, depth, angle, parent) {
this.x = x;
this.y = y;
this.depth = depth;
this.angle = angle;
this.parent = parent;
this.children = [];
this.size = minSize + (maxDepth - depth) * 5;
this.color = this.getColor();
this.pulse = params.pulse.min;
this.lifespan = params.lifespan * 1000;
this.creationTime = Date.now();
this.velocity = { x: 0, y: 0 };
if (depth < maxDepth) {
this.spawnChildren();
}
}
getColor() {
const hue = 180 + Math.floor(this.depth * 2);
const sat = 50 + Math.floor(this.depth * 3);
const light = 70 - Math.floor(this.depth * 2);
return `hsl(${hue}, ${sat}%, ${light}%)`;
}
spawnChildren() {
const branchCount = Math.floor(50 * params.connectedness / (this.depth + 1));
const angleVariation = branchAngle * (1 + Math.random() * params.complexity * 2);
for (let i = 0; i < branchCount; i++) {
const angle = this.angle + (Math.random() - 0.5) * angleVariation;
const length = branchLength * (0.7 + 0.3 * params.motion);
const x = this.x + Math.cos(angle) * length;
const y = this.y + Math.sin(angle) * length;
const child = new FractalNode(x, y, this.depth + 1, angle, this);
this.children.push(child);
}
}
update() {
const age = (Date.now() - this.creationTime) / this.lifespan;
if (age > 1) return false;
// Pulsing effect
const pulseFactor = params.pulse.avg + Math.sin(Date.now() * 0.001) * 0.3;
this.pulse = params.pulse.min + (params.pulse.max - params.pulse.min) * pulseFactor;
// Motion effect
const motionFactor = params.motion * 0.5;
this.x += Math.cos(Date.now() * 0.0005 + this.x * 0.01) * motionFactor;
this.y += Math.sin(Date.now() * 0.0005 + this.y * 0.01) * motionFactor;
// Update children
for (let i = this.children.length - 1; i >= 0; i--) {
if (!this.children[i].update()) {
this.children.splice(i, 1);
}
}
return true;
}
draw() {
if (this.size < 1) return;
// Draw line to parent
if (this.parent) {
ctx.strokeStyle = this.color;
ctx.lineWidth = thickness * this.pulse;
ctx.beginPath();
ctx.moveTo(this.parent.x, this.parent.y);
ctx.lineTo(this.x, this.y);
ctx.stroke();
}
// Draw node
ctx.fillStyle = this.color;
ctx.beginPath();
ctx.arc(this.x, this.y, this.size * this.pulse, 0, Math.PI * 2);
ctx.fill();
// Draw children
for (const child of this.children) {
child.draw();
}
}
}
// Initialize
let rootNodes = [];
let frameCount = 0;
function init() {
rootNodes = [];
const rootCount = Math.floor(54 * params.density);
for (let i = 0; i < rootCount; i++) {
const angle = Math.random() * Math.PI * 2;
const x = canvas.width * 0.5 + Math.cos(angle) * canvas.width * 0.4;
const y = canvas.height * 0.5 + Math.sin(angle) * canvas.height * 0.4;
rootNodes.push(new FractalNode(x, y, 0, angle));
}
}
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update and draw fractals
for (let i = rootNodes.length - 1; i >= 0; i--) {
if (!rootNodes[i].update()) {
rootNodes.splice(i, 1);
} else {
rootNodes[i].draw();
}
}
// Add new roots occasionally
if (frameCount % 20 === 0 && rootNodes.length < 54 * params.density) {
const angle = Math.random() * Math.PI * 2;
const x = Math.random() * canvas.width;
const y = Math.random() * canvas.height;
rootNodes.push(new FractalNode(x, y, 0, angle));
}
frameCount++;
requestAnimationFrame(animate);
}
init();
animate();
</script>
</body>
</html>
```