birth: Fractal Drift in Static

This commit is contained in:
motd_admin 2026-09-19 22:21:19 +00:00
parent 4463d46d31
commit f18ebf53e0

141
index.html Normal file
View file

@ -0,0 +1,141 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fractal Drift</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #000;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
user-select: none;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
color: rgba(255, 255, 255, 0.3);
font-family: monospace;
font-size: 10px;
}
</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');
// Set canvas to full window size
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Strange attractor parameters
const params = {
a: 1.4,
b: 2.3,
c: 0.2,
d: 1.1,
e: 1.0,
f: 1.0,
scale: 100,
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
hue: 180,
pulse: 1.08
};
// Generate points
let points = [];
const maxPoints = 1000 * params.density;
function generatePoints() {
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
for (let i = 0; i < maxPoints; i++) {
points.push({
x: centerX + (Math.random() - 0.5) * 200,
y: centerY + (Math.random() - 0.5) * 200,
vx: 0,
vy: 0,
life: 0,
size: 1 + Math.random() * 2 * params.complexity
});
}
}
generatePoints();
// Animation
function animate() {
// Dim background for glow effect
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update parameters based on pulse
const pulseVariation = (Math.random() * 0.05 + 0.95) * params.pulse;
const attractScale = params.scale * pulseVariation;
const motionScale = params.motion * pulseVariation;
// Draw and update points
for (let i = 0; i < points.length; i++) {
const p = points[i];
p.life += (0.01 * params.lifespan);
// Strange attractor equations
const x = p.x - canvas.width/2;
const y = p.y - canvas.height/2;
const xn = Math.sin(params.a * y) - Math.cos(params.b * x);
const yn = Math.sin(params.c * x) - Math.cos(params.d * y);
p.vx = xn * attractScale * motionScale;
p.vy = yn * attractScale * motionScale;
// Apply velocity with some damping
p.x += p.vx * (0.01 + 0.01 * params.motion);
p.y += p.vy * (0.01 + 0.01 * params.motion);
// Calculate size based on life and complexity
const size = p.size * (0.5 + 0.5 * Math.sin(p.life * 2 * Math.PI * params.complexity));
// Draw with dryness-inspired monochrome palette
const alpha = 0.2 + 0.8 * Math.sin(p.life * 2 * Math.PI * params.connectedness);
const brightness = 10 + 90 * (1 - params.dryness) + 40 * Math.sin(p.life * 2);
ctx.fillStyle = `rgba(${brightness}, ${brightness}, ${brightness}, ${alpha})`;
ctx.beginPath();
ctx.arc(p.x, p.y, size, 0, Math.PI * 2);
ctx.fill();
// Occasionally reset points to keep things alive
if (Math.random() < 0.001 * params.lifespan) {
p.x = canvas.width/2 + (Math.random() - 0.5) * 200;
p.y = canvas.height/2 + (Math.random() - 0.5) * 200;
p.life = 0;
}
}
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>