organic-resonance-shifts-7izx/index.html

188 lines
No EOL
5.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>Organic Resonance</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
color: rgba(255, 255, 255, 0.3);
font-family: monospace;
font-size: 10px;
}
</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;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Configuration based on parameters
const config = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: 1.06,
tone: {
anger: 0.00,
sadness: 0.00,
curiosity: 0.10,
dryness: 0.90,
playfulness: 0.00,
tension: 0.00
}
};
// Cellular automata grid
const gridSize = Math.max(32, Math.min(64, Math.round(32 + config.complexity * 32)));
const cellSize = Math.min(16, Math.max(4, 16 - Math.floor(config.density * 12)));
const rows = Math.floor(canvas.height / cellSize);
const cols = Math.floor(canvas.width / cellSize);
// Initialize grid
let grid = new Array(rows).fill().map(() => new Array(cols).fill(0));
// Random seed based on parameters
Math.seedrandom('organism-' + JSON.stringify(config));
// Initialize with random cells
function initGrid() {
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
grid[y][x] = Math.random() < 0.3 ? 1 : 0;
}
}
}
initGrid();
// Cellular automata rules
function updateGrid() {
const newGrid = grid.map(arr => [...arr]);
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
const neighbors = countNeighbors(x, y);
// Conway-like rules with more variation
if (grid[y][x] === 1) {
newGrid[y][x] = neighbors >= 2 && neighbors <= 4 ? 1 : 0;
} else {
newGrid[y][x] = neighbors === 3 || neighbors === 5 ? 1 : 0;
}
}
}
grid = newGrid;
}
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;
const ny = y + dy;
if (nx >= 0 && nx < cols && ny >= 0 && ny < rows) {
count += grid[ny][nx];
}
}
}
return count;
}
// Color palette
function getColor(value) {
const dryness = config.tone.dryness;
if (dryness > 0.7) {
// Monochrome palette
const intensity = value * 0.8 + 0.2;
return `rgba(255, 255, 255, ${intensity})`;
} else {
// More variation
const hue = 180 + Math.sin(Date.now() * 0.001) * 30;
const saturation = 70 + value * 30;
const lightness = 40 + value * 20;
return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
}
}
// Drawing function
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
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] > 0) {
const cellValue = grid[y][x];
const alpha = cellValue * 0.7 + 0.3;
ctx.fillStyle = getColor(cellValue);
ctx.globalAlpha = alpha;
const px = x * cellSize;
const py = y * cellSize;
// Draw irregular shapes based on cell state
ctx.beginPath();
ctx.arc(
px + cellSize * 0.5 + Math.sin(y * 0.1 + Date.now() * 0.001) * 2,
py + cellSize * 0.5 + Math.cos(x * 0.1 + Date.now() * 0.002) * 2,
cellSize * 0.3 + Math.sin(x * 0.1) * 0.5,
0,
Math.PI * 2
);
ctx.fill();
}
}
}
ctx.globalAlpha = 1;
updateGrid();
}
// Animation loop
function animate() {
draw();
requestAnimationFrame(animate);
}
// Start animation
animate();
// Clean up on unload
window.addEventListener('beforeunload', () => {
cancelAnimationFrame(animate);
});
</script>
</body>
</html>