birth: Pulsing Cellular Whispers

This commit is contained in:
motd_admin 2026-03-30 21:47:16 +00:00
parent e87b5cff1f
commit b4783ac043

161
index.html Normal file
View file

@ -0,0 +1,161 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quiver Cell</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
background: #0a0a0a;
}
#info {
position: absolute;
bottom: 20px;
color: #4a4a4a;
font-family: 'Courier New', monospace;
font-size: 11px;
text-align: center;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="info">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 mapped from input
const params = {
motion: 0.486,
density: 0.487,
complexity: 0.466,
connectedness: 0.658,
lifespan: 0.457,
pulse: { avg: 0.57, min: 0.30, max: 2.00 },
tone: { dryness: 0.90, curiosity: 0.10 }
};
// Cell state and grid
const cellSize = 8 + Math.floor(params.density * 6);
const cols = Math.floor(canvas.width / cellSize);
const rows = Math.floor(canvas.height / cellSize);
let grid = new Array(cols * rows).fill(0);
let nextGrid = new Array(cols * rows).fill(0);
// Initialize with higher density in center
for (let i = 0; i < grid.length; i++) {
const x = i % cols;
const y = Math.floor(i / cols);
const dist = Math.sqrt(
Math.pow(x - cols/2, 2) +
Math.pow(y - rows/2, 2)
);
if (dist < Math.min(cols, rows) * 0.3 && Math.random() < params.density * 0.7) {
grid[i] = Math.random() < 0.3 ? 1 : 0;
}
}
// CA ruleset with connectedness influencing spread
function updateGrid() {
const spread = 0.3 + params.connectedness * 0.4;
for (let i = 0; i < grid.length; i++) {
const x = i % cols;
const y = Math.floor(i / cols);
let neighbors = 0;
// Moore neighborhood
for (let dx = -1; dx <= 1; dx++) {
for (let dy = -1; dy <= 1; dy++) {
if (dx === 0 && dy === 0) continue;
const nx = (x + dx + cols) % cols;
const ny = (y + dy + rows) % rows;
neighbors += grid[ny * cols + nx];
}
}
// Complexity affects survival chance
const survival = params.complexity * 0.7 + 0.3;
nextGrid[i] = 0;
if (grid[i] === 1) {
// Survival if enough neighbors (but less for complexity)
if (neighbors >= 2 && neighbors <= 4 && Math.random() < survival) {
nextGrid[i] = 1;
}
} else {
// Birth if exactly 3 neighbors and connected
if (neighbors === 3 && Math.random() < spread) {
nextGrid[i] = 1;
}
}
}
[grid, nextGrid] = [nextGrid, grid];
}
// Drawing with dryness-inspired monochrome
function drawGrid() {
ctx.fillStyle = 'rgba(20, 20, 20, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
const pulseScale = params.pulse.avg * 2;
const baseSize = cellSize * 0.8;
const lifeScale = params.lifespan * 0.8 + 0.2;
for (let i = 0; i < grid.length; i++) {
if (grid[i] === 1) {
const x = (i % cols) * cellSize + cellSize/2;
const y = Math.floor(i / cols) * cellSize + cellSize/2;
// Age-based fading for ephemeral feel
const age = 1 - (Math.random() * params.lifespan * 0.7);
const alpha = Math.max(0.1, age * lifeScale);
ctx.fillStyle = `rgba(240, 240, 240, ${alpha})`;
// Slight variation in size based on age
const size = baseSize * (0.8 + age * 0.4) * pulseScale;
ctx.beginPath();
ctx.arc(x, y, size, 0, Math.PI * 2);
ctx.fill();
}
}
}
// Animation loop with motion variation
let time = 0;
function animate() {
const motionFactor = params.motion * 0.05;
const pulseFactor = (Math.sin(time * 0.0003) * 0.5 + 0.5) *
(params.pulse.max - params.pulse.min) + params.pulse.min;
time += 1 * pulseFactor;
updateGrid();
drawGrid();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>