birth: Chemical Bloom in Static

This commit is contained in:
motd_admin 2026-05-30 21:47:17 +00:00
parent 9bbbbf6092
commit a65477cc28

137
index.html Normal file
View file

@ -0,0 +1,137 @@
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chemical Bloom</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#info {
position: absolute;
bottom: 10px;
left: 10px;
color: #555;
font-size: 10px;
z-index: 100;
}
</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');
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
// Reaction-diffusion parameters influenced by Tone parameters
const params = {
feed: 0.055, // Slight feed (curiosity)
kill: 0.062, // Moderate kill (dryness)
diffA: 1.0, // High diffusion
diffB: 0.5, // Moderate diffusion
timeStep: 0.1,
brightness: 0.9, // High energy from energy=324.5
contrast: 0.7,
pulse: 0.39 // Dynamic pulse affecting reactions
};
// Grid setup
const size = 64;
const grid = Array(size).fill().map(() => Array(size).fill(0));
const next = Array(size).fill().map(() => Array(size).fill(0));
// Initialize with sparse density
function init() {
for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
grid[i][j] = (Math.random() < params.feed * 0.5) ? 1 : 0;
}
}
// Add some dense spots (connectedness)
for (let k = 0; k < 120; k++) {
const i = Math.floor(Math.random() * size);
const j = Math.floor(Math.random() * size);
grid[i][j] = 1;
}
}
init();
// Reaction-diffusion simulation
function update() {
const pulseEffect = (0.3 + Math.sin(Date.now() * 0.001 * params.pulse) * 0.7) * 0.5;
for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
// Boundary check
const x = (i + size) % size;
const y = (j + size) % size;
// Concentrations
const a = grid[x][y];
const b = next[x][y];
// Calculate neighbors (connectedness)
let sum = 0;
for (let di = -1; di <= 1; di++) {
for (let dj = -1; dj <= 1; dj++) {
if (di === 0 && dj === 0) continue;
const nx = (x + di + size) % size;
const ny = (y + dj + size) % size;
sum += grid[nx][ny];
}
}
const neighbors = sum / 8;
// Reaction (Gray-Scott)
const reaction = a * b * b;
const newA = a + (params.diffA * neighbors - reaction) * params.timeStep;
const newB = b + (params.diffB * neighbors + reaction - (params.kill + params.feed + pulseEffect) * b) * params.timeStep;
next[x][y] = Math.max(0, Math.min(1, newB));
// Visualization (high energy)
const intensity = Math.min(1, newB * params.brightness);
ctx.fillStyle = `rgba(255, 255, 255, ${intensity * params.contrast})`;
ctx.fillRect(
(i / size) * canvas.width,
(j / size) * canvas.height,
canvas.width / size,
canvas.height / size
);
}
}
// Swap grids
const temp = grid;
grid = next;
next = temp;
next.fill().map(() => Array(size).fill(0));
}
function animate() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
update();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```