birth: Dry Cells in Motion

This commit is contained in:
motd_admin 2026-10-15 10:21:21 +00:00
parent b60f177878
commit b473645aab

163
index.html Normal file
View file

@ -0,0 +1,163 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dry Cellular Pulse</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
color: #666;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: flex-start;
padding: 20px;
box-sizing: border-box;
}
canvas {
display: block;
}
.info {
margin-top: 20px;
font-size: 11px;
opacity: 0.5;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="info">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 input
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: {
avg: 1.08,
min: 1.05,
max: 1.1
},
tone: {
anger: 0,
sadness: 0,
curiosity: 0.3,
dryness: 0.8,
playfulness: 0,
tension: 0
}
};
// Cellular Automata parameters
const cellSize = 8;
const cols = Math.floor(canvas.width / cellSize);
const rows = Math.floor(canvas.height / cellSize);
// Initialize grid
let grid = Array(rows).fill().map(() => Array(cols).fill(0));
let nextGrid = Array(rows).fill().map(() => Array(cols).fill(0));
// Set initial population based on density
function initializeGrid() {
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
grid[y][x] = Math.random() < params.density ? 1 : 0;
}
}
}
// Rules for cellular automata (Game of Life-like)
function updateGrid() {
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
let neighbors = countNeighbors(x, y);
if (grid[y][x] === 1) {
// Survival condition
nextGrid[y][x] = neighbors >= 2 && neighbors <= 3 ? 1 : 0;
} else {
// Birth condition
nextGrid[y][x] = neighbors === 3 ? 1 : 0;
}
}
}
// Swap grids
[grid, nextGrid] = [nextGrid, grid];
}
function countNeighbors(x, y) {
let count = 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 + cols) % cols;
const ny = (y + dy + rows) % rows;
count += grid[ny][nx];
}
}
return count;
}
// Draw function
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Calculate pulse effect
const pulse = params.pulse.avg;
const time = Date.now() * 0.001 * pulse;
// Draw cells
ctx.strokeStyle = `rgba(220, 220, 220, 0.8)`;
ctx.lineWidth = Math.sin(time * 0.5) * 0.5 + 0.5;
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
if (grid[y][x] === 1) {
const size = (Math.sin(time * 0.3 + x * 0.1 + y * 0.1) * 0.5 + 0.5) * cellSize * 0.8;
ctx.beginPath();
ctx.arc(
x * cellSize + cellSize/2,
y * cellSize + cellSize/2,
size,
0,
Math.PI * 2
);
ctx.stroke();
}
}
}
}
// Animation loop
function animate() {
updateGrid();
draw();
requestAnimationFrame(animate);
}
// Initialize and start
initializeGrid();
animate();
</script>
</body>
</html>