teal-echoes-in-silent-react.../index.html

204 lines
No EOL
6.7 KiB
HTML

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neurameba Motion</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
display: block;
}
#info {
position: absolute;
bottom: 20px;
color: #444;
font-family: monospace;
font-size: 10px;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="info">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 generative input
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: 1.07,
tone: {
anger: 0.0,
sadness: 0.0,
curiosity: 0.7,
dryness: 0.8,
playfulness: 0.2,
tension: 0.0
}
};
// Color palette based on tone
const palette = [
`hsl(180, 30%, ${70 + params.tone.curiosity * 20}%)`, // teal base
`hsl(180, 40%, ${60 + params.tone.curiosity * 10}%)`,
`hsl(0, 0%, ${params.tone.dryness > 0.7 ? 20 : 40}%)`, // monochrome
`hsl(0, 0%, ${params.tone.dryness > 0.7 ? 80 : 60}%)`
];
// Reaction-diffusion system
const GRID_SIZE = 100;
const CELL_SIZE = Math.min(canvas.width, canvas.height) / GRID_SIZE;
const grid = Array(GRID_SIZE).fill().map(() =>
Array(GRID_SIZE).fill().map(() => ({
a: Math.random() * 0.1,
b: Math.random() * 0.1,
history: []
}))
);
function updateGrid() {
const newGrid = grid.map(row => row.map(cell => ({...cell})));
const feed = 0.055 + Math.sin(Date.now() * 0.001 * params.pulse) * 0.01;
const kill = 0.062 + Math.cos(Date.now() * 0.0008 * params.pulse) * 0.01;
for (let y = 1; y < GRID_SIZE - 1; y++) {
for (let x = 1; x < GRID_SIZE - 1; x++) {
const cell = grid[y][x];
const a = cell.a;
const b = cell.b;
// Reaction-diffusion equations
const newA = a +
(0.1 * laplacian(grid, x, y, 'a') -
a * b * b +
feed * (1 - a)) * params.motion;
const newB = b +
(0.05 * laplacian(grid, x, y, 'b') +
a * b * b -
(kill + feed) * b) * params.motion;
newGrid[y][x].a = Math.max(0, Math.min(1, newA));
newGrid[y][x].b = Math.max(0, Math.min(1, newB));
// Store history for trails
if (params.lifespan > 0.3) {
newGrid[y][x].history.push({
a: newA,
b: newB,
t: Date.now()
});
if (newGrid[y][x].history.length > 3) {
newGrid[y][x].history.shift();
}
}
}
}
return newGrid;
}
function laplacian(grid, x, y, type) {
let sum = 0;
for (let dy = -1; dy <= 1; dy++) {
for (let dx = -1; dx <= 1; dx++) {
if (dx === 0 && dy === 0) continue;
sum += grid[y + dy][x + dx][type];
}
}
return sum / 8 - grid[y][x][type];
}
function draw() {
// Fade with pulse
ctx.fillStyle = `rgba(0, 0, 0, ${0.05 + 0.95 * (1 - params.pulse * 0.5)})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
const newGrid = updateGrid();
// Draw cells with trails
const cellWidth = canvas.width / GRID_SIZE;
const cellHeight = canvas.height / GRID_SIZE;
for (let y = 0; y < GRID_SIZE; y++) {
for (let x = 0; x < GRID_SIZE; x++) {
const cell = newGrid[y][x];
const a = cell.a;
const b = cell.b;
// Draw trail
if (params.lifespan > 0.3 && cell.history.length > 0) {
ctx.strokeStyle = palette[2];
ctx.lineWidth = 1;
ctx.beginPath();
for (let i = 0; i < cell.history.length; i++) {
const h = cell.history[i];
const alpha = 1 - (Date.now() - h.t) / 3000;
if (alpha <= 0) continue;
const px = x * cellWidth + cellWidth / 2;
const py = y * cellHeight + cellHeight / 2;
ctx.globalAlpha = alpha * 0.7;
ctx.moveTo(px, py);
}
ctx.stroke();
ctx.globalAlpha = 1;
}
// Draw current state
if (a > 0.05 || b > 0.05) {
const hue = 180 + (b * 100);
const saturation = 50 + (a * 30);
const lightness = 30 + (a * 40);
ctx.fillStyle = `hsl(${hue}, ${saturation}%, ${lightness}%)`;
ctx.beginPath();
ctx.arc(
x * cellWidth + cellWidth / 2,
y * cellHeight + cellHeight / 2,
cellWidth * 0.4 * (a + b * 0.5),
0,
Math.PI * 2
);
ctx.fill();
}
}
}
grid.length = 0;
grid.push(...newGrid.map(row => row.map(cell => ({...cell, history: []}))));
requestAnimationFrame(draw);
}
draw();
</script>
</body>
</html>
```