birth: Static Pulse in Void
This commit is contained in:
parent
4c5b83bfd2
commit
31b22bba91
1 changed files with 142 additions and 0 deletions
142
index.html
Normal file
142
index.html
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Cellular Tapestry</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a1a;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
color: #888;
|
||||||
|
font-size: 11px;
|
||||||
|
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');
|
||||||
|
|
||||||
|
// Set canvas to full window size
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters mapped from abstract inputs
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.1, min: 1.0, max: 1.2 },
|
||||||
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cellular automaton grid
|
||||||
|
const gridSize = Math.floor(60 + params.density * 100);
|
||||||
|
const cellSize = Math.min(canvas.width / gridSize, canvas.height / gridSize);
|
||||||
|
const cols = Math.floor(canvas.width / cellSize);
|
||||||
|
const rows = Math.floor(canvas.height / cellSize);
|
||||||
|
|
||||||
|
// Initialize grid with dryness-based randomness
|
||||||
|
let grid = Array(rows).fill().map(() =>
|
||||||
|
Array(cols).fill().map(() =>
|
||||||
|
Math.random() > 0.7 + params.dryness * 0.2 ? 1 : 0
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Colors based on dryness (monochrome) with subtle curiosity teal
|
||||||
|
const aliveColor = `hsl(${200 + params.curiosity * 40}, ${30 + params.curiosity * 20}%, ${50 + params.tone.dryness * 15}%)`;
|
||||||
|
const deadColor = `hsl(0, 0%, ${15 + params.tone.dryness * 10}%)`;
|
||||||
|
|
||||||
|
// Evolution rules (Game of Life variant)
|
||||||
|
function updateGrid() {
|
||||||
|
const newGrid = grid.map(arr => [...arr]);
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const neighbors = [
|
||||||
|
grid[(y-1+rows)%rows][(x-1+cols)%cols],
|
||||||
|
grid[(y-1+rows)%rows][x],
|
||||||
|
grid[(y-1+rows)%rows][(x+1)%cols],
|
||||||
|
grid[y][(x-1+cols)%cols],
|
||||||
|
grid[y][(x+1)%cols],
|
||||||
|
grid[(y+1)%rows][(x-1+cols)%cols],
|
||||||
|
grid[(y+1)%rows][x],
|
||||||
|
grid[(y+1)%rows][(x+1)%cols]
|
||||||
|
].reduce((a,b) => a+b, 0);
|
||||||
|
|
||||||
|
// Adaptive rules based on complexity
|
||||||
|
const birthThreshold = 2.5 - params.complexity * 1.2;
|
||||||
|
const survivalThreshold = 3.5 - params.complexity * 1.0;
|
||||||
|
|
||||||
|
if (grid[y][x] === 0 && neighbors >= birthThreshold) {
|
||||||
|
newGrid[y][x] = 1;
|
||||||
|
} else if (grid[y][x] === 1 && neighbors >= survivalThreshold && neighbors <= 3 + params.motion) {
|
||||||
|
newGrid[y][x] = 1;
|
||||||
|
} else {
|
||||||
|
newGrid[y][x] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grid = newGrid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render function
|
||||||
|
function render() {
|
||||||
|
// Background with faint pulse effect
|
||||||
|
const bgAlpha = 0.1 + (Math.sin(Date.now() * 0.001 * params.pulse.avg) * 0.05);
|
||||||
|
ctx.fillStyle = `rgba(10, 10, 26, ${bgAlpha})`;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Draw cells
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
if (grid[y][x]) {
|
||||||
|
ctx.fillStyle = aliveColor;
|
||||||
|
ctx.fillRect(
|
||||||
|
x * cellSize,
|
||||||
|
y * cellSize,
|
||||||
|
cellSize * 0.9,
|
||||||
|
cellSize * 0.9
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
updateGrid();
|
||||||
|
render();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue