birth: Pale Fractured Spaces

This commit is contained in:
motd_admin 2026-06-05 09:47:18 +00:00
parent ff9ddfe5cb
commit 8cf613f21f

151
index.html Normal file
View file

@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scattered Echoes</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
color: #444;
font-size: 10px;
text-shadow: 0 0 5px #111;
}
</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 parameters (Gray-Scott model variant)
const params = {
feed: 0.05,
kill: 0.06,
dt: 0.1,
scale: 2.5 + Math.random() * 2,
density: 0.5 + Math.random() * 0.3,
complexity: 0.5 + Math.random() * 0.3,
motion: 0.5,
connectedness: 0.4,
colorVariation: 0.2,
palette: [
'#f0f0f0', // background
'#888888', // inactive
'#cccccc', // slow growth
'#eeeeee' // fast growth
]
};
// Initialize grid
const size = Math.ceil(Math.max(canvas.width, canvas.height) / params.scale);
const grid = new Array(size * size).fill(0);
const prevGrid = new Array(size * size).fill(0);
function init() {
// Initial sparse seeding
for (let i = 0; i < size * size * params.density; i++) {
const idx = Math.floor(Math.random() * size * size);
grid[idx] = Math.random() * 0.1;
}
}
function update() {
// Store previous state
for (let i = 0; i < grid.length; i++) {
prevGrid[i] = grid[i];
}
// Update each cell
for (let y = 1; y < size - 1; y++) {
for (let x = 1; x < size - 1; x++) {
const idx = y * size + x;
const u = prevGrid[idx];
const v = grid[idx];
// Simplified Gray-Scott reaction
const laplacianU = (prevGrid[idx - size] + prevGrid[idx + size] +
prevGrid[idx - 1] + prevGrid[idx + 1] -
4 * u) * 0.2;
const reaction = u * v * v;
const du = params.dt * (params.feed * (1 - u) - reaction + params.dt * 0.2 * laplacianU);
const dv = params.dt * (-params.kill * v + reaction + params.dt * 0.1 * laplacianU);
grid[idx] = u + du;
prevGrid[idx] += dv;
// Clamping
grid[idx] = Math.max(0, Math.min(1, grid[idx]));
prevGrid[idx] = Math.max(0, Math.min(1, prevGrid[idx]));
}
}
}
function draw() {
const imageData = ctx.createImageData(canvas.width, canvas.height);
const data = imageData.data;
for (let y = 0; y < canvas.height; y++) {
for (let x = 0; x < canvas.width; x++) {
const cellX = Math.floor(x / params.scale);
const cellY = Math.floor(y / params.scale);
const idx = cellY * size + cellX;
// Calculate brightness based on both grid values
const brightness = Math.min(1,
prevGrid[idx] * 0.6 + grid[idx] * 0.4 + Math.random() * params.colorVariation);
const colorIndex = Math.floor(brightness * (params.palette.length - 1));
const color = params.palette[colorIndex];
const i = (y * canvas.width + x) * 4;
data[i] = parseInt(color.slice(1, 3), 16);
data[i + 1] = parseInt(color.slice(3, 5), 16);
data[i + 2] = parseInt(color.slice(5, 7), 16);
data[i + 3] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
}
function animate() {
update();
draw();
// Occasionally adjust parameters to create organic variation
if (Math.random() < 0.02) {
params.feed = 0.04 + Math.random() * 0.03;
params.kill = 0.05 + Math.random() * 0.03;
params.scale = 2 + Math.random() * 3;
}
requestAnimationFrame(animate);
}
init();
animate();
</script>
</body>
</html>