birth: Mist Breathing on Void
This commit is contained in:
parent
e03bbff2db
commit
e92a4c31d0
1 changed files with 146 additions and 0 deletions
146
index.html
Normal file
146
index.html
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Mist Rising</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a1a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: #555;
|
||||||
|
font-size: 10px;
|
||||||
|
text-shadow: 0 0 5px rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
|
</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;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// System parameters
|
||||||
|
const params = {
|
||||||
|
size: Math.max(1, Math.min(6, 6 * (0.5 + Math.random()))),
|
||||||
|
diffusionRateA: 1,
|
||||||
|
diffusionRateB: 0.5,
|
||||||
|
feed: 0.055,
|
||||||
|
kill: 0.062,
|
||||||
|
timeStep: 1,
|
||||||
|
reactionStrength: 0.1 * (0.5 + Math.random()),
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: 1.07 + Math.random() * 0.03
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize grids
|
||||||
|
const size = Math.ceil(canvas.width / params.size) + 2;
|
||||||
|
const grid = Array(size).fill().map(() => Array(size).fill(0));
|
||||||
|
const nextGrid = Array(size).fill().map(() => Array(size).fill(0));
|
||||||
|
|
||||||
|
// Initialize with random values
|
||||||
|
for (let i = 0; i < size; i++) {
|
||||||
|
for (let j = 0; j < size; j++) {
|
||||||
|
grid[i][j] = Math.random();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grayish color palette for dryness
|
||||||
|
const colors = [
|
||||||
|
'#2a2a3a', '#3a3a4a', '#4a4a5a',
|
||||||
|
'#5a5a6a', '#6a6a7a', '#7a7a8a'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
let time = 0;
|
||||||
|
function animate() {
|
||||||
|
// Pulse effect
|
||||||
|
params.feed = 0.055 + 0.005 * Math.sin(time * 0.02 * params.pulse);
|
||||||
|
params.kill = 0.062 + 0.003 * Math.sin(time * 0.015 * params.pulse);
|
||||||
|
|
||||||
|
// Update grid
|
||||||
|
for (let i = 1; i < size - 1; i++) {
|
||||||
|
for (let j = 1; j < size - 1; j++) {
|
||||||
|
const a = grid[i][j];
|
||||||
|
const b = grid[i][j];
|
||||||
|
|
||||||
|
// Reaction-diffusion equations
|
||||||
|
const reaction = a * b * b;
|
||||||
|
const da = params.diffusionRateA * (grid[i-1][j] + grid[i+1][j] + grid[i][j-1] + grid[i][j+1] - 4 * a) - reaction + params.feed * (1 - a);
|
||||||
|
const db = params.diffusionRateB * (grid[i-1][j] + grid[i+1][j] + grid[i][j-1] + grid[i][j+1] - 4 * b) + reaction - (params.kill + params.feed) * b;
|
||||||
|
|
||||||
|
nextGrid[i][j] = a + params.timeStep * da;
|
||||||
|
nextGrid[i][j] = Math.max(0, Math.min(1, nextGrid[i][j]));
|
||||||
|
|
||||||
|
nextGrid[i][j] = b + params.timeStep * db;
|
||||||
|
nextGrid[i][j] = Math.max(0, Math.min(1, nextGrid[i][j]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap grids
|
||||||
|
const temp = grid;
|
||||||
|
grid = nextGrid;
|
||||||
|
nextGrid = temp;
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
ctx.fillStyle = '#0a0a1a';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
for (let i = 0; i < size; i++) {
|
||||||
|
for (let j = 0; j < size; j++) {
|
||||||
|
const value = grid[i][j];
|
||||||
|
if (value < 0.05) continue;
|
||||||
|
|
||||||
|
const x = (i - (size - canvas.width / params.size) / 2) * params.size;
|
||||||
|
const y = (j - (size - canvas.height / params.size) / 2) * params.size;
|
||||||
|
const radius = (value * 2 + 0.3) * params.size * 2;
|
||||||
|
|
||||||
|
const colorIndex = Math.min(colors.length - 1, Math.floor(value * colors.length));
|
||||||
|
ctx.fillStyle = colors[colorIndex];
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(x, y, radius * params.motion, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add subtle motion to create organic feel
|
||||||
|
if (Math.random() < 0.1) {
|
||||||
|
const i = Math.floor(Math.random() * (size - 2)) + 1;
|
||||||
|
const j = Math.floor(Math.random() * (size - 2)) + 1;
|
||||||
|
grid[i][j] = Math.min(1, grid[i][j] + 0.1 * Math.random());
|
||||||
|
}
|
||||||
|
|
||||||
|
time++;
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
Loading…
Add table
Reference in a new issue