birth: Gray currents in lattice veins
This commit is contained in:
parent
3ce66da024
commit
81d91bf66b
1 changed files with 168 additions and 0 deletions
168
index.html
Normal file
168
index.html
Normal file
|
|
@ -0,0 +1,168 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Reaction Diffusion</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
color: #555;
|
||||||
|
font-size: 10px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 4px;
|
||||||
|
background: rgba(0,0,0,0.3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas"></canvas>
|
||||||
|
<div id="info">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 abstract specs
|
||||||
|
const params = {
|
||||||
|
motion: 0.512,
|
||||||
|
density: 0.573,
|
||||||
|
complexity: 0.581,
|
||||||
|
connectedness: 0.477,
|
||||||
|
lifespan: 0.436,
|
||||||
|
survivingNodes: 79,
|
||||||
|
branchCount: 60,
|
||||||
|
loops: 182,
|
||||||
|
maxDepth: 20,
|
||||||
|
thicknessRatio: 1.50,
|
||||||
|
fractalDimension: 1.585,
|
||||||
|
finalEnergy: 373.8,
|
||||||
|
pulse: { avg: 0.85, min: 0.30, max: 2.00 },
|
||||||
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.70, dryness: 0.80, playfulness: 0.10, tension: 0.00 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize reaction-diffusion grid
|
||||||
|
const size = 80;
|
||||||
|
const grid = Array(size).fill().map(() => Array(size).fill(0));
|
||||||
|
const nextGrid = Array(size).fill().map(() => Array(size).fill(0));
|
||||||
|
|
||||||
|
// Seed random spots based on density
|
||||||
|
for (let i = 0; i < size; i++) {
|
||||||
|
for (let j = 0; j < size; j++) {
|
||||||
|
if (Math.random() < params.density * 2) { // Scale density for visibility
|
||||||
|
grid[i][j] = Math.random() * 0.5 + 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gray monochrome palette (dryness=0.80)
|
||||||
|
function getColor(value) {
|
||||||
|
const v = Math.min(1, Math.max(0, value));
|
||||||
|
const gray = Math.floor(20 + v * 60);
|
||||||
|
return `rgb(${gray}, ${gray}, ${gray})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reaction-diffusion equations
|
||||||
|
function updateGrid() {
|
||||||
|
const F = 0.055;
|
||||||
|
const k = 0.062;
|
||||||
|
const timeStep = 0.15;
|
||||||
|
|
||||||
|
for (let i = 1; i < size - 1; i++) {
|
||||||
|
for (let j = 1; j < size - 1; j++) {
|
||||||
|
const center = grid[i][j];
|
||||||
|
const north = grid[i-1][j];
|
||||||
|
const south = grid[i+1][j];
|
||||||
|
const east = grid[i][j+1];
|
||||||
|
const west = grid[i][j-1];
|
||||||
|
const laplacian = (north + south + east + west - 4 * center) * 0.25;
|
||||||
|
|
||||||
|
const reaction = center * (F - (center + 1) * k - timeStep * laplacian);
|
||||||
|
nextGrid[i][j] = center + timeStep * reaction + timeStep * (0.2 * laplacian);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap grids
|
||||||
|
[grid, nextGrid].forEach(g => g.fill().map(row => row.fill(0)));
|
||||||
|
|
||||||
|
// Add some random perturbations based on motion
|
||||||
|
const motionFactor = params.motion * 0.1;
|
||||||
|
for (let i = 1; i < size - 1; i++) {
|
||||||
|
for (let j = 1; j < size - 1; j++) {
|
||||||
|
if (Math.random() < motionFactor * 0.5) {
|
||||||
|
grid[i][j] += (Math.random() - 0.5) * 0.2 * motionFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation
|
||||||
|
let time = 0;
|
||||||
|
function animate() {
|
||||||
|
time += 0.01;
|
||||||
|
|
||||||
|
// Pulse effect
|
||||||
|
const pulse = params.pulse.avg + Math.sin(time * 3) * (params.pulse.max - params.pulse.avg) * 0.3;
|
||||||
|
|
||||||
|
// Complexity affects the diffusion rates
|
||||||
|
const complexityFactor = params.complexity * 0.1 + 0.05;
|
||||||
|
|
||||||
|
// Update grid with parameters
|
||||||
|
for (let step = 0; step < pulse; step++) {
|
||||||
|
updateGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Scale factor to fit grid to canvas
|
||||||
|
const cellWidth = canvas.width / size;
|
||||||
|
const cellHeight = canvas.height / size;
|
||||||
|
|
||||||
|
for (let i = 0; i < size; i++) {
|
||||||
|
for (let j = 0; j < size; j++) {
|
||||||
|
const value = grid[i][j];
|
||||||
|
if (value > 0.1) {
|
||||||
|
ctx.fillStyle = getColor(value);
|
||||||
|
ctx.fillRect(i * cellWidth, j * cellHeight, cellWidth, cellHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add some connectedness-based "veins" occasionally
|
||||||
|
if (Math.random() < params.connectedness * 0.01) {
|
||||||
|
const i = Math.floor(Math.random() * size);
|
||||||
|
const j = Math.floor(Math.random() * size);
|
||||||
|
const brightness = 80 + Math.random() * 40;
|
||||||
|
ctx.strokeStyle = `rgb(${brightness}, ${brightness}, ${brightness})`;
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(i * cellWidth, j * cellHeight);
|
||||||
|
ctx.lineTo((i + 1) * cellWidth, (j + 1) * cellHeight);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue