birth: Circuit Breath of Static
This commit is contained in:
parent
5b48dfb629
commit
785901ad4d
1 changed files with 149 additions and 0 deletions
149
index.html
Normal file
149
index.html
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba · motd.social</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: #555;
|
||||||
|
font-size: 10px;
|
||||||
|
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');
|
||||||
|
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters from prompt
|
||||||
|
const motion = 0.5;
|
||||||
|
const density = 0.5;
|
||||||
|
const complexity = 0.5;
|
||||||
|
const connectedness = 0.5;
|
||||||
|
const lifespan = 0.5;
|
||||||
|
const pulseAvg = 1.1;
|
||||||
|
const dryness = 0.8;
|
||||||
|
const playfulness = 0.1;
|
||||||
|
|
||||||
|
// Derived values
|
||||||
|
const cols = Math.floor(10 + density * 30);
|
||||||
|
const rows = Math.floor(10 + density * 30);
|
||||||
|
const cellSize = Math.min(canvas.width / cols, canvas.height / rows);
|
||||||
|
const grid = Array(rows).fill().map(() => Array(cols).fill(0));
|
||||||
|
const nextGrid = Array(rows).fill().map(() => Array(cols).fill(0));
|
||||||
|
|
||||||
|
// Colors based on parameters
|
||||||
|
const bgColor = '#0a0a0a';
|
||||||
|
const cellColors = dryness > 0.5
|
||||||
|
? ['#333', '#555', '#777']
|
||||||
|
: ['#f0f0f0', '#d0d0d0', '#a0a0a0'];
|
||||||
|
|
||||||
|
function initGrid() {
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
grid[y][x] = Math.random() < 0.1 ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateGrid() {
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const neighbors = countNeighbors(x, y);
|
||||||
|
const current = grid[y][x];
|
||||||
|
|
||||||
|
// Cellular automata rules
|
||||||
|
if (current === 1) {
|
||||||
|
nextGrid[y][x] = neighbors >= 2 && neighbors <= 3 ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
nextGrid[y][x] = neighbors === 3 ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap grids
|
||||||
|
[grid, nextGrid] = [nextGrid, grid];
|
||||||
|
}
|
||||||
|
|
||||||
|
function countNeighbors(x, y) {
|
||||||
|
let count = 0;
|
||||||
|
for (let dy = -1; dy <= 1; dy++) {
|
||||||
|
for (let dx = -1; dx <= 1; dx++) {
|
||||||
|
if (dx === 0 && dy === 0) continue;
|
||||||
|
const nx = (x + dx + cols) % cols;
|
||||||
|
const ny = (y + dy + rows) % rows;
|
||||||
|
count += grid[ny][nx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawGrid() {
|
||||||
|
ctx.fillStyle = bgColor;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
if (grid[y][x] === 1) {
|
||||||
|
const color = cellColors[Math.floor(Math.random() * cellColors.length)];
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
|
||||||
|
const px = x * cellSize;
|
||||||
|
const py = y * cellSize;
|
||||||
|
const size = cellSize * 0.8;
|
||||||
|
|
||||||
|
// Add variation based on complexity
|
||||||
|
const variation = complexity * 0.5 + 0.5;
|
||||||
|
ctx.fillRect(px + cellSize * (0.1 * Math.random() * variation),
|
||||||
|
py + cellSize * (0.1 * Math.random() * variation),
|
||||||
|
size * variation,
|
||||||
|
size * variation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
// Add pulse variation
|
||||||
|
const pulse = pulseAvg * (0.9 + 0.2 * Math.random());
|
||||||
|
const updateInterval = Math.max(10, 100 / (motion * 4 + 1));
|
||||||
|
|
||||||
|
if (Math.random() < 0.02 * pulse) {
|
||||||
|
initGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
drawGrid();
|
||||||
|
updateGrid();
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
initGrid();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue