birth: Muted Pulse in Grayscale
This commit is contained in:
parent
57b4357164
commit
199d663e1d
1 changed files with 184 additions and 0 deletions
184
index.html
Normal file
184
index.html
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Neurameba Pattern</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #000;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: rgba(255, 255, 255, 0.3);
|
||||||
|
font-size: 10px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</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();
|
||||||
|
|
||||||
|
// Simulation parameters derived from organism data
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: 1.08,
|
||||||
|
tone: {
|
||||||
|
anger: 0.0,
|
||||||
|
sadness: 0.0,
|
||||||
|
curiosity: 0.1,
|
||||||
|
dryness: 0.9,
|
||||||
|
playfulness: 0.0,
|
||||||
|
tension: 0.0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reaction-diffusion simulation
|
||||||
|
const gridSize = Math.min(50, Math.max(20, Math.floor(20 + params.density * 30)));
|
||||||
|
const cellSize = Math.min(window.innerWidth, window.innerHeight) / gridSize;
|
||||||
|
const cols = Math.ceil(window.innerWidth / cellSize);
|
||||||
|
const rows = Math.ceil(window.innerHeight / cellSize);
|
||||||
|
|
||||||
|
// Gray-Scott parameters (scaled from organism parameters)
|
||||||
|
const F = 0.055 + params.complexity * 0.02;
|
||||||
|
const k = 0.062 - params.connectedness * 0.02;
|
||||||
|
const feedRate = 0.01 + params.motion * 0.01;
|
||||||
|
const killRate = 0.03 + (1 - params.lifespan) * 0.02;
|
||||||
|
|
||||||
|
// State buffers
|
||||||
|
let current = new Float64Array(cols * rows * 2);
|
||||||
|
let next = new Float64Array(cols * rows * 2);
|
||||||
|
|
||||||
|
// Initialize with sparse, random pattern
|
||||||
|
for (let i = 0; i < cols * rows; i++) {
|
||||||
|
if (Math.random() < 0.05 * (params.density * 2)) {
|
||||||
|
current[i * 2] = 0.5 + (Math.random() - 0.5) * 0.1;
|
||||||
|
current[i * 2 + 1] = 0.25 + (Math.random() - 0.5) * 0.05;
|
||||||
|
} else {
|
||||||
|
current[i * 2] = 0.5 + (Math.random() - 0.5) * 0.01;
|
||||||
|
current[i * 2 + 1] = 0.25 + (Math.random() - 0.5) * 0.005;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Color palette (monochrome due to high dryness)
|
||||||
|
function getColor(u, v) {
|
||||||
|
const val = u + v * 0.5;
|
||||||
|
const gray = Math.floor(30 + val * 120);
|
||||||
|
return `rgb(${gray}, ${gray}, ${gray})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function laplacian(grid, x, y, component) {
|
||||||
|
const idx = (y * cols + x) * 2 + component;
|
||||||
|
let sum = 0;
|
||||||
|
|
||||||
|
for (let dy = -1; dy <= 1; dy++) {
|
||||||
|
for (let dx = -1; dx <= 1; dx++) {
|
||||||
|
if (dx === 0 && dy === 0) continue;
|
||||||
|
const nx = x + dx;
|
||||||
|
const ny = y + dy;
|
||||||
|
if (nx >= 0 && nx < cols && ny >= 0 && ny < rows) {
|
||||||
|
sum += grid[(ny * cols + nx) * 2 + component];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum / 8 - grid[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
const aspectRatio = window.innerWidth / window.innerHeight;
|
||||||
|
const timeStep = 0.1;
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const idx = (y * cols + x) * 2;
|
||||||
|
|
||||||
|
const u = current[idx];
|
||||||
|
const v = current[idx + 1];
|
||||||
|
|
||||||
|
// Apply Gray-Scott reaction-diffusion
|
||||||
|
const uvv = u * v * v;
|
||||||
|
const laplacianU = laplacian(current, x, y, 0);
|
||||||
|
const laplacianV = laplacian(current, x, y, 1);
|
||||||
|
|
||||||
|
next[idx] = u + timeStep * (
|
||||||
|
(feedRate * (1 - u) - uvv + 0.0001 * laplacianU) * params.pulse
|
||||||
|
);
|
||||||
|
next[idx + 1] = v + timeStep * (
|
||||||
|
(-killRate * v + uvv + 0.0001 * laplacianV) * params.pulse
|
||||||
|
);
|
||||||
|
|
||||||
|
// Boundary conditions
|
||||||
|
if (x === 0 || x === cols - 1 || y === 0 || y === rows - 1) {
|
||||||
|
next[idx] = 0.5;
|
||||||
|
next[idx + 1] = 0.25;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap buffers
|
||||||
|
[current, next] = [next, current];
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
// Clear canvas with semi-transparent background for trail effect
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const idx = (y * cols + x) * 2;
|
||||||
|
const u = current[idx];
|
||||||
|
const v = current[idx + 1];
|
||||||
|
|
||||||
|
if (u > 0.2 && v > 0.05) {
|
||||||
|
const cellX = x * cellSize;
|
||||||
|
const cellY = y * cellSize;
|
||||||
|
|
||||||
|
// Size based on complexity and connectedness
|
||||||
|
const size = 2 + (u - 0.2) * 10 * params.complexity;
|
||||||
|
|
||||||
|
// Color based on tone parameters
|
||||||
|
const val = u + v * 0.5;
|
||||||
|
const gray = Math.floor(30 + val * 120);
|
||||||
|
ctx.fillStyle = `rgba(${gray}, ${gray}, ${gray}, ${0.5 + u * 0.5})`;
|
||||||
|
|
||||||
|
ctx.fillRect(cellX, cellY, cellSize, cellSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
update();
|
||||||
|
draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue