birth: Circuit Bloom in Static

This commit is contained in:
motd_admin 2026-04-12 09:47:18 +00:00
parent 95fd778f35
commit 40b037654b

174
index.html Normal file
View file

@ -0,0 +1,174 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neurameba Cellular Oasis</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
color: #f0f0f0;
font-family: 'Courier New', monospace;
}
#attribution {
position: absolute;
bottom: 20px;
left: 20px;
font-size: 10px;
opacity: 0.5;
z-index: 100;
}
canvas {
display: block;
}
</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();
// Configuration based on parameters
const config = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
tone: { dryness: 0.9, curiosity: 0.1 },
pulse: { avg: 1.11, min: 0.95, max: 1.30 }
};
const gridSize = Math.floor(40 + config.density * 40);
const cellSize = Math.min(15, Math.max(5, 20 - config.complexity * 10));
const rows = Math.ceil(canvas.height / cellSize);
const cols = Math.ceil(canvas.width / cellSize);
// Initialize grid
let grid = Array(rows).fill().map(() =>
Array(cols).fill().map(() => ({
state: Math.random() > 0.7 ? 1 : 0,
nextState: 0,
age: 0,
energy: Math.random() * 0.5 + 0.3,
color: `hsl(0, 0%, ${50 + Math.random() * 20}%)`
}))
);
// Ruleset variations based on connectedness
const rules = [
// Rule 1: Low connectedness (less predictable)
(cell, neighbors) => {
const alive = cell.state === 1;
const sum = neighbors.reduce((s, n) => s + n.state, 0);
if (alive) {
return sum >= 2 && sum <= 4 ? 1 : 0;
} else {
return sum === 3 ? 1 : 0;
}
},
// Rule 2: High connectedness (more networked)
(cell, neighbors) => {
const alive = cell.state === 1;
const sum = neighbors.reduce((s, n) => s + n.state, 0);
if (alive) {
return sum >= 3 && sum <= 5 ? 1 : 0;
} else {
return sum === 4 ? 1 : 0;
}
}
];
function updateGrid() {
const rule = rules[Math.floor(config.connectedness)];
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
const cell = grid[y][x];
const neighbors = [];
// Get 8 neighbors with toroidal wrapping
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;
neighbors.push(grid[ny][nx]);
}
}
// Apply rule
cell.nextState = rule(cell, neighbors);
// Update energy and color based on complexity
cell.energy = Math.min(1, cell.energy + (Math.random() - 0.5) * 0.1 * config.complexity);
const hue = 180 + (cell.energy * 60);
cell.color = `hsl(${hue}, 30%, ${50 + cell.energy * 20}%)`;
}
}
// Apply next state
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
grid[y][x].state = grid[y][x].nextState;
grid[y][x].age += config.lifespan * 0.1;
}
}
}
function drawGrid() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
const cell = grid[y][x];
if (cell.state === 1) {
const size = cellSize * 0.8;
const px = x * cellSize + (cellSize - size) / 2;
const py = y * cellSize + (cellSize - size) / 2;
// Draw cell with pulse animation
const pulse = 1 + (Math.sin(Date.now() * 0.001 * config.pulse.avg) * 0.1);
ctx.fillStyle = cell.color;
if (config.tone.dryness > 0.8) {
ctx.fillStyle = 'hsl(0, 0%, 90%)';
}
if (config.motion < 0.3) {
// Static blocks
ctx.fillRect(px, py, size * pulse, size);
} else {
// Flowing cells
ctx.beginPath();
ctx.arc(px + size/2, py + size/2, size/2 * pulse, 0, Math.PI * 2);
ctx.fill();
}
}
}
}
}
function animate() {
updateGrid();
drawGrid();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>