birth: Whispering Fractal Veins
This commit is contained in:
parent
771fbc7db1
commit
b370eafc6f
1 changed files with 192 additions and 0 deletions
192
index.html
Normal file
192
index.html
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Fractal Nebula</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
.attribution {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
color: #444;
|
||||
font-family: monospace;
|
||||
font-size: 10px;
|
||||
z-index: 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');
|
||||
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Fractal parameters
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: 1.06,
|
||||
tone: {
|
||||
anger: 0.0,
|
||||
sadness: 0.0,
|
||||
curiosity: 0.1,
|
||||
dryness: 0.9,
|
||||
playfulness: 0.0,
|
||||
tension: 0.0
|
||||
}
|
||||
};
|
||||
|
||||
// Color palette (monochrome with slight teal variation)
|
||||
const palette = {
|
||||
bg: '#0a0a0a',
|
||||
base: '#1a1a1a',
|
||||
line: '#4a4a4a',
|
||||
highlight: '#7a7a7a'
|
||||
};
|
||||
if (params.tone.curiosity > 0.5) {
|
||||
palette.line = `hsl(180, 30%, ${50 + params.tone.curiosity * 20}%)`;
|
||||
palette.highlight = `hsl(180, 60%, ${70 + params.tone.curiosity * 20}%)`;
|
||||
}
|
||||
|
||||
// Fractal tree parameters
|
||||
const branchCount = Math.floor(3 + params.complexity * 5);
|
||||
const depth = Math.floor(3 + params.complexity * 7);
|
||||
const maxWidth = 1 + params.connectedness * 4;
|
||||
const branchVariation = 0.7 + params.motion * 0.3;
|
||||
const angleVariation = 0.3 + params.motion * 0.4;
|
||||
|
||||
// Tree node
|
||||
class TreeNode {
|
||||
constructor(x, y, angle, width, depth) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.angle = angle;
|
||||
this.width = width;
|
||||
this.depth = depth;
|
||||
this.maxDepth = depth;
|
||||
this.children = [];
|
||||
this.lifespan = 0;
|
||||
this.maxLifespan = 100 + Math.random() * 100 * params.lifespan;
|
||||
}
|
||||
|
||||
grow() {
|
||||
if (this.depth <= 0) return;
|
||||
|
||||
const branchLength = 20 / (1 + this.depth * 0.5);
|
||||
const newWidth = this.width * 0.7;
|
||||
|
||||
// Branch directions with variation
|
||||
const directions = [];
|
||||
for (let i = 0; i < branchCount; i++) {
|
||||
const angleOffset = (Math.random() - 0.5) * angleVariation * Math.PI;
|
||||
directions.push(this.angle + angleOffset);
|
||||
}
|
||||
|
||||
directions.forEach((newAngle, i) => {
|
||||
const rad = newAngle;
|
||||
const newX = this.x + Math.cos(rad) * branchLength;
|
||||
const newY = this.y + Math.sin(rad) * branchLength;
|
||||
|
||||
const child = new TreeNode(
|
||||
newX,
|
||||
newY,
|
||||
newAngle,
|
||||
newWidth,
|
||||
this.depth - 1
|
||||
);
|
||||
|
||||
// Some branches can loop back toward parent
|
||||
if (Math.random() < params.connectedness * 0.3 && this.depth > 1) {
|
||||
child.x = this.x + Math.cos(newAngle + Math.PI * 0.7) * branchLength * 0.4;
|
||||
child.y = this.y + Math.sin(newAngle + Math.PI * 0.7) * branchLength * 0.4;
|
||||
}
|
||||
|
||||
this.children.push(child);
|
||||
});
|
||||
}
|
||||
|
||||
update() {
|
||||
this.lifespan++;
|
||||
this.children.forEach(child => child.update());
|
||||
}
|
||||
|
||||
draw() {
|
||||
ctx.strokeStyle = palette.line;
|
||||
ctx.lineWidth = this.width * (1 - this.lifespan / this.maxLifespan);
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.x, this.y);
|
||||
ctx.lineTo(
|
||||
this.x + Math.cos(this.angle) * 20 / (1 + this.depth * 0.5),
|
||||
this.y + Math.sin(this.angle) * 20 / (1 + this.depth * 0.5)
|
||||
);
|
||||
ctx.stroke();
|
||||
|
||||
this.children.forEach(child => child.draw());
|
||||
}
|
||||
}
|
||||
|
||||
// Root nodes
|
||||
const roots = [];
|
||||
const rootCount = 3 + Math.floor(params.density * 8);
|
||||
|
||||
for (let i = 0; i < rootCount; i++) {
|
||||
roots.push(new TreeNode(
|
||||
canvas.width * 0.3 + Math.random() * canvas.width * 0.4,
|
||||
canvas.height * 0.3 + Math.random() * canvas.height * 0.4,
|
||||
Math.random() * Math.PI * 2,
|
||||
maxWidth,
|
||||
depth
|
||||
));
|
||||
}
|
||||
|
||||
// Main animation
|
||||
function animate() {
|
||||
// Fade effect for low lifespan
|
||||
if (params.lifespan < 0.3) {
|
||||
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
}
|
||||
|
||||
ctx.fillStyle = palette.bg;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
roots.forEach(root => {
|
||||
if (Math.random() < params.motion * 0.1) {
|
||||
root.grow();
|
||||
}
|
||||
root.update();
|
||||
root.draw();
|
||||
});
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue