birth: Dry Cell Birth Cycle

This commit is contained in:
motd_admin 2026-09-14 18:21:20 +00:00
parent e39b692fdc
commit 10ec1e709a

154
index.html Normal file
View file

@ -0,0 +1,154 @@
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dry Cellular Bloom</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: 10px;
color: #555;
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');
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Parameters derived from abstract values
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: 1.07,
tone: {
anger: 0,
sadness: 0,
curiosity: 0.1,
dryness: 0.9,
playfulness: 0,
tension: 0
}
};
// Dry monochrome palette (high dryness)
const palette = {
bg: '#0a0a0a',
cell: '#444444',
live: '#ffffff',
dead: '#111111'
};
// Cellular automata grid
const gridSize = Math.floor(40 * params.density) + 10;
const grid = Array.from({length: gridSize}, () =>
Array.from({length: Math.floor(gridSize * (canvas.width/canvas.height))}, () =>
Math.random() > 0.7 ? 1 : 0
)
);
let frameCount = 0;
function drawGrid() {
const cellWidth = canvas.width / grid[0].length;
const cellHeight = canvas.height / grid.length;
// Update cells based on Moore neighborhood
const newGrid = grid.map(arr => [...arr]);
for (let y = 0; y < grid.length; y++) {
for (let x = 0; x < grid[y].length; x++) {
let neighbors = 0;
for (let dy = -1; dy <= 1; dy++) {
for (let dx = -1; dx <= 1; dx++) {
if (dx === 0 && dy === 0) continue;
const nx = (x + dx + grid[y].length) % grid[y].length;
const ny = (y + dy + grid.length) % grid.length;
neighbors += grid[ny][nx];
}
}
// High complexity adds more rules
const ruleVariation = params.complexity * 0.3;
const alive = grid[y][x] === 1;
if (alive) {
// Survival with variation
newGrid[y][x] = neighbors >= 2 + ruleVariation * 3 &&
neighbors <= 3 + ruleVariation * 3 ? 1 : 0;
} else {
// Birth with variation
newGrid[y][x] = neighbors >= 3 - ruleVariation * 2 &&
neighbors <= 3 + ruleVariation * 2 ? 1 : 0;
}
}
}
grid.length = 0;
grid.push(...newGrid);
// Draw cells with low opacity for dryness effect
ctx.fillStyle = palette.cell;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = palette.live;
for (let y = 0; y < grid.length; y++) {
for (let x = 0; x < grid[y].length; x++) {
if (grid[y][x] === 1) {
const size = cellWidth * (0.5 + 0.5 * Math.sin(frameCount * 0.05 + x * 0.1));
ctx.globalAlpha = 0.1 + 0.9 * (Math.sin(frameCount * 0.03 + x * y * 0.001) * 0.5 + 0.5);
ctx.beginPath();
ctx.arc(
x * cellWidth + cellWidth/2,
y * cellHeight + cellHeight/2,
size/2,
0,
Math.PI * 2
);
ctx.fill();
}
}
}
ctx.globalAlpha = 1;
frameCount++;
}
function animate() {
drawGrid();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```