birth: Teal Echoes in Silent Grid

This commit is contained in:
motd_admin 2026-09-26 18:21:18 +00:00
parent ee374f7a78
commit e12f0f24e7

115
index.html Normal file
View file

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neurameba Cellular Automata</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #000;
color: #fff;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
font-size: 10px;
opacity: 0.5;
}
</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();
// Cellular automata parameters
const cellSize = 8;
const cols = Math.floor(canvas.width / cellSize);
const rows = Math.floor(canvas.height / cellSize);
let grid = new Array(rows).fill().map(() => new Array(cols).fill(0));
let nextGrid = new Array(rows).fill().map(() => new Array(cols).fill(0));
// Initialize with sparse density
function initializeGrid() {
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
grid[i][j] = Math.random() < 0.3 ? 1 : 0;
}
}
}
initializeGrid();
// Cellular automata rules (Game of Life variant with reduced complexity)
function updateGrid() {
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
let neighbors = 0;
for (let di = -1; di <= 1; di++) {
for (let dj = -1; dj <= 1; dj++) {
if (di === 0 && dj === 0) continue;
const ni = i + di;
const nj = j + dj;
if (ni >= 0 && ni < rows && nj >= 0 && nj < cols) {
neighbors += grid[ni][nj];
}
}
}
// Reduced complexity rules
if (grid[i][j] === 1) {
nextGrid[i][j] = neighbors >= 2 && neighbors <= 3 ? 1 : 0;
} else {
nextGrid[i][j] = neighbors === 3 ? 1 : 0;
}
}
}
// Swap grids
[grid, nextGrid] = [nextGrid, grid];
}
// Drawing functions
function drawCell(i, j, size) {
ctx.fillStyle = `hsl(170, 80%, ${50 + Math.random() * 20}%)`;
ctx.fillRect(j * size, i * size, size, size);
}
function drawGrid() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (grid[i][j] === 1) {
drawCell(i, j, cellSize);
}
}
}
}
// Animation loop
function animate() {
updateGrid();
drawGrid();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>