static-hum-of-neurons-xrnr/index.html

152 lines
No EOL
5.1 KiB
HTML

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Static Hum</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
color: #333;
}
#canvas {
display: block;
}
#attribution {
position: fixed;
bottom: 10px;
right: 10px;
font-size: 10px;
color: #444;
z-index: 10;
}
</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();
// Configuration derived from parameters
const config = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.1, min: 1.0, max: 1.3 },
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.8, playfulness: 0, tension: 0 }
};
// Cellular automaton setup
const gridSize = 32;
const cols = Math.floor(canvas.width / gridSize) + 2;
const rows = Math.floor(canvas.height / gridSize) + 2;
const grid = new Array(cols * rows).fill(0);
// Initialize with density parameter
function initializeGrid() {
for (let i = 0; i < grid.length; i++) {
grid[i] = Math.random() < config.density ? 1 : 0;
}
}
// CA rules with complexity influencing neighborhood size
function updateGrid() {
const newGrid = new Array(grid.length).fill(0);
const neighborhoodSize = Math.max(1, Math.floor(config.complexity * 4));
for (let i = 0; i < grid.length; i++) {
const x = i % cols;
const y = Math.floor(i / cols);
// Get neighborhood sum with wrap-around
let sum = 0;
for (let nx = -1; nx <= 1; nx++) {
for (let ny = -1; ny <= 1; ny++) {
const nx2 = (x + nx + cols) % cols;
const ny2 = (y + ny + rows) % rows;
sum += grid[nx2 + ny2 * cols];
}
}
sum -= grid[i]; // Don't count self
// Conway-like rules but with continuous values
const alive = grid[i];
const neighbors = sum;
if (alive) {
// Survival with randomness based on lifespan
newGrid[i] = (neighbors >= 2 && neighbors <= 5) ||
(Math.random() * 2 < config.lifespan) ? 1 : 0;
} else {
// Birth with randomness based on motion
newGrid[i] = (neighbors >= 3 && neighbors <= 6) &&
(Math.random() * 2 < config.motion) ? 1 : 0;
}
}
// Apply pulse variation
const pulseFactor = config.pulse.avg + (config.pulse.max - config.pulse.min) *
Math.sin(Date.now() * 0.001) * 0.33;
for (let i = 0; i < grid.length; i++) {
grid[i] = newGrid[i];
}
return pulseFactor;
}
// Drawing with dryness-based monochrome palette
function drawGrid(pulseFactor) {
const cellSize = gridSize * (0.8 + 0.2 * config.motion * pulseFactor);
const alpha = 0.7 + 0.3 * config.motion * (0.5 + Math.sin(Date.now() * 0.002) * 0.5);
ctx.fillStyle = `rgba(220, 220, 200, ${alpha * 0.05})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (let i = 0; i < grid.length; i++) {
if (grid[i]) {
const x = (i % cols) * gridSize - gridSize;
const y = Math.floor(i / cols) * gridSize - gridSize;
const hue = 0; // Dryness is monochrome
const saturation = 0;
const value = 180 + 50 * Math.sin(Date.now() * 0.001 + i * 0.1);
const lightness = 80 + 10 * Math.sin(Date.now() * 0.003 + i * 0.05);
ctx.fillStyle = `hsl(${hue}, ${saturation}%, ${lightness}%)`;
ctx.beginPath();
ctx.arc(x + gridSize/2, y + gridSize/2, cellSize/2 * (0.5 + 0.5 * config.density), 0, Math.PI * 2);
ctx.fill();
}
}
}
// Animation loop
function animate() {
const pulseFactor = updateGrid();
drawGrid(pulseFactor);
requestAnimationFrame(animate);
}
initializeGrid();
animate();
</script>
</body>
</html>
```