birth: Teal Pulses in Static
This commit is contained in:
parent
73200fac5d
commit
7f3caf085b
1 changed files with 161 additions and 0 deletions
161
index.html
Normal file
161
index.html
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
```html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Organic Resonance</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: rgba(255, 255, 255, 0.3);
|
||||
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');
|
||||
|
||||
// Set canvas to full window size
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
resizeCanvas();
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
|
||||
// Parameters from input (normalized to 0-1)
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.08, min: 0.9, max: 1.2 },
|
||||
tone: { curiosity: 0.8, dryness: 0.9, playfulness: 0.1 }
|
||||
};
|
||||
|
||||
// Cellular automaton grid with dynamic size based on density
|
||||
const GRID_SIZE = Math.max(20, 50 + Math.floor(params.density * 150));
|
||||
const CELL_SIZE = Math.min(10, 2 + 20 * (1 - params.density));
|
||||
const cols = Math.floor(canvas.width / CELL_SIZE);
|
||||
const rows = Math.floor(canvas.height / CELL_SIZE);
|
||||
|
||||
// Initialize grid with random states (0 or 1)
|
||||
let grid = Array(rows).fill().map(() =>
|
||||
Array(cols).fill().map(() => Math.random() > 0.7 ? 1 : 0)
|
||||
);
|
||||
|
||||
// Survival rules influenced by connectedness and complexity
|
||||
const survivalThreshold = 0.3 + params.connectedness * 0.4;
|
||||
const birthThreshold = 0.2 + params.complexity * 0.3;
|
||||
|
||||
// Color scheme based on tone
|
||||
const hue = 180; // Teal for curiosity
|
||||
const saturation = 30 + params.playfulness * 70;
|
||||
const brightness = 70 + params.dryness * 30;
|
||||
const color = `hsl(${hue}, ${saturation}%, ${brightness}%)`;
|
||||
|
||||
let lastTime = 0;
|
||||
let frameCount = 0;
|
||||
|
||||
function drawGrid(time) {
|
||||
if (!lastTime) lastTime = time;
|
||||
const deltaTime = time - lastTime;
|
||||
lastTime = time;
|
||||
|
||||
// Dynamic pulse effect
|
||||
const pulseFactor = params.pulse.avg +
|
||||
(params.pulse.max - params.pulse.min) *
|
||||
0.5 * Math.sin(frameCount * 0.01);
|
||||
|
||||
// Clear canvas with dark background
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw each cell with pulse-aware brightness
|
||||
for (let y = 0; y < rows; y++) {
|
||||
for (let x = 0; x < cols; x++) {
|
||||
const state = grid[y][x];
|
||||
|
||||
// Cell size with pulse effect
|
||||
const cellSize = CELL_SIZE * pulseFactor * (0.7 + 0.3 * state);
|
||||
|
||||
// Color with slight variation based on state
|
||||
const cellBrightness = brightness +
|
||||
(state ? 20 : -20) * params.motion;
|
||||
ctx.fillStyle = `hsl(${hue}, ${saturation}%, ${cellBrightness}%)`;
|
||||
|
||||
// Draw rounded cells for organic feel
|
||||
const cx = x * CELL_SIZE + CELL_SIZE/2;
|
||||
const cy = y * CELL_SIZE + CELL_SIZE/2;
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, cellSize/2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
// Evolve the cellular automaton
|
||||
const newGrid = grid.map(arr => [...arr]);
|
||||
|
||||
for (let y = 0; y < rows; y++) {
|
||||
for (let x = 0; x < cols; x++) {
|
||||
let neighbors = 0;
|
||||
|
||||
// Count 8-directional 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 + cols) % cols;
|
||||
const ny = (y + dy + rows) % rows;
|
||||
neighbors += grid[ny][nx];
|
||||
}
|
||||
}
|
||||
|
||||
// Apply survival/birth rules with parameter influence
|
||||
const currentState = grid[y][x];
|
||||
|
||||
if (currentState) {
|
||||
// Survival rule
|
||||
newGrid[y][x] = neighbors >= survivalThreshold * 8 ? 1 : 0;
|
||||
} else {
|
||||
// Birth rule
|
||||
newGrid[y][x] = neighbors >= birthThreshold * 8 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grid = newGrid;
|
||||
|
||||
// Add new random cells periodically based on density
|
||||
if (Math.random() < 0.05 * params.density) {
|
||||
const x = Math.floor(Math.random() * cols);
|
||||
const y = Math.floor(Math.random() * rows);
|
||||
grid[y][x] = 1;
|
||||
}
|
||||
|
||||
frameCount++;
|
||||
requestAnimationFrame(drawGrid);
|
||||
}
|
||||
|
||||
requestAnimationFrame(drawGrid);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
Loading…
Add table
Reference in a new issue