145 lines
No EOL
4.8 KiB
HTML
145 lines
No EOL
4.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Dry Cellular Echoes</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
#attribution {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
color: #333;
|
|
font-size: 10px;
|
|
text-shadow: 0 0 5px #fff;
|
|
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 based on generative art builder input
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.05, min: 1.0, max: 1.1 },
|
|
tone: { dryness: 0.9, curiosity: 0.1 }
|
|
};
|
|
|
|
// Cellular automata grid
|
|
const cols = Math.floor(canvas.width / 8) + 2;
|
|
const rows = Math.floor(canvas.height / 8) + 2;
|
|
const grid = Array(rows).fill().map(() => Array(cols).fill(0));
|
|
const nextGrid = Array(rows).fill().map(() => Array(cols).fill(0));
|
|
|
|
// Initialize grid with dry, sparse patterns
|
|
function initGrid() {
|
|
for (let y = 0; y < rows; y++) {
|
|
for (let x = 0; x < cols; x++) {
|
|
// Low density with some curiosity (teal) patterns
|
|
grid[y][x] = (Math.random() < params.density * 0.2) ? 1 + params.tone.curiosity * 2 : 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Cellular automata rules (Game of Life variant)
|
|
function updateGrid() {
|
|
for (let y = 0; y < rows; y++) {
|
|
for (let x = 0; x < cols; x++) {
|
|
let neighbors = 0;
|
|
|
|
// Count dead neighbors
|
|
for (let dy = -1; dy <= 1; dy++) {
|
|
for (let dx = -1; dx <= 1; dx++) {
|
|
if (dx === 0 && dy === 0) continue;
|
|
const nx = x + dx;
|
|
const ny = y + dy;
|
|
if (nx >= 0 && nx < cols && ny >= 0 && ny < rows) {
|
|
neighbors += grid[ny][nx] > 0 ? 1 : 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Rules favoring dryness (high dead neighbor threshold)
|
|
if (grid[y][x] > 0) {
|
|
nextGrid[y][x] = (neighbors >= 2 && neighbors <= 3) ? 1 : 0;
|
|
} else {
|
|
nextGrid[y][x] = (neighbors === 3) ? 0.5 : 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Swap grids
|
|
[grid, nextGrid] = [nextGrid, grid];
|
|
}
|
|
|
|
// Draw function
|
|
function draw() {
|
|
// Semi-transparent overlay for motion blur effect
|
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Get pulse factor
|
|
const pulse = params.pulse.avg + Math.sin(Date.now() * 0.001) * (params.pulse.max - params.pulse.min) * 0.1;
|
|
|
|
for (let y = 0; y < rows; y++) {
|
|
for (let x = 0; x < cols; x++) {
|
|
if (grid[y][x] > 0) {
|
|
// Dryness color (monochrome with slight variation)
|
|
const value = grid[y][x] * 0.7 + 0.3;
|
|
const hue = (value * 30) % 360;
|
|
ctx.fillStyle = `hsl(${hue}, ${10 + grid[y][x] * 15}%, ${20 + value * 30}%)`;
|
|
|
|
// Add some curiosity (teal) to living cells
|
|
if (params.tone.curiosity > 0) {
|
|
ctx.fillStyle = `hsl(${200 + grid[y][x] * 60}, 60%, ${30 + value * 20}%)`;
|
|
}
|
|
|
|
const px = x * 8 * pulse;
|
|
const py = y * 8 * pulse;
|
|
const size = 8 * grid[y][x] * pulse;
|
|
|
|
ctx.fillRect(px, py, size, size);
|
|
}
|
|
}
|
|
}
|
|
|
|
updateGrid();
|
|
}
|
|
|
|
// Animation loop
|
|
function animate() {
|
|
draw();
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
initGrid();
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |