birth: Gray Nebula in Motion

This commit is contained in:
motd_admin 2026-06-27 21:47:19 +00:00
parent 67c83eb033
commit 23293909ed

149
index.html Normal file
View file

@ -0,0 +1,149 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gray Nebula</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #000;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
}
canvas {
display: block;
}
#attribution {
position: fixed;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
color: #555;
font-size: 12px;
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();
// Parameters derived from abstract specifications
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.08, min: 1.05, max: 1.10 },
tone: { anger: 0, sadness: 0, curiosity: 0.2, dryness: 0.8, playfulness: 0, tension: 0 }
};
// Reaction-diffusion simulation constants
const W = canvas.width;
const H = canvas.height;
const SIZE = 2; // size of each cell
const WIDTH = Math.floor(W / SIZE);
const HEIGHT = Math.floor(H / SIZE);
// Initialize fields
let current = new Float32Array(WIDTH * HEIGHT * 4);
let next = new Float32Array(WIDTH * HEIGHT * 4);
// Fill with random values
for (let i = 0; i < current.length; i += 4) {
current[i] = 0.5 + (Math.random() * 0.1 - 0.05); // A
current[i+1] = 0.5 + (Math.random() * 0.1 - 0.05); // B
current[i+2] = 0; // C
current[i+3] = 0; // D
}
// Simulation parameters
const Da = 1.0;
const Db = 0.5;
const f = 0.055 + (params.complexity * 0.045); // feed rate
const k = 0.062 + (params.connectedness * 0.038); // kill rate
const feedRate = () => f + (Math.sin(Date.now() * 0.001) * 0.01 * params.pulse.avg);
function update() {
const t = Date.now() * 0.001 * params.motion;
for (let x = 1; x < WIDTH - 1; x++) {
for (let y = 1; y < HEIGHT - 1; y++) {
const i = (x + y * WIDTH) * 4;
// Get neighbors
const iN = ((x) + (y-1) * WIDTH) * 4;
const iS = ((x) + (y+1) * WIDTH) * 4;
const iE = ((x+1) + (y) * WIDTH) * 4;
const iW = ((x-1) + (y) * WIDTH) * 4;
const iNW = ((x-1) + (y-1) * WIDTH) * 4;
const iNE = ((x+1) + (y-1) * WIDTH) * 4;
const iSW = ((x-1) + (y+1) * WIDTH) * 4;
const iSE = ((x+1) + (y+1) * WIDTH) * 4;
const A = current[i];
const B = current[i+1];
// Laplacian
const lapA = (current[iN] + current[iS] + current[iE] + current[iW] +
current[iNW] + current[iNE] + current[iSW] + current[iSE] - 8 * A) / 8;
const lapB = (current[iN+1] + current[iS+1] + current[iE+1] + current[iW+1] +
current[iNW+1] + current[iNE+1] + current[iSW+1] + current[iSE+1] - 8 * B) / 8;
// Reaction terms
const reactA = A * B * B;
const reactB = A * B;
// Update
next[i] = A + (Da * lapA - reactA + feedRate()) * SIZE;
next[i+1] = B + (Db * lapB + reactA - reactB) * SIZE;
next[i+2] = 0;
next[i+3] = 0;
}
}
// Swap buffers
[current, next] = [next, current];
// Render
ctx.clearRect(0, 0, W, H);
for (let x = 0; x < WIDTH; x++) {
for (let y = 0; y < HEIGHT; y++) {
const i = (x + y * WIDTH) * 4;
const val = current[i+1]; // B value
if (val > 0.1 && val < 0.9) {
const size = SIZE * 2 * (1 - params.tone.dryness);
const hue = 200 + (val * 120);
const sat = 50 + (params.tone.curiosity * 50);
const bri = 10 + (val * 80);
ctx.fillStyle = `hsl(${hue}, ${sat}%, ${bri}%)`;
ctx.fillRect(x * SIZE, y * SIZE, size, size);
}
}
}
requestAnimationFrame(update);
}
update();
</script>
</body>
</html>