birth: Flickering Static Structures
This commit is contained in:
parent
70f18dee51
commit
68c2cfa78c
1 changed files with 137 additions and 0 deletions
137
index.html
Normal file
137
index.html
Normal file
|
|
@ -0,0 +1,137 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Tense Grid</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: #444;
|
||||||
|
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();
|
||||||
|
|
||||||
|
// Generate a simple buffer for cellular automata
|
||||||
|
const gridWidth = 32;
|
||||||
|
const gridHeight = 18;
|
||||||
|
const cellSize = Math.min(
|
||||||
|
Math.floor(canvas.width / gridWidth),
|
||||||
|
Math.floor(canvas.height / gridHeight)
|
||||||
|
);
|
||||||
|
|
||||||
|
let grid = Array(gridHeight).fill().map(() =>
|
||||||
|
Array(gridWidth).fill().map(() => Math.random() < 0.5 ? 1 : 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
// State for rendering effects
|
||||||
|
let hue = 0;
|
||||||
|
let frameCount = 0;
|
||||||
|
|
||||||
|
function updateGrid() {
|
||||||
|
const newGrid = grid.map(row => [...row]);
|
||||||
|
|
||||||
|
for (let y = 0; y < gridHeight; y++) {
|
||||||
|
for (let x = 0; x < gridWidth; x++) {
|
||||||
|
const neighbors = [
|
||||||
|
[y-1, x-1], [y-1, x], [y-1, x+1],
|
||||||
|
[y, x-1], [y, x+1],
|
||||||
|
[y+1, x-1], [y+1, x], [y+1, x+1]
|
||||||
|
].filter(([ny, nx]) =>
|
||||||
|
ny >= 0 && ny < gridHeight && nx >= 0 && nx < gridWidth
|
||||||
|
).reduce((sum, [ny, nx]) => sum + grid[ny][nx], 0);
|
||||||
|
|
||||||
|
// Survival rules favoring moderate activity
|
||||||
|
if (grid[y][x] === 1) {
|
||||||
|
newGrid[y][x] = neighbors === 2 || neighbors === 3 ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
newGrid[y][x] = neighbors === 3 ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grid = newGrid;
|
||||||
|
frameCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
// Clear with dark background
|
||||||
|
ctx.fillStyle = '#0a0a0a';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Calculate cell size based on current dimensions
|
||||||
|
const cellWidth = canvas.width / gridWidth;
|
||||||
|
const cellHeight = canvas.height / gridHeight;
|
||||||
|
|
||||||
|
// Draw minimalist grid with pulsing patterns
|
||||||
|
for (let y = 0; y < gridHeight; y++) {
|
||||||
|
for (let x = 0; x < gridWidth; x++) {
|
||||||
|
if (grid[y][x] === 1) {
|
||||||
|
const intensity = (Math.sin(frameCount * 0.05 + x * 0.1 + y * 0.1) * 0.5 + 0.5);
|
||||||
|
const baseHue = 60; // Yellow-green
|
||||||
|
const saturation = 10 + intensity * 50;
|
||||||
|
const lightness = 30 + intensity * 20;
|
||||||
|
const alpha = 0.7 + intensity * 0.3;
|
||||||
|
|
||||||
|
ctx.fillStyle = `hsla(${baseHue}, ${saturation}%, ${lightness}%, ${alpha})`;
|
||||||
|
ctx.fillRect(
|
||||||
|
x * cellWidth,
|
||||||
|
y * cellHeight,
|
||||||
|
cellWidth - 1,
|
||||||
|
cellHeight - 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtle pulse based on frame count
|
||||||
|
hue = (hue + 0.1) % 360;
|
||||||
|
ctx.strokeStyle = `hsla(${hue}, 10%, 20%, 0.1)`;
|
||||||
|
ctx.lineWidth = 0.5;
|
||||||
|
ctx.beginPath();
|
||||||
|
|
||||||
|
// Draw a grid overlay that pulses
|
||||||
|
for (let x = 0; x < gridWidth; x++) {
|
||||||
|
ctx.moveTo(x * cellWidth, 0);
|
||||||
|
ctx.lineTo(x * cellWidth, canvas.height);
|
||||||
|
}
|
||||||
|
for (let y = 0; y < gridHeight; y++) {
|
||||||
|
ctx.moveTo(0, y * cellHeight);
|
||||||
|
ctx.lineTo(canvas.width, y * cellHeight);
|
||||||
|
}
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
updateGrid();
|
||||||
|
requestAnimationFrame(draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
draw();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue