birth: Chemical Echoes in Static
This commit is contained in:
parent
a252954682
commit
b1f7ec334b
1 changed files with 199 additions and 0 deletions
199
index.html
Normal file
199
index.html
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
```html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Chemical Echoes</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: #555555;
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
</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 organism specs
|
||||
const params = {
|
||||
motion: 0.496,
|
||||
density: 0.529,
|
||||
complexity: 0.471,
|
||||
connectedness: 0.516,
|
||||
lifespan: 0.432,
|
||||
pulse: { avg: 0.37, min: 0.30, max: 1.65 },
|
||||
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 },
|
||||
topology: {
|
||||
nodes: 86,
|
||||
branches: 75,
|
||||
loops: 1223,
|
||||
maxDepth: 26,
|
||||
thicknessRatio: 1.25,
|
||||
fractalDim: 1.518,
|
||||
energy: 493.8
|
||||
}
|
||||
};
|
||||
|
||||
// Reaction-diffusion simulation
|
||||
const size = 100;
|
||||
const grid = new Array(size);
|
||||
const next = new Array(size);
|
||||
|
||||
// Initialize with variations based on parameters
|
||||
for (let i = 0; i < size; i++) {
|
||||
grid[i] = new Array(size);
|
||||
next[i] = new Array(size);
|
||||
for (let j = 0; j < size; j++) {
|
||||
// Base reaction rate influenced by complexity and motion
|
||||
const reactionRate = 0.15 + params.complexity * 0.3;
|
||||
// Initial concentrations influenced by density
|
||||
grid[i][j] = [
|
||||
params.density, // A
|
||||
1 - params.density, // B
|
||||
Math.random() * 0.1, // C
|
||||
0 // D
|
||||
];
|
||||
next[i][j] = [0, 0, 0, 0];
|
||||
}
|
||||
}
|
||||
|
||||
// Grayish palette with subtle variation
|
||||
const palette = [
|
||||
`hsl(0, 0%, ${60 + params.tone.dryness * 20}%)`,
|
||||
`hsl(0, 0%, ${40 + params.tone.dryness * 30}%)`,
|
||||
`hsl(0, 0%, ${80 + params.tone.dryness * 10}%)`,
|
||||
`hsl(0, 0%, ${20 + params.tone.dryness * 20}%)`
|
||||
];
|
||||
|
||||
let frameCount = 0;
|
||||
let lastTime = 0;
|
||||
|
||||
function animate(currentTime) {
|
||||
const deltaTime = currentTime - lastTime;
|
||||
lastTime = currentTime;
|
||||
|
||||
// Adjust simulation speed based on motion parameter
|
||||
const speed = 0.05 + params.motion * 0.15;
|
||||
|
||||
// Reaction-diffusion step
|
||||
for (let x = 1; x < size - 1; x++) {
|
||||
for (let y = 1; y < size - 1; y++) {
|
||||
const a = grid[x][y][0];
|
||||
const b = grid[x][y][1];
|
||||
const c = grid[x][y][2];
|
||||
const d = grid[x][y][3];
|
||||
|
||||
// Modified Gray-Scott reaction
|
||||
const reaction = a * b * b;
|
||||
const newA = a + (speed * (0.08 * (this.diffuse(a, x, y)) - reaction));
|
||||
const newB = b + (speed * (0.06 * (this.diffuse(b, x, y)) + reaction));
|
||||
|
||||
// Additional complexity from connectedness
|
||||
const spread = params.connectedness * 0.1;
|
||||
next[x][y][0] = Math.max(0, Math.min(1, newA + (grid[x-1][y][0] + grid[x+1][y][0] + grid[x][y-1][0] + grid[x][y+1][0]) * spread / 4));
|
||||
next[x][y][1] = Math.max(0, Math.min(1, newB + (grid[x-1][y][1] + grid[x+1][y][1] + grid[x][y-1][1] + grid[x][y+1][1]) * spread / 4));
|
||||
|
||||
// Add some random perturbation
|
||||
if (Math.random() < 0.05 * params.complexity) {
|
||||
next[x][y][0] += (Math.random() - 0.5) * 0.2;
|
||||
next[x][y][1] += (Math.random() - 0.5) * 0.2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Swap grids
|
||||
for (let x = 0; x < size; x++) {
|
||||
for (let y = 0; y < size; y++) {
|
||||
for (let i = 0; i < 4; i++) {
|
||||
grid[x][y][i] = next[x][y][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drawing
|
||||
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
const cellWidth = canvas.width / size;
|
||||
const cellHeight = canvas.height / size;
|
||||
|
||||
// Draw based on concentrations
|
||||
for (let x = 0; x < size; x++) {
|
||||
for (let y = 0; y < size; y++) {
|
||||
const val = grid[x][y][0]; // Concentration A
|
||||
if (val > 0.1) {
|
||||
// Use fractal-inspired size variation
|
||||
const size = cellWidth * (0.2 + val * 0.8) * (params.fractalDim / 1.518);
|
||||
const opacity = Math.min(1, val * 2);
|
||||
|
||||
// Subtle color variation
|
||||
const hueOffset = Math.sin(x * 0.1 + frameCount * 0.01) * 5;
|
||||
const saturation = 10 + params.tone.dryness * 5;
|
||||
|
||||
ctx.fillStyle = `hsla(${hueOffset}, ${saturation}%, ${50 + params.tone.dryness * 30}%, ${opacity})`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(
|
||||
x * cellWidth + cellWidth/2,
|
||||
y * cellHeight + cellHeight/2,
|
||||
size * (0.5 + Math.sin(frameCount * 0.05 + x * 0.2) * 0.5),
|
||||
0,
|
||||
Math.PI * 2
|
||||
);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add some persistent trails based on lifespan
|
||||
if (params.lifespan > 0.3) {
|
||||
ctx.fillStyle = `hsla(0, 0%, ${70 + Math.sin(frameCount * 0.02) * 10}%, 0.02)`;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
}
|
||||
|
||||
frameCount++;
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Simple diffusion function for the reaction
|
||||
function diffuse(value, x, y) {
|
||||
return (
|
||||
grid[x][y][value] * -1 +
|
||||
grid[x-1][y][value] * 0.2 +
|
||||
grid[x+1][y][value] * 0.2 +
|
||||
grid[x][y-1][value] * 0.2 +
|
||||
grid[x][y+1][value] * 0.2
|
||||
);
|
||||
}
|
||||
|
||||
// Start animation
|
||||
requestAnimationFrame(animate);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
Loading…
Add table
Reference in a new issue