birth: Pulsing cellular murmurs
This commit is contained in:
parent
ac25a10625
commit
1a752505cb
1 changed files with 165 additions and 0 deletions
165
index.html
Normal file
165
index.html
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Motd</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a1a;
|
||||
font-family: 'Courier New', monospace;
|
||||
color: #a0a0a0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
font-size: 10px;
|
||||
opacity: 0.5;
|
||||
mix-blend-mode: difference;
|
||||
}
|
||||
</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 resize() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resize);
|
||||
resize();
|
||||
|
||||
// Parameters based on input
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulseAvg: 1.07,
|
||||
pulseMin: 0.9,
|
||||
pulseMax: 1.2,
|
||||
tone: {
|
||||
anger: 0,
|
||||
sadness: 0,
|
||||
curiosity: 0.7,
|
||||
dryness: 0.9,
|
||||
playfulness: 0.1,
|
||||
tension: 0
|
||||
}
|
||||
};
|
||||
|
||||
// Cellular automata grid
|
||||
const gridSize = Math.floor(50 + params.density * 50);
|
||||
const cellSize = Math.min(
|
||||
Math.floor(canvas.width / gridSize),
|
||||
Math.floor(canvas.height / gridSize)
|
||||
);
|
||||
|
||||
const gridWidth = Math.floor(canvas.width / cellSize);
|
||||
const gridHeight = Math.floor(canvas.height / cellSize);
|
||||
|
||||
let grid = Array(gridWidth).fill().map(() =>
|
||||
Array(gridHeight).fill(0).map(() =>
|
||||
Math.random() < 0.5 ? 1 : 0
|
||||
)
|
||||
);
|
||||
|
||||
// State for next generation
|
||||
const nextGrid = Array(gridWidth).fill().map(() =>
|
||||
Array(gridHeight).fill(0)
|
||||
);
|
||||
|
||||
// Color palette based on parameters
|
||||
const curiosity = 0.7;
|
||||
const dryness = 0.9;
|
||||
const hue = 180 + Math.floor(curiosity * 60);
|
||||
const sat = 50 + Math.floor(dryness * 50);
|
||||
const light = 50 + Math.floor(curiosity * 50);
|
||||
|
||||
function getColor(state) {
|
||||
if (state === 0) return 'rgba(0, 0, 0, 0)';
|
||||
const alpha = 0.3 + state * (0.7 - 0.3 * params.lifespan);
|
||||
return `hsl(${hue}, ${sat}%, ${light}%, ${alpha})`;
|
||||
}
|
||||
|
||||
// Cellular automata rules
|
||||
function updateGrid() {
|
||||
for (let x = 0; x < gridWidth; x++) {
|
||||
for (let y = 0; y < gridHeight; y++) {
|
||||
const neighbors = [
|
||||
[x-1, y-1], [x, y-1], [x+1, y-1],
|
||||
[x-1, y], [x+1, y],
|
||||
[x-1, y+1], [x, y+1], [x+1, y+1]
|
||||
].filter(([nx, ny]) =>
|
||||
nx >= 0 && nx < gridWidth && ny >= 0 && ny < gridHeight
|
||||
).reduce((sum, [nx, ny]) =>
|
||||
sum + grid[nx][ny]
|
||||
, 0);
|
||||
|
||||
// Conway's Game of Life with slight mutation
|
||||
if (grid[x][y] === 1) {
|
||||
nextGrid[x][y] = neighbors < 2 || neighbors > 3 ? 0 : 1;
|
||||
} else {
|
||||
nextGrid[x][y] = neighbors === 3 ? 1 : 0;
|
||||
}
|
||||
|
||||
// Add some randomness based on motion
|
||||
if (Math.random() < params.motion * 0.01) {
|
||||
nextGrid[x][y] = Math.random() > 0.5 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Swap grids
|
||||
[grid, nextGrid].forEach(g => g.fill().map(row => row.fill(0)));
|
||||
for (let x = 0; x < gridWidth; x++) {
|
||||
for (let y = 0; y < gridHeight; y++) {
|
||||
grid[x][y] = nextGrid[x][y];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
// Background fade
|
||||
ctx.fillStyle = 'rgba(10, 10, 26, 0.1)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw cellular automata
|
||||
for (let x = 0; x < gridWidth; x++) {
|
||||
for (let y = 0; y < gridHeight; y++) {
|
||||
if (grid[x][y] > 0) {
|
||||
const cellX = x * cellSize;
|
||||
const cellY = y * cellSize;
|
||||
const size = cellSize * (0.3 + grid[x][y] * 0.7 * params.pulseAvg);
|
||||
ctx.fillStyle = getColor(grid[x][y]);
|
||||
ctx.fillRect(cellX, cellY, size, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update grid periodically
|
||||
if (Math.random() < params.complexity * 0.02) {
|
||||
updateGrid();
|
||||
}
|
||||
|
||||
requestAnimationFrame(draw);
|
||||
}
|
||||
|
||||
draw();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue