birth: Flickering Thought Patterns
This commit is contained in:
parent
02fbebecf3
commit
6f53c78794
1 changed files with 172 additions and 0 deletions
172
index.html
Normal file
172
index.html
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neural Mists</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
color: rgba(255, 255, 255, 0.3);
|
||||||
|
font-size: 12px;
|
||||||
|
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 derived from the generative art specifications
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.06, min: 0.9, max: 1.2 },
|
||||||
|
color: {
|
||||||
|
anger: 0.0,
|
||||||
|
sadness: 0.0,
|
||||||
|
curiosity: 0.7,
|
||||||
|
dryness: 0.9,
|
||||||
|
playfulness: 0.0,
|
||||||
|
tension: 0.0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cellular automata grid
|
||||||
|
const gridSize = 40;
|
||||||
|
const cellSize = Math.min(20, Math.max(8, window.innerWidth / gridSize));
|
||||||
|
const cols = Math.floor(window.innerWidth / cellSize);
|
||||||
|
const rows = Math.floor(window.innerHeight / cellSize);
|
||||||
|
|
||||||
|
// Initialize grid
|
||||||
|
let grid = Array(rows).fill().map(() => Array(cols).fill(0));
|
||||||
|
let nextGrid = Array(rows).fill().map(() => Array(cols).fill(0));
|
||||||
|
|
||||||
|
// Initialize with random state based on density
|
||||||
|
function initGrid() {
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
grid[y][x] = Math.random() < params.density ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cellular automata rules
|
||||||
|
function updateGrid() {
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
let neighbors = 0;
|
||||||
|
|
||||||
|
// Count neighbors (Moore neighborhood)
|
||||||
|
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 Game of Life rules with variation
|
||||||
|
const isAlive = grid[y][x] === 1;
|
||||||
|
const aliveNeighbors = neighbors;
|
||||||
|
|
||||||
|
if (isAlive) {
|
||||||
|
nextGrid[y][x] = aliveNeighbors >= 2 && aliveNeighbors <= 3 ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
nextGrid[y][x] = aliveNeighbors === 3 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add some complexity variation
|
||||||
|
if (Math.random() < 0.05 * params.complexity) {
|
||||||
|
nextGrid[y][x] = Math.random() < 0.5 ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap grids
|
||||||
|
[grid, nextGrid] = [nextGrid, grid];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Color palette based on parameters
|
||||||
|
function getColor(value) {
|
||||||
|
if (value === 0) return 'rgba(0, 0, 0, 0)';
|
||||||
|
|
||||||
|
// Curiosity (teals) with dryness (monochrome)
|
||||||
|
const baseHue = 180 + Math.sin(Date.now() * 0.001) * 20;
|
||||||
|
const saturation = 70 + Math.sin(Date.now() * 0.0005) * 15;
|
||||||
|
const lightness = 40 + Math.sin(Date.now() * 0.0002) * 10;
|
||||||
|
const alpha = 0.7 + Math.sin(x * 0.1 + Date.now() * 0.002) * 0.3;
|
||||||
|
|
||||||
|
return `hsl(${baseHue}, ${saturation}%, ${lightness}%, ${alpha})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the grid
|
||||||
|
function draw() {
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const cellValue = grid[y][x];
|
||||||
|
if (cellValue > 0) {
|
||||||
|
ctx.fillStyle = getColor(cellValue);
|
||||||
|
ctx.fillRect(x * cellSize, y * cellSize, cellSize, cellSize);
|
||||||
|
|
||||||
|
// Add some subtle motion based on pulse
|
||||||
|
const pulseFactor = params.pulse.avg + Math.sin(Date.now() * 0.002 + x * 0.1 + y * 0.05) * 0.1;
|
||||||
|
ctx.globalAlpha = cellValue * 0.1 * pulseFactor;
|
||||||
|
ctx.fillStyle = 'rgba(255, 255, 255, 0.1)';
|
||||||
|
ctx.fillRect(
|
||||||
|
x * cellSize + Math.sin(Date.now() * 0.001 + x) * 2,
|
||||||
|
y * cellSize + Math.cos(Date.now() * 0.001 + y) * 2,
|
||||||
|
cellSize * 0.8,
|
||||||
|
cellSize * 0.8
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.globalAlpha = 1.0;
|
||||||
|
updateGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start everything
|
||||||
|
initGrid();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue