birth: Static Pulse Spreading
This commit is contained in:
parent
072c13b1b5
commit
5edf7ea9a9
1 changed files with 153 additions and 0 deletions
153
index.html
Normal file
153
index.html
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Static Pulse</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background-color: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
#attribution {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: #333;
|
||||
font-size: 10px;
|
||||
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 the input
|
||||
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.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 }
|
||||
};
|
||||
|
||||
// Reaction-diffusion simulation
|
||||
const size = 64;
|
||||
const grid = new Array(size * size);
|
||||
const nextGrid = new Array(size * size);
|
||||
|
||||
// Initialize with patterns
|
||||
function init() {
|
||||
for (let i = 0; i < size * size; i++) {
|
||||
const x = i % size;
|
||||
const y = Math.floor(i / size);
|
||||
const centerDist = Math.sqrt(
|
||||
Math.pow(x - size/2, 2) +
|
||||
Math.pow(y - size/2, 2)
|
||||
) / (size/2);
|
||||
|
||||
// Base pattern with some randomness
|
||||
let val = 0.5 + 0.1 * Math.sin(x * 0.2 + y * 0.3) +
|
||||
0.1 * (Math.random() - 0.5) * (1 - centerDist);
|
||||
|
||||
// Adjust based on tone (dryness favors neutral patterns)
|
||||
val = val * 0.9 + 0.05;
|
||||
|
||||
grid[i] = Math.max(0, Math.min(1, val));
|
||||
nextGrid[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
const width = canvas.width;
|
||||
const height = canvas.height;
|
||||
const cellWidth = width / size;
|
||||
const cellHeight = height / size;
|
||||
|
||||
// Reaction-diffusion parameters
|
||||
const feed = 0.055;
|
||||
const kill = 0.062;
|
||||
const diffA = 1.0;
|
||||
const diffB = 0.5;
|
||||
const timeStep = 1.0;
|
||||
|
||||
for (let x = 1; x < size - 1; x++) {
|
||||
for (let y = 1; y < size - 1; y++) {
|
||||
const idx = x + y * size;
|
||||
const a = grid[idx];
|
||||
const b = grid[idx] - nextGrid[idx];
|
||||
|
||||
nextGrid[idx] = a + timeStep * (
|
||||
diffA * (grid[idx - 1] + grid[idx + 1] + grid[idx - size] + grid[idx + size] - 4 * a) -
|
||||
a * b * b +
|
||||
feed * (1 - a)
|
||||
);
|
||||
|
||||
nextGrid[idx] += timeStep * (
|
||||
diffB * (nextGrid[idx - 1] + nextGrid[idx + 1] + nextGrid[idx - size] + nextGrid[idx + size] - 4 * b) +
|
||||
kill * a +
|
||||
feed * (1 - b)
|
||||
);
|
||||
|
||||
// Apply bounds
|
||||
nextGrid[idx] = Math.max(0, Math.min(1, nextGrid[idx]));
|
||||
}
|
||||
}
|
||||
|
||||
// Swap grids
|
||||
[grid, nextGrid] = [nextGrid, grid];
|
||||
|
||||
// Draw
|
||||
ctx.fillStyle = '#000';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
for (let x = 0; x < size; x++) {
|
||||
for (let y = 0; y < size; y++) {
|
||||
const idx = x + y * size;
|
||||
const val = grid[idx];
|
||||
|
||||
if (val > 0.1) {
|
||||
const brightness = Math.floor(val * 255 * 0.8);
|
||||
ctx.fillStyle = `rgb(${brightness}, ${brightness}, ${brightness})`;
|
||||
|
||||
// Add some variation based on motion parameter
|
||||
const pulse = params.pulse.avg + 0.1 * Math.sin(Date.now() * 0.002 * params.motion);
|
||||
const sizeFactor = 1 + 0.2 * (pulse - 1);
|
||||
|
||||
ctx.fillRect(
|
||||
x * cellWidth + (cellWidth - cellWidth * sizeFactor) / 2,
|
||||
y * cellHeight + (cellHeight - cellHeight * sizeFactor) / 2,
|
||||
cellWidth * sizeFactor,
|
||||
cellHeight * sizeFactor
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function animate() {
|
||||
update();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
init();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue