diffuse-quiet-architectures.../index.html

201 lines
No EOL
6.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>diffuse equilibrium</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
color: #666;
font-family: 'Courier New', monospace;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100vh;
}
canvas {
display: block;
}
#info {
padding: 20px;
font-size: 12px;
text-align: right;
background: rgba(0,0,0,0.3);
}
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="info">neurameba · motd.social</div>
<script>
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
// Parameters from prompt
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.09, min: 0.95, max: 1.20 },
tone: { anger: 0.0, sadness: 0.0, curiosity: 0.1, dryness: 0.9, playfulness: 0.0, tension: 0.0 }
};
// Reaction-diffusion simulation
const W = Math.floor(canvas.width / 2);
const H = Math.floor(canvas.height / 2);
const size = 2;
const cols = Math.ceil(W / size);
const rows = Math.ceil(H / size);
let current = new Float32Array(cols * rows * 4);
let next = new Float32Array(cols * rows * 4);
// Init with sparse random values
function init() {
const total = cols * rows;
for (let i = 0; i < total; i++) {
// Dryness = monochrome, low contrast
const val = 0.1 + Math.random() * 0.2;
current[i*4] = val;
current[i*4+1] = val;
current[i*4+2] = val;
current[i*4+3] = 1;
}
// Add sparse complexity
for (let i = 0; i < total * params.complexity; i++) {
const idx = Math.floor(Math.random() * total) * 4;
current[idx] = 0.3 + Math.random() * 0.4;
current[idx+1] = 0.3 + Math.random() * 0.4;
current[idx+2] = 0.3 + Math.random() * 0.4;
}
}
function laplacian(i, j, channel) {
let sum = 0;
let count = 0;
for (let di = -1; di <= 1; di++) {
for (let dj = -1; dj <= 1; dj++) {
if (di === 0 && dj === 0) continue;
const ni = i + di;
const nj = j + dj;
if (ni >= 0 && ni < rows && nj >= 0 && nj < cols) {
sum += current[(ni*cols + nj)*4 + channel];
count++;
}
}
}
return sum / count - current[(i*cols + j)*4 + channel];
}
// Gray-Scott reaction terms
function step() {
const F = 0.055;
const K = 0.062;
const dt = 0.1;
const diffusionA = 1.0;
const diffusionB = 0.5;
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
const idx = (i*cols + j)*4;
const a = current[idx];
const b = current[idx+1];
const c = current[idx+2];
const laplacianA = laplacian(i, j, 0);
const laplacianB = laplacian(i, j, 1);
// Gray-Scott equations
const reactionA = a * b * b;
const reactionB = a * b * b;
next[idx] = a + (diffusionA * laplacianA - reactionA) * dt;
next[idx+1] = b + (diffusionB * laplacianB + reactionA - reactionB) * dt;
next[idx+2] = c + (0.1 * laplacian(i, j, 2)) * dt;
next[idx+3] = 1;
}
}
// Swap buffers
[current, next] = [next, current];
// Apply connectivity (blur based on connectedness)
if (params.connectedness > 0.3) {
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
const idx = (i*cols + j)*4;
const blur = params.connectedness * 0.2;
current[idx] = current[idx] * (1 - blur) + laplacian(i, j, 0) * blur;
current[idx+1] = current[idx+1] * (1 - blur) + laplacian(i, j, 1) * blur;
current[idx+2] = current[idx+2] * (1 - blur) + laplacian(i, j, 2) * blur;
}
}
}
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Motion affects step size
const pulseFactor = params.pulse.avg * (0.9 + Math.sin(Date.now() * 0.001) * 0.1);
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
const idx = (i*cols + j)*4;
const a = current[idx];
const b = current[idx+1];
const c = current[idx+2];
// Dryness = low contrast, monochrome
const val = (a + b + c) / 3;
ctx.fillStyle = `rgba(255, 255, 255, ${val * pulseFactor})`;
ctx.fillRect(j * size * 2, i * size * 2, size * 2, size * 2);
}
}
// Add subtle variation for complexity
if (Math.random() < params.complexity * 0.01) {
const i = Math.floor(Math.random() * rows);
const j = Math.floor(Math.random() * cols);
const idx = (i*cols + j)*4;
current[idx] = 0.5 + Math.random() * 0.3;
current[idx+1] = 0.5 + Math.random() * 0.3;
current[idx+2] = 0.5 + Math.random() * 0.3;
}
step();
}
init();
let lastTime = 0;
function animate(time) {
if (!lastTime) lastTime = time;
const delta = time - lastTime;
lastTime = time;
// Slow update rate for higher motion
if (Math.random() < params.motion * 0.02) {
draw();
}
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>