birth: Quiver Grid Dreams
This commit is contained in:
parent
adc5d7f47d
commit
781da39a55
1 changed files with 143 additions and 0 deletions
143
index.html
Normal file
143
index.html
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Quiver Grid · motd</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a1a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: fixed;
|
||||||
|
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');
|
||||||
|
|
||||||
|
function resize() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resize);
|
||||||
|
resize();
|
||||||
|
|
||||||
|
// Reaction-diffusion parameters
|
||||||
|
const params = {
|
||||||
|
feed_rate: 0.055,
|
||||||
|
kill_rate: 0.062,
|
||||||
|
diffusion_a: 1.0,
|
||||||
|
diffusion_b: 0.5,
|
||||||
|
time_step: 1.0,
|
||||||
|
grid_size: 4,
|
||||||
|
brush_size: 5,
|
||||||
|
noise_strength: 0.05
|
||||||
|
};
|
||||||
|
|
||||||
|
const cols = Math.floor(canvas.width / params.grid_size);
|
||||||
|
const rows = Math.floor(canvas.height / params.grid_size);
|
||||||
|
const grid = new Array(cols * rows).fill(0);
|
||||||
|
const next = new Array(cols * rows).fill(0);
|
||||||
|
|
||||||
|
// Initialize with sparse random seeds
|
||||||
|
for (let i = 0; i < grid.length; i++) {
|
||||||
|
if (Math.random() < 0.01 * (1 + params.density * 9)) {
|
||||||
|
grid[i] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
// React & diffuse
|
||||||
|
for (let i = 0; i < grid.length; i++) {
|
||||||
|
const x = i % cols;
|
||||||
|
const y = Math.floor(i / cols);
|
||||||
|
|
||||||
|
const a = grid[i];
|
||||||
|
const b = next[i];
|
||||||
|
|
||||||
|
// Neighbors (Moore neighborhood)
|
||||||
|
const neighbors = [
|
||||||
|
i - 1, i + 1, i - cols, i + cols, // cardinal
|
||||||
|
i - cols - 1, i - cols + 1, i + cols - 1, i + cols + 1 // diagonals
|
||||||
|
].map(idx => {
|
||||||
|
return idx >= 0 && idx < grid.length ? grid[idx] : 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const laplacian_a = (neighbors.reduce((sum, val) => sum + val, 0) - 8 * a) / 9;
|
||||||
|
const laplacian_b = (b * 0.1); // Simplified
|
||||||
|
|
||||||
|
next[i] = a + (params.diffusion_a * laplacian_a - a * b * b + params.feed_rate * (1 - a)) * params.time_step;
|
||||||
|
next[i] += (params.diffusion_b * laplacian_b - a * b * b + params.kill_rate * b) * params.time_step;
|
||||||
|
|
||||||
|
// Clamp
|
||||||
|
next[i] = Math.max(0, Math.min(1, next[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap buffers
|
||||||
|
[grid, next] = [next, grid];
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
ctx.fillStyle = '#0a0a1a';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
const intensity = 0.7 + Math.sin(Date.now() * 0.001) * 0.1;
|
||||||
|
const hue = (Date.now() * 0.0005) % 360;
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const i = x + y * cols;
|
||||||
|
const val = grid[i];
|
||||||
|
|
||||||
|
if (val > 0.1) {
|
||||||
|
ctx.fillStyle = `hsl(${hue}, 80%, ${50 + val * 20}%)`;
|
||||||
|
ctx.fillRect(
|
||||||
|
x * params.grid_size,
|
||||||
|
y * params.grid_size,
|
||||||
|
params.grid_size,
|
||||||
|
params.grid_size
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mouse interaction
|
||||||
|
canvas.addEventListener('mousemove', (e) => {
|
||||||
|
const rect = canvas.getBoundingClientRect();
|
||||||
|
const x = Math.floor((e.clientX - rect.left) / params.grid_size);
|
||||||
|
const y = Math.floor((e.clientY - rect.top) / params.grid_size);
|
||||||
|
|
||||||
|
for (let dy = -params.brush_size; dy <= params.brush_size; dy++) {
|
||||||
|
for (let dx = -params.brush_size; dx <= params.brush_size; dx++) {
|
||||||
|
const nx = x + dx;
|
||||||
|
const ny = y + dy;
|
||||||
|
if (nx >= 0 && nx < cols && ny >= 0 && ny < rows) {
|
||||||
|
const i = nx + ny * cols;
|
||||||
|
grid[i] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
update();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue