birth: Teal Nebula Pulse

This commit is contained in:
motd_admin 2026-04-16 09:47:15 +00:00
parent 70448db804
commit 308ea263c4

135
index.html Normal file
View file

@ -0,0 +1,135 @@
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Teal Nebula</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #0a0a1a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 20px;
color: #77aaff;
font-size: 10px;
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');
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Reaction-diffusion parameters
const params = {
feed: 0.055,
kill: 0.062,
diffA: 1.0,
diffB: 0.5,
scale: 120,
pixelSize: 1
};
// Initialize grids
let grid = Array(canvas.height).fill().map(() =>
Array(canvas.width).fill().map(() => Math.random() * 0.2)
);
let nextGrid = Array(canvas.height).fill().map(() =>
Array(canvas.width).fill(0)
);
// Reaction-diffusion simulation
function update() {
for (let y = 1; y < canvas.height - 1; y++) {
for (let x = 1; x < canvas.width - 1; x++) {
const a = grid[y][x];
const b = nextGrid[y][x];
// Calculate Laplacian
const aLap = (
grid[y-1][x] + grid[y+1][x] +
grid[y][x-1] + grid[y][x+1] -
4 * a
) * params.diffA;
const bLap = (
nextGrid[y-1][x] + nextGrid[y+1][x] +
nextGrid[y][x-1] + nextGrid[y][x+1] -
4 * b
) * params.diffB;
// Reaction terms
const reaction = a * b * b;
const aNew = a + (aLap * params.feed) - reaction;
const bNew = b + (bLap * params.kill) + reaction;
// Clamp and store
nextGrid[y][x] = Math.min(Math.max(bNew, 0), 1);
grid[y][x] = Math.min(Math.max(aNew, 0), 1);
}
}
// Swap grids
[grid, nextGrid] = [nextGrid, grid];
}
// Drawing function
function draw() {
ctx.fillStyle = '#0a0a1a';
ctx.fillRect(0, 0, canvas.width, canvas.height);
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 val = grid[y][x];
const idx = (y * canvas.width + x) * 4;
// Teal color scheme for curiosity
data[idx] = Math.min(255, val * 255 * 2); // R (low)
data[idx+1] = Math.min(255, val * 255 * 1.8); // G (medium)
data[idx+2] = Math.min(255, val * 255 * 2.2); // B (high)
data[idx+3] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
}
// Animation loop
function animate() {
update();
draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```