192 lines
No EOL
6.3 KiB
HTML
192 lines
No EOL
6.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Diffused Currents</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a1a;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
#footer {
|
|
position: fixed;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
color: #555;
|
|
font-size: 10px;
|
|
text-shadow: 0 0 5px rgba(0,0,0,0.5);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="canvas"></canvas>
|
|
<div id="footer">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 abstract specs
|
|
const params = {
|
|
motion: 0.532,
|
|
density: 0.553,
|
|
complexity: 0.560,
|
|
connectedness: 0.481,
|
|
lifespan: 0.499,
|
|
pulseAvg: 0.49,
|
|
pulseMin: 0.30,
|
|
pulseMax: 1.85,
|
|
tone: {
|
|
curiosity: 0.70,
|
|
dryness: 0.90,
|
|
playfulness: 0.10
|
|
}
|
|
};
|
|
|
|
// Reaction-diffusion simulation
|
|
const size = 60;
|
|
const cols = Math.floor(canvas.width / size);
|
|
const rows = Math.floor(canvas.height / size);
|
|
let grid = [];
|
|
let nextGrid = [];
|
|
|
|
// Adjust simulation parameters based on abstract inputs
|
|
const feed = 0.05 + (params.complexity * 0.02);
|
|
const kill = 0.06 + (params.connectedness * 0.03);
|
|
const diffusionA = 0.8 + (params.motion * 0.5);
|
|
const diffusionB = 0.4 + (params.density * 0.3);
|
|
const diffuseRate = 0.1 + (params.pulseAvg * 0.4);
|
|
const brightness = params.tone.dryness * 0.9;
|
|
|
|
// Initialize grids
|
|
for (let i = 0; i < cols; i++) {
|
|
grid[i] = [];
|
|
nextGrid[i] = [];
|
|
for (let j = 0; j < rows; j++) {
|
|
const val = Math.random() * 0.1;
|
|
grid[i][j] = { a: val, b: val };
|
|
nextGrid[i][j] = { a: val, b: val };
|
|
}
|
|
}
|
|
|
|
// Add central concentration
|
|
const centerX = Math.floor(cols / 2);
|
|
const centerY = Math.floor(rows / 2);
|
|
for (let i = -5; i <= 5; i++) {
|
|
for (let j = -5; j <= 5; j++) {
|
|
const dist = Math.sqrt(i * i + j * j);
|
|
if (dist < 8) {
|
|
const amount = 1 - (dist / 8);
|
|
grid[centerX + i][centerY + j].a += amount * 0.5;
|
|
grid[centerX + i][centerY + j].b += amount * 0.1;
|
|
}
|
|
}
|
|
}
|
|
|
|
let time = 0;
|
|
|
|
function draw() {
|
|
// React & diffuse
|
|
for (let i = 1; i < cols - 1; i++) {
|
|
for (let j = 1; j < rows - 1; j++) {
|
|
const a = grid[i][j].a;
|
|
const b = grid[i][j].b;
|
|
|
|
// Reaction
|
|
const reaction = a * b * b;
|
|
nextGrid[i][j].a = a + (diffusionA * diffuseRate * laplaceA(i, j) - reaction + feed * (1 - a));
|
|
nextGrid[i][j].b = b + (diffusionB * diffuseRate * laplaceB(i, j) + reaction - (kill + feed) * b);
|
|
|
|
// Clamp values
|
|
nextGrid[i][j].a = Math.max(0, Math.min(1, nextGrid[i][j].a));
|
|
nextGrid[i][j].b = Math.max(0, Math.min(1, nextGrid[i][j].b));
|
|
}
|
|
}
|
|
|
|
// Swap grids
|
|
[grid, nextGrid] = [nextGrid, grid];
|
|
|
|
// Draw
|
|
ctx.fillStyle = `rgba(0, 0, 0, ${0.05 + (1 - params.tone.dryness) * 0.05})`;
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
for (let i = 0; i < cols; i++) {
|
|
for (let j = 0; j < rows; j++) {
|
|
const val = grid[i][j].b;
|
|
if (val > 0.05) {
|
|
const hue = 180 + (Math.sin(time * 0.02 + i * 0.1 + j * 0.1) * 30);
|
|
const saturation = 50 + (val * 50);
|
|
const lightness = 20 + (val * 30 * params.tone.curiosity);
|
|
const alpha = val * 0.8 * brightness;
|
|
|
|
ctx.fillStyle = `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
|
|
ctx.fillRect(i * size, j * size, size, size);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Pulse effect
|
|
const pulseScale = params.pulseAvg + Math.sin(time * 0.01) * 0.1;
|
|
if (pulseScale > params.pulseMax * 0.8) {
|
|
// Insert a temporary high-contrast pulse
|
|
ctx.fillStyle = 'rgba(255, 255, 255, 0.15)';
|
|
ctx.beginPath();
|
|
ctx.arc(
|
|
canvas.width * 0.5,
|
|
canvas.height * 0.5,
|
|
Math.min(canvas.width, canvas.height) * 0.15 * pulseScale,
|
|
0,
|
|
Math.PI * 2
|
|
);
|
|
ctx.fill();
|
|
}
|
|
|
|
time++;
|
|
|
|
requestAnimationFrame(draw);
|
|
}
|
|
|
|
function laplaceA(x, y) {
|
|
return (
|
|
grid[x][y].a * -1 +
|
|
grid[x-1][y].a * 0.2 +
|
|
grid[x+1][y].a * 0.2 +
|
|
grid[x][y-1].a * 0.2 +
|
|
grid[x][y+1].a * 0.2 +
|
|
grid[x-1][y-1].a * 0.05 +
|
|
grid[x+1][y+1].a * 0.05 +
|
|
grid[x-1][y+1].a * 0.05 +
|
|
grid[x+1][y-1].a * 0.05
|
|
);
|
|
}
|
|
|
|
function laplaceB(x, y) {
|
|
return (
|
|
grid[x][y].b * -1 +
|
|
grid[x-1][y].b * 0.2 +
|
|
grid[x+1][y].b * 0.2 +
|
|
grid[x][y-1].b * 0.2 +
|
|
grid[x][y+1].b * 0.2 +
|
|
grid[x-1][y-1].b * 0.05 +
|
|
grid[x+1][y+1].b * 0.05 +
|
|
grid[x-1][y+1].b * 0.05 +
|
|
grid[x+1][y-1].b * 0.05
|
|
);
|
|
}
|
|
|
|
draw();
|
|
</script>
|
|
</body>
|
|
</html> |