teal-tremors-in-the-grid-f5tb/index.html

230 lines
8.4 KiB
HTML
Raw Normal View History

2026-03-25 21:38:42 +00:00
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Teal Tremors</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: #4a5c5e;
font-size: 10px;
text-align: center;
width: 100%;
}
</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 generative art input
const params = {
motion: 0.494,
density: 0.427,
complexity: 0.580,
connectedness: 0.487,
lifespan: 0.470,
survivingNodes: 140,
branchCount: 135,
loops: 1974,
maxDepth: 54,
thicknessRatio: 1.25,
fractalDim: 0.839,
finalEnergy: 4155.2,
pulse: { avg: 0.47, min: 0.30, max: 2.00 },
tone: {
anger: 0.00,
sadness: 0.00,
curiosity: 0.80,
dryness: 0.90,
playfulness: 0.10,
tension: 0.00
}
};
// Reaction-diffusion agent parameters
const agentCount = Math.floor(params.survivingNodes * 3);
const diffusionRate = 0.3;
const reactionRate = 0.7;
const feedRate = 0.055;
const killRate = 0.062;
const stepSize = 0.1;
// Initialize grids
const size = Math.min(canvas.width, canvas.height);
const gridWidth = Math.floor(canvas.width / 4);
const gridHeight = Math.floor(canvas.height / 4);
const agents = [];
const feed = new Array(gridWidth * gridHeight).fill(0);
const kill = new Array(gridWidth * gridHeight).fill(0);
const concentration = new Array(gridWidth * gridHeight).fill(0);
// Initialize agents
for (let i = 0; i < agentCount; i++) {
agents.push({
x: Math.random() * gridWidth,
y: Math.random() * gridHeight,
vx: (Math.random() - 0.5) * params.motion * 2,
vy: (Math.random() - 0.5) * params.motion * 2,
radius: 1 + Math.random() * 2 * params.thicknessRatio,
hue: 180 + Math.random() * 20,
sat: 50 + Math.random() * 30,
lum: 60 + Math.random() * 20,
life: Math.random() * params.lifespan * 100,
maxLife: Math.random() * params.lifespan * 100 + 50
});
}
// Initialize feed/kill patterns
for (let y = 0; y < gridHeight; y++) {
for (let x = 0; x < gridWidth; x++) {
const idx = y * gridWidth + x;
feed[idx] = Math.sin(x * 0.1) * Math.cos(y * 0.1) * 0.1 + 0.05;
kill[idx] = Math.cos(x * 0.05) * Math.sin(y * 0.05) * 0.1 + 0.05;
}
}
function update() {
// Clear with semi-transparent overlay
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Diffusion step
for (let i = 0; i < agents.length; i++) {
const a = agents[i];
a.x += a.vx;
a.y += a.vy;
// Wrap around edges
a.x = (a.x + gridWidth) % gridWidth;
a.y = (a.y + gridHeight) % gridHeight;
// Update concentration
const idx = Math.floor(a.y) * gridWidth + Math.floor(a.x);
concentration[idx] += 0.1;
}
// Reaction-diffusion simulation
const newConcentration = new Array(gridWidth * gridHeight).fill(0);
for (let y = 0; y < gridHeight; y++) {
for (let x = 0; x < gridWidth; x++) {
const idx = y * gridWidth + x;
const c = concentration[idx];
const f = feed[idx];
const k = kill[idx];
// Gray-Scott model
const lap = (concentration[(y-1)*gridWidth + x] +
concentration[(y+1)*gridWidth + x] +
concentration[y*gridWidth + (x-1)] +
concentration[y*gridWidth + (x+1)] -
4 * c) * diffusionRate;
const reaction = c * c * (f - (k + 1)) + f;
newConcentration[idx] = Math.min(1, Math.max(0, c + lap * stepSize + reaction * stepSize * params.complexity));
}
}
// Update agents based on concentration
for (let i = agents.length - 1; i >= 0; i--) {
const a = agents[i];
const idx = Math.floor(a.y) * gridWidth + Math.floor(a.x);
const localConcentration = newConcentration[idx];
// Move toward higher concentration areas
a.vx += (Math.random() - 0.5) * params.motion * 0.1;
a.vy += (Math.random() - 0.5) * params.motion * 0.1;
// Adjust properties based on concentration
a.radius = 1 + localConcentration * 3 * params.thicknessRatio;
a.hue = 180 + localConcentration * 20;
a.sat = 50 + localConcentration * 30;
a.lum = 60 + localConcentration * 20;
a.life += params.lifespan;
// Remove dead agents
if (a.life > a.maxLife || Math.random() < params.motion * 0.01) {
agents.splice(i, 1);
// Create new agent
agents.push({
x: Math.random() * gridWidth,
y: Math.random() * gridHeight,
vx: (Math.random() - 0.5) * params.motion * 2,
vy: (Math.random() - 0.5) * params.motion * 2,
radius: 1 + Math.random() * 2 * params.thicknessRatio,
hue: 180 + Math.random() * 20,
sat: 50 + Math.random() * 30,
lum: 60 + Math.random() * 20,
life: 0,
maxLife: 1000 * params.lifespan
});
}
// Draw agent
const screenX = (a.x / gridWidth) * canvas.width;
const screenY = (a.y / gridHeight) * canvas.height;
const globalConcentration = concentration[idx] * 100;
ctx.beginPath();
ctx.arc(screenX, screenY, a.radius * 2, 0, Math.PI * 2);
ctx.fillStyle = `hsla(${a.hue}, ${a.sat}%, ${a.lum - globalConcentration * 0.5}%, ${0.2 + globalConcentration * 0.005})`;
ctx.fill();
}
// Draw some feed/kill patterns
ctx.globalAlpha = 0.1;
for (let y = 0; y < gridHeight; y += 5) {
for (let x = 0; x < gridWidth; x += 5) {
const idx = y * gridWidth + x;
const sx = (x / gridWidth) * canvas.width;
const sy = (y / gridHeight) * canvas.height;
ctx.strokeStyle = `hsl(180, 50%, ${50 + feed[idx] * 30}%)`;
ctx.beginPath();
ctx.arc(sx, sy, 2, 0, Math.PI * 2);
ctx.stroke();
ctx.strokeStyle = `hsl(0, 50%, ${50 + kill[idx] * 30}%)`;
ctx.beginPath();
ctx.arc(sx + 5, sy, 2, 0, Math.PI * 2);
ctx.stroke();
}
}
ctx.globalAlpha = 1;
requestAnimationFrame(update);
}
update();
</script>
</body>
</html>
```