birth: ) &&
html.includes(
This commit is contained in:
parent
1762b9ead0
commit
ad6305e882
1 changed files with 159 additions and 0 deletions
159
index.html
Normal file
159
index.html
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba · motd.social</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
color: #555;
|
||||||
|
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();
|
||||||
|
|
||||||
|
// Reaction-diffusion simulation parameters
|
||||||
|
const params = {
|
||||||
|
feedRate: 0.055,
|
||||||
|
killRate: 0.062,
|
||||||
|
diffusionRateA: 1.0,
|
||||||
|
diffusionRateB: 0.5,
|
||||||
|
timeStep: 1.0,
|
||||||
|
width: Math.floor(canvas.width / 2),
|
||||||
|
height: Math.floor(canvas.height / 2),
|
||||||
|
cellSize: 2,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
motion: 0.5,
|
||||||
|
connectedness: 0.5
|
||||||
|
};
|
||||||
|
|
||||||
|
// Double buffer for simulation
|
||||||
|
const grid = new Float32Array(params.width * params.height * 2);
|
||||||
|
let current = 0;
|
||||||
|
|
||||||
|
function initGrid() {
|
||||||
|
for (let i = 0; i < params.width * params.height; i++) {
|
||||||
|
const idx = i * 4;
|
||||||
|
grid[idx] = Math.random();
|
||||||
|
grid[idx + 1] = Math.random();
|
||||||
|
grid[idx + 2] = 0;
|
||||||
|
grid[idx + 3] = 0;
|
||||||
|
}
|
||||||
|
// Add some initial structure based on complexity
|
||||||
|
const centerX = params.width / 2;
|
||||||
|
const centerY = params.height / 2;
|
||||||
|
for (let y = 0; y < params.height; y++) {
|
||||||
|
for (let x = 0; x < params.width; x++) {
|
||||||
|
const dist = Math.sqrt(Math.pow(x - centerX, 2) + Math.pow(y - centerY, 2));
|
||||||
|
const idx = (y * params.width + x) * 4;
|
||||||
|
if (dist < 50 * params.complexity + 10) {
|
||||||
|
grid[idx + 1] = 1; // Set B high at center
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
const next = 1 - current;
|
||||||
|
const gridCurrent = grid.subarray(current * params.width * params.height * 4);
|
||||||
|
const gridNext = grid.subarray(next * params.width * params.height * 4);
|
||||||
|
|
||||||
|
for (let y = 1; y < params.height - 1; y++) {
|
||||||
|
for (let x = 1; x < params.width - 1; x++) {
|
||||||
|
const idx = (y * params.width + x) * 4;
|
||||||
|
const idxUp = ((y - 1) * params.width + x) * 4;
|
||||||
|
const idxDown = ((y + 1) * params.width + x) * 4;
|
||||||
|
const idxLeft = (y * params.width + (x - 1)) * 4;
|
||||||
|
const idxRight = (y * params.width + (x + 1)) * 4;
|
||||||
|
|
||||||
|
const a = gridCurrent[idx];
|
||||||
|
const b = gridCurrent[idx + 1];
|
||||||
|
|
||||||
|
const laplacianA = (gridCurrent[idxUp] + gridCurrent[idxDown] +
|
||||||
|
gridCurrent[idxLeft] + gridCurrent[idxRight] -
|
||||||
|
4 * a) * params.diffusionRateA;
|
||||||
|
const laplacianB = (gridCurrent[idxUp + 1] + gridCurrent[idxDown + 1] +
|
||||||
|
gridCurrent[idxLeft + 1] + gridCurrent[idxRight + 1] -
|
||||||
|
4 * b) * params.diffusionRateB;
|
||||||
|
|
||||||
|
const reaction = a * b * b;
|
||||||
|
const newA = a + params.timeStep * (laplacianA - reaction + params.feedRate * (1 - a));
|
||||||
|
const newB = b + params.timeStep * (laplacianB + reaction - (params.killRate + params.feedRate) * b);
|
||||||
|
|
||||||
|
gridNext[idx] = Math.min(Math.max(newA, 0), 1);
|
||||||
|
gridNext[idx + 1] = Math.min(Math.max(newB, 0), 1);
|
||||||
|
gridNext[idx + 2] = b > 0.5 ? 1 : 0; // Binary threshold for visualization
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
current = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
const gridCurrent = grid.subarray(current * params.width * params.height * 4);
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Scale up for display
|
||||||
|
const scaleX = canvas.width / params.width / params.cellSize;
|
||||||
|
const scaleY = canvas.height / params.height / params.cellSize;
|
||||||
|
|
||||||
|
for (let y = 0; y < params.height / params.cellSize; y++) {
|
||||||
|
for (let x = 0; x < params.width / params.cellSize; x++) {
|
||||||
|
const idx = (Math.floor(y * params.cellSize) * params.width +
|
||||||
|
Math.floor(x * params.cellSize)) * 4;
|
||||||
|
const value = gridCurrent[idx + 1]; // B concentration
|
||||||
|
|
||||||
|
if (value > 0.2) {
|
||||||
|
// Draw with dryness (monochrome) and tension (high contrast)
|
||||||
|
const intensity = Math.min(value * 1.5, 1);
|
||||||
|
ctx.fillStyle = `rgba(255, 255, 255, ${intensity})`;
|
||||||
|
ctx.fillRect(x * params.cellSize * scaleX,
|
||||||
|
y * params.cellSize * scaleY,
|
||||||
|
params.cellSize * scaleX,
|
||||||
|
params.cellSize * scaleY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
for (let i = 0; i < 8; i++) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
initGrid();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue