birth: Fractal Breath of Motion
This commit is contained in:
parent
83ac7523f3
commit
413dfdfe0c
1 changed files with 154 additions and 0 deletions
154
index.html
Normal file
154
index.html
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Fractal Bloom</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: #4a4a4a;
|
||||||
|
font-size: 10px;
|
||||||
|
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 adjusted by input
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: 1.07
|
||||||
|
};
|
||||||
|
|
||||||
|
// Tone palette
|
||||||
|
const palette = {
|
||||||
|
base: '#4a4a4a',
|
||||||
|
accent: '#2a9d8f',
|
||||||
|
dryAccent: '#ffffff',
|
||||||
|
playAccent: '#ffb347'
|
||||||
|
};
|
||||||
|
|
||||||
|
let time = 0;
|
||||||
|
let points = [];
|
||||||
|
const maxPoints = 120;
|
||||||
|
|
||||||
|
function initPoints() {
|
||||||
|
points = [];
|
||||||
|
for (let i = 0; i < maxPoints * params.density; i++) {
|
||||||
|
points.push({
|
||||||
|
x: Math.random() * canvas.width,
|
||||||
|
y: Math.random() * canvas.height,
|
||||||
|
size: Math.random() * 3 + 1,
|
||||||
|
color: params.complexity > 0.7 ? palette.accent : palette.dryAccent,
|
||||||
|
life: 0,
|
||||||
|
maxLife: 100 + Math.random() * 200
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawFractalBranch(x, y, angle, depth, size, maxDepth) {
|
||||||
|
if (depth > maxDepth) return;
|
||||||
|
|
||||||
|
const length = size * (0.7 + 0.3 * Math.sin(time * 0.01));
|
||||||
|
const endX = x + Math.cos(angle) * length;
|
||||||
|
const endY = y + Math.sin(angle) * length;
|
||||||
|
|
||||||
|
const fade = depth / maxDepth;
|
||||||
|
const color = `rgba(${Math.floor(100 + 155 * fade)}, ${Math.floor(180 + 75 * fade)}, ${Math.floor(160 + 20 * fade)}, 0.8)`;
|
||||||
|
ctx.strokeStyle = color;
|
||||||
|
ctx.lineWidth = size * (1 - fade);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x, y);
|
||||||
|
ctx.lineTo(endX, endY);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
const branches = 2 + Math.floor(params.connectedness * 3);
|
||||||
|
const angleSpread = Math.PI * (0.3 + 0.4 * params.motion);
|
||||||
|
|
||||||
|
for (let i = 0; i < branches; i++) {
|
||||||
|
const newAngle = angle + (Math.random() - 0.5) * angleSpread;
|
||||||
|
drawFractalBranch(
|
||||||
|
endX, endY, newAngle, depth + 1, size * (0.6 + 0.2 * Math.random()),
|
||||||
|
maxDepth + (params.complexity - 0.5) * 2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePoints() {
|
||||||
|
points.forEach(p => {
|
||||||
|
p.life++;
|
||||||
|
if (p.life > p.maxLife) {
|
||||||
|
p.x = Math.random() * canvas.width;
|
||||||
|
p.y = Math.random() * canvas.height;
|
||||||
|
p.life = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Fractal center point moves with pulse
|
||||||
|
const centerX = canvas.width / 2 + Math.sin(time * 0.02) * 50 * params.pulse;
|
||||||
|
const centerY = canvas.height / 2 + Math.cos(time * 0.03) * 30 * params.pulse;
|
||||||
|
|
||||||
|
// Draw fractal branches
|
||||||
|
const maxDepth = 4 + Math.floor(params.complexity * 4);
|
||||||
|
drawFractalBranch(
|
||||||
|
centerX, centerY,
|
||||||
|
time * 0.01, 0,
|
||||||
|
5 + params.motion * 5,
|
||||||
|
maxDepth
|
||||||
|
);
|
||||||
|
|
||||||
|
// Draw scattered points
|
||||||
|
points.forEach(p => {
|
||||||
|
if (params.density > 0.8 || p.life % 30 < 15) {
|
||||||
|
ctx.fillStyle = p.color;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(p.x, p.y, p.size * (p.life / p.maxLife), 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
time += 0.02 + 0.01 * params.motion;
|
||||||
|
updatePoints();
|
||||||
|
requestAnimationFrame(draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
initPoints();
|
||||||
|
draw();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue