birth: Quivering Symmetry in Grayscale
This commit is contained in:
parent
1df337df98
commit
36f9073ba7
1 changed files with 176 additions and 0 deletions
176
index.html
Normal file
176
index.html
Normal file
|
|
@ -0,0 +1,176 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Quivering Symmetry</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #000;
|
||||||
|
color: #fff;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 10px;
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
</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');
|
||||||
|
|
||||||
|
// Set canvas to full window size
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters derived from abstract inputs
|
||||||
|
const params = {
|
||||||
|
motion: 0.514,
|
||||||
|
density: 0.557,
|
||||||
|
complexity: 0.485,
|
||||||
|
connectedness: 0.520,
|
||||||
|
lifespan: 0.402,
|
||||||
|
survivingNodes: 63,
|
||||||
|
branchCount: 57,
|
||||||
|
loops: 364,
|
||||||
|
maxDepth: 15,
|
||||||
|
thicknessRatio: 1.25,
|
||||||
|
fractalDimension: 1.331,
|
||||||
|
pulse: { avg: 0.48, min: 0.30, max: 1.65 },
|
||||||
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.80, dryness: 0.90, playfulness: 0.10, tension: 0.00 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reaction-diffusion grid
|
||||||
|
const gridSize = Math.min(128, Math.max(32, Math.floor(64 * params.density)));
|
||||||
|
const cellWidth = canvas.width / gridSize;
|
||||||
|
const cellHeight = canvas.height / gridSize;
|
||||||
|
|
||||||
|
// Gray values (dryness = monochrome)
|
||||||
|
const dryness = params.tone.dryness;
|
||||||
|
const baseColor = Math.floor(30 + 200 * (1 - dryness));
|
||||||
|
const bgColor = `rgb(${baseColor}, ${baseColor}, ${baseColor})`;
|
||||||
|
const fgColor1 = `rgb(${255 - baseColor}, ${255 - baseColor}, ${255 - baseColor})`;
|
||||||
|
const fgColor2 = `rgb(${220 - baseColor}, ${220 - baseColor}, ${180 - baseColor})`;
|
||||||
|
|
||||||
|
// Reaction-diffusion coefficients
|
||||||
|
const DA = 1.0;
|
||||||
|
const DB = 0.5;
|
||||||
|
const feed = 0.055;
|
||||||
|
const kill = 0.062;
|
||||||
|
|
||||||
|
// Initialize grids
|
||||||
|
let gridA = new Array(gridSize * gridSize).fill(1);
|
||||||
|
let gridB = new Array(gridSize * gridSize).fill(0);
|
||||||
|
|
||||||
|
// Random perturbations based on complexity
|
||||||
|
for (let i = 0; i < gridSize * gridSize; i++) {
|
||||||
|
if (Math.random() < params.complexity * 0.1) {
|
||||||
|
gridA[i] = 0.5 + Math.random() * 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reaction-diffusion simulation
|
||||||
|
function updateGrid() {
|
||||||
|
const newGridA = new Array(gridSize * gridSize).fill(0);
|
||||||
|
const newGridB = new Array(gridSize * gridSize).fill(0);
|
||||||
|
|
||||||
|
for (let y = 1; y < gridSize - 1; y++) {
|
||||||
|
for (let x = 1; x < gridSize - 1; x++) {
|
||||||
|
const idx = y * gridSize + x;
|
||||||
|
|
||||||
|
// Calculate Laplacian
|
||||||
|
const laplacianA = (gridA[idx - 1] + gridA[idx + 1] +
|
||||||
|
gridA[idx - gridSize] + gridA[idx + gridSize] +
|
||||||
|
gridA[idx - gridSize - 1] + gridA[idx - gridSize + 1] +
|
||||||
|
gridA[idx + gridSize - 1] + gridA[idx + gridSize + 1] -
|
||||||
|
8 * gridA[idx]) / 4;
|
||||||
|
|
||||||
|
const laplacianB = (gridB[idx - 1] + gridB[idx + 1] +
|
||||||
|
gridB[idx - gridSize] + gridB[idx + gridSize] +
|
||||||
|
gridB[idx - gridSize - 1] + gridB[idx - gridSize + 1] +
|
||||||
|
gridB[idx + gridSize - 1] + gridB[idx + gridSize + 1] -
|
||||||
|
8 * gridB[idx]) / 4;
|
||||||
|
|
||||||
|
// Reaction terms
|
||||||
|
const reactionA = gridA[idx] * gridB[idx] * gridB[idx];
|
||||||
|
const reactionB = gridA[idx] * (feed - kill) - reactionA;
|
||||||
|
|
||||||
|
// Update concentrations
|
||||||
|
newGridA[idx] = Math.max(0, Math.min(1, gridA[idx] + (DA * laplacianA - reactionA) * params.motion));
|
||||||
|
newGridB[idx] = Math.max(0, Math.min(1, gridB[idx] + (DB * laplacianB + reactionA) * params.motion));
|
||||||
|
|
||||||
|
// Add some noise based on motion
|
||||||
|
newGridA[idx] += (Math.random() - 0.5) * params.motion * 0.01;
|
||||||
|
newGridB[idx] += (Math.random() - 0.5) * params.motion * 0.01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gridA = newGridA;
|
||||||
|
gridB = newGridB;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw grid
|
||||||
|
function drawGrid() {
|
||||||
|
ctx.fillStyle = bgColor;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
const pulseFactor = params.pulse.avg + Math.sin(Date.now() * 0.001) * params.pulse.max * 0.1;
|
||||||
|
|
||||||
|
for (let y = 0; y < gridSize; y++) {
|
||||||
|
for (let x = 0; x < gridSize; x++) {
|
||||||
|
const idx = y * gridSize + x;
|
||||||
|
const valA = gridA[idx];
|
||||||
|
const valB = gridB[idx];
|
||||||
|
|
||||||
|
// Complex patterns emerge from reaction-diffusion
|
||||||
|
const size = cellWidth * 0.8;
|
||||||
|
const xPos = x * cellWidth + cellWidth * 0.1;
|
||||||
|
const yPos = y * cellHeight + cellHeight * 0.1;
|
||||||
|
|
||||||
|
// Color based on reaction terms
|
||||||
|
const t = valA - valB;
|
||||||
|
const hue = 180 + 60 * t;
|
||||||
|
const saturation = 70 + 30 * valB;
|
||||||
|
const lightness = 50 + 20 * valA;
|
||||||
|
|
||||||
|
// Apply dryness to desaturate
|
||||||
|
const finalSaturation = saturation * (1 - dryness * 0.7);
|
||||||
|
|
||||||
|
ctx.fillStyle = `hsl(${hue}, ${finalSaturation}%, ${lightness}%)`;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(xPos + size/2, yPos + size/2, size * 0.4 * params.complexity, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
updateGrid();
|
||||||
|
drawGrid();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start animation
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue