birth: Pulsing Monochrome Symbiosis

This commit is contained in:
motd_admin 2026-04-30 21:47:18 +00:00
parent 10a9d9aaa0
commit 26ababaace

160
index.html Normal file
View file

@ -0,0 +1,160 @@
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reaction-Diffusion Canvas</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 20px;
color: #555;
font-size: 12px;
text-align: center;
width: 100%;
}
</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');
// Set canvas to full window size
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
// Reaction-diffusion parameters (Gray-Scott model)
const params = {
feed: 0.052,
kill: 0.060,
diffusionA: 1.0,
diffusionB: 0.5,
timeStep: 1.0,
gridSize: 4,
decay: 0.99,
complexity: 0.54,
connectedness: 0.53,
motion: 0.52,
pulse: 0.49,
energy: 487.6
};
// Initialize grids
const grid = [];
const nextGrid = [];
const sizeX = Math.floor(canvas.width / params.gridSize);
const sizeY = Math.floor(canvas.height / params.gridSize);
// Fill with initial noise
function initGrids() {
for (let i = 0; i < sizeX; i++) {
grid[i] = new Array(sizeY);
nextGrid[i] = new Array(sizeY);
for (let j = 0; j < sizeY; j++) {
// Start with sparse, motion-sensitive patterns
const base = (Math.random() * params.motion < 0.3) ? 0.1 : 0;
grid[i][j] = base + (Math.random() * params.connectedness * 0.2);
nextGrid[i][j] = 0;
}
}
}
initGrids();
// Reaction-diffusion step
function update() {
for (let x = 1; x < sizeX - 1; x++) {
for (let y = 1; y < sizeY - 1; y++) {
const a = grid[x][y];
const b = nextGrid[x][y];
// Laplacian diffusion
const laplacianA = (grid[x-1][y] + grid[x+1][y] + grid[x][y-1] + grid[x][y+1] - 4 * a) * params.diffusionA;
const laplacianB = (nextGrid[x-1][y] + nextGrid[x+1][y] + nextGrid[x][y-1] + nextGrid[x][y+1] - 4 * b) * params.diffusionB;
// Gray-Scott reaction
const reaction = a * b * b;
const newA = a + (params.diffusionA * laplacianA) - reaction + params.feed * (1 - a);
const newB = b + (params.diffusionB * laplacianB) + reaction - (params.kill + params.feed) * b;
// Apply decay based on lifespan
nextGrid[x][y] = Math.max(0, Math.min(1,
newB * params.decay
));
// Add pulse variations
if (Math.random() < params.pulse) {
nextGrid[x][y] = Math.min(1, nextGrid[x][y] + 0.2 * params.motion);
}
}
}
// Swap grids and apply complexity variations
for (let x = 0; x < sizeX; x++) {
for (let y = 0; y < sizeY; y++) {
grid[x][y] = nextGrid[x][y];
// More intricate patterns in high complexity areas
if (Math.random() < params.complexity * 0.01) {
nextGrid[x][y] = grid[x][y] + (Math.random() - 0.5) * 0.3;
}
}
}
}
// Drawing with dryness/monochrome palette
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
const imageData = ctx.createImageData(sizeX, sizeY);
const data = imageData.data;
for (let y = 0; y < sizeY; y++) {
for (let x = 0; x < sizeX; x++) {
const val = grid[x][y];
const idx = (y * sizeX + x) * 4;
// Dry monochrome palette (high contrast)
const intensity = Math.floor(255 * val);
data[idx] = intensity;
data[idx + 1] = intensity;
data[idx + 2] = intensity;
data[idx + 3] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
ctx.imageSmoothingEnabled = false;
}
// Main animation loop
function animate() {
update();
draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```