whispering-recursive-tendri.../index.html

147 lines
No EOL
4.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recursive Tendrils</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
display: block;
}
.attribution {
position: absolute;
bottom: 20px;
color: #555;
font-family: monospace;
font-size: 10px;
text-align: center;
width: 100%;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="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();
// Parameters derived from abstract input
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.1, min: 1.0, max: 1.3 },
tone: { dryness: 0.8, playfulness: 0.1 }
};
// Fractal system state
const fractals = [];
const maxDepth = 4;
const branchCount = 3;
const lengthBase = 20;
const angleVariation = Math.PI * 0.6;
const lengthFalloff = 0.6;
const colorBase = '#a0a0a0';
const decayRate = 0.95;
// Initialize fractals
function initFractals() {
fractals.length = 0;
const count = 50 + Math.floor(params.density * 150);
for (let i = 0; i < count; i++) {
fractals.push({
x: Math.random() * canvas.width,
y: canvas.height,
depth: 0,
length: lengthBase * (0.5 + Math.random() * 0.5),
angle: -Math.PI/2,
angleOffset: 0,
color: colorBase,
alpha: 0.8 + Math.random() * 0.2,
growth: 0,
pulse: params.pulse.avg * (0.9 + Math.random() * 0.2)
});
}
}
// Recursive fractal growth
function growFractal(x, y, depth, length, angle, parentColor, pulse) {
if (depth > maxDepth) return;
ctx.beginPath();
const hue = 0;
const saturation = 0;
const lightness = 20 + Math.sin(Date.now() * 0.001 * pulse) * 10;
const color = `hsl(${hue}, ${saturation}%, ${lightness}%)`;
ctx.strokeStyle = color;
ctx.lineWidth = 2 * (1 - depth/maxDepth);
ctx.globalAlpha = 0.7 * (1 - depth/maxDepth);
const endX = x + Math.cos(angle) * length;
const endY = y + Math.sin(angle) * length;
ctx.moveTo(x, y);
ctx.lineTo(endX, endY);
ctx.stroke();
// Branching
for (let i = 0; i < branchCount; i++) {
const newAngle = angle + (Math.random() - 0.5) * angleVariation * (1 - params.complexity);
const newLength = length * lengthFalloff * (0.7 + Math.random() * 0.3);
growFractal(endX, endY, depth + 1, newLength, newAngle, color, pulse * params.pulse.avg);
}
}
// Animation loop
function animate() {
// Clear with fade
ctx.globalAlpha = 0.05;
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.globalAlpha = 1.0;
// Update and draw fractals
fractals.forEach((f, i) => {
if (f.depth === 0) {
f.x += (Math.random() - 0.5) * params.motion * 2;
f.y -= params.motion * 0.5;
if (f.y < 0) f.y = canvas.height;
f.growth += 0.05;
if (f.growth >= 1) {
growFractal(f.x, f.y, 0, f.length, f.angle, f.color, f.pulse);
}
}
});
requestAnimationFrame(animate);
}
// Initialize and start
initFractals();
animate();
</script>
</body>
</html>