birth: Quivering Gel Membrane

This commit is contained in:
motd_admin 2026-11-02 10:21:22 +00:00
parent f93be451ca
commit de4ba88ead

158
index.html Normal file
View file

@ -0,0 +1,158 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quivering Membrane</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
color: #444;
font-size: 10px;
pointer-events: none;
}
</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 input
const motion = 0.5;
const density = 0.5;
const complexity = 0.5;
const connectedness = 0.5;
const lifespan = 0.5;
// Cellular automata settings
const cellSize = 8;
const cols = Math.floor(canvas.width / cellSize);
const rows = Math.floor(canvas.height / cellSize);
let grid = createGrid();
let nextGrid = createGrid();
// Mood-based palette
const dryness = 0.9;
const curiosity = 0.7;
const playfulness = 0.1;
const baseHue = 170 + curiosity * 60;
const hueVariation = playfulness * 30;
const saturation = dryness > 0.8 ? 0 : 100;
const lightness = dryness > 0.8 ? 10 : 90;
function createGrid() {
const grid = new Array(rows);
for (let i = 0; i < rows; i++) {
grid[i] = new Array(cols);
for (let j = 0; j < cols; j++) {
// Initial state based on density
grid[i][j] = Math.random() > density ? 0 : 1;
}
}
return grid;
}
function countNeighbors(x, y) {
let count = 0;
for (let i = -1; i <= 1; i++) {
for (let j = -1; j <= 1; j++) {
if (i === 0 && j === 0) continue;
const nx = (x + i + rows) % rows;
const ny = (y + j + cols) % cols;
count += grid[nx][ny];
}
}
return count;
}
function updateGrid() {
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
const neighbors = countNeighbors(i, j);
const current = grid[i][j];
// Cellular automata rules with some randomness based on motion
if (current === 1) {
if (neighbors < 2 || neighbors > 3) {
nextGrid[i][j] = 0;
} else {
nextGrid[i][j] = 1;
}
} else {
if (neighbors === 3) {
nextGrid[i][j] = 1;
} else {
nextGrid[i][j] = 0;
}
}
// Add some motion-based variation
if (Math.random() < motion * 0.1) {
nextGrid[i][j] = Math.random() > 0.7 ? 1 : 0;
}
}
}
// Swap grids
[grid, nextGrid] = [nextGrid, grid];
}
function drawGrid() {
ctx.fillStyle = `hsl(${baseHue + (Math.random() * hueVariation - hueVariation/2)}, ${saturation}%, ${lightness}%)`;
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (grid[i][j] === 1) {
const x = j * cellSize;
const y = i * cellSize;
ctx.fillRect(x, y, cellSize, cellSize);
// Add subtle complexity by varying opacity
const opacity = 0.3 + (Math.random() * complexity * 0.7);
ctx.globalAlpha = opacity;
ctx.fillRect(x, y, cellSize, cellSize);
}
}
}
// Reset alpha
ctx.globalAlpha = 1.0;
}
function animate() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
updateGrid();
drawGrid();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>