birth: Fractal Roots in Motion
This commit is contained in:
parent
bb48cb5aea
commit
c363810fba
1 changed files with 225 additions and 0 deletions
225
index.html
Normal file
225
index.html
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
<!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: #0a0a0a;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
color: #333;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
</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();
|
||||
|
||||
// Parameters derived from abstract input
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: 1.07,
|
||||
tone: {
|
||||
dryness: 0.9,
|
||||
playfulness: 0.1
|
||||
}
|
||||
};
|
||||
|
||||
// State variables
|
||||
const branches = [];
|
||||
const maxBranches = 200;
|
||||
const branchLength = 50 + Math.random() * 50;
|
||||
const branchWidth = 1 + params.density * 2;
|
||||
const branchCount = Math.floor(10 + params.complexity * 30);
|
||||
const branchDecay = 0.95 + (1 - params.lifespan) * 0.05;
|
||||
|
||||
// Color palette based on tone
|
||||
const colors = {
|
||||
dryness: [0.15, 0.15, 0.15], // muted monochrome
|
||||
playfulness: [0.8, 0.7, 0.2] // soft yellow/beige
|
||||
};
|
||||
const bgColor = '#0a0a0a';
|
||||
const fgColor = [
|
||||
colors.dryness[0] * 0.8,
|
||||
colors.dryness[1] * 0.8,
|
||||
colors.dryness[2] * 0.8
|
||||
];
|
||||
|
||||
// Initialize branches
|
||||
function initBranches() {
|
||||
branches.length = 0;
|
||||
const centerX = canvas.width / 2;
|
||||
const centerY = canvas.height / 2;
|
||||
|
||||
for (let i = 0; i < branchCount; i++) {
|
||||
branches.push({
|
||||
x: centerX,
|
||||
y: centerY,
|
||||
length: branchLength * (0.5 + Math.random()),
|
||||
angle: (Math.PI * 2) * (i / branchCount),
|
||||
width: branchWidth * (0.5 + Math.random()),
|
||||
color: [
|
||||
fgColor[0] * (0.7 + Math.random() * 0.3),
|
||||
fgColor[1] * (0.7 + Math.random() * 0.3),
|
||||
fgColor[2] * (0.7 + Math.random() * 0.3)
|
||||
],
|
||||
depth: 0,
|
||||
children: [],
|
||||
alive: true
|
||||
});
|
||||
}
|
||||
|
||||
// Create recursive structure
|
||||
for (let i = 0; i < branches.length; i++) {
|
||||
const branch = branches[i];
|
||||
if (Math.random() > 0.7) {
|
||||
const childCount = Math.floor(1 + Math.random() * 3 * params.connectedness);
|
||||
for (let j = 0; j < childCount; j++) {
|
||||
branch.children.push({
|
||||
x: branch.x,
|
||||
y: branch.y,
|
||||
length: branch.length * (0.3 + 0.5 * Math.random()),
|
||||
angle: branch.angle + (Math.random() - 0.5) * Math.PI * 0.5,
|
||||
width: branch.width * (0.4 + 0.3 * Math.random()),
|
||||
color: [
|
||||
branch.color[0] * 0.8,
|
||||
branch.color[1] * 0.8,
|
||||
branch.color[2] * 0.8
|
||||
],
|
||||
depth: branch.depth + 1,
|
||||
children: [],
|
||||
alive: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a branch
|
||||
function drawBranch(branch) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(branch.x, branch.y);
|
||||
|
||||
const endX = branch.x + Math.cos(branch.angle) * branch.length;
|
||||
const endY = branch.y + Math.sin(branch.angle) * branch.length;
|
||||
ctx.lineTo(endX, endY);
|
||||
|
||||
ctx.lineWidth = branch.width;
|
||||
ctx.strokeStyle = `rgba(${branch.color[0] * 255}, ${branch.color[1] * 255}, ${branch.color[2] * 255}, ${branch.depth / 10})`;
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Update branches - recursive growth/decay
|
||||
function updateBranches() {
|
||||
for (let i = 0; i < branches.length; i++) {
|
||||
const branch = branches[i];
|
||||
|
||||
if (!branch.alive) continue;
|
||||
|
||||
// Apply motion (subtle sway)
|
||||
branch.angle += (Math.random() - 0.5) * 0.01 * params.motion;
|
||||
|
||||
// Update children recursively
|
||||
for (let j = 0; j < branch.children.length; j++) {
|
||||
const child = branch.children[j];
|
||||
child.x = branch.x;
|
||||
child.y = branch.y;
|
||||
child.angle = branch.angle + Math.random() * 0.1 - 0.05;
|
||||
|
||||
// Fade with depth/decay
|
||||
child.width *= branchDecay;
|
||||
if (child.width < 0.1) {
|
||||
child.alive = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove dead children
|
||||
branch.children = branch.children.filter(child => child.alive);
|
||||
|
||||
// If no children and too thin, consider dying
|
||||
if (branch.children.length === 0 && branch.width < 0.3) {
|
||||
branch.alive = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Occasionally add new primary branches based on density
|
||||
if (branches.length < maxBranches && Math.random() < 0.05 * params.density * params.complexity) {
|
||||
branches.push({
|
||||
x: canvas.width / 2,
|
||||
y: canvas.height / 2,
|
||||
length: branchLength * (0.5 + Math.random()),
|
||||
angle: Math.random() * Math.PI * 2,
|
||||
width: branchWidth * (0.5 + Math.random()),
|
||||
color: [
|
||||
fgColor[0] * (0.7 + Math.random() * 0.3),
|
||||
fgColor[1] * (0.7 + Math.random() * 0.3),
|
||||
fgColor[2] * (0.7 + Math.random() * 0.3)
|
||||
],
|
||||
depth: 0,
|
||||
children: [],
|
||||
alive: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Draw all branches recursively
|
||||
function drawAllBranches(branches) {
|
||||
for (let i = 0; i < branches.length; i++) {
|
||||
const branch = branches[i];
|
||||
if (branch.alive) {
|
||||
drawBranch(branch);
|
||||
drawAllBranches(branch.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
// Fade background slightly
|
||||
ctx.fillStyle = `rgba(0, 0, 0, ${0.1 * params.lifespan})`;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
updateBranches();
|
||||
drawAllBranches(branches);
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Start with initial structure
|
||||
initBranches();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue