birth: Static Bloom in Fracture
This commit is contained in:
parent
1786ed68fd
commit
5e3a1370f7
1 changed files with 159 additions and 0 deletions
159
index.html
Normal file
159
index.html
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Static Bloom</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
color: #fff;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 20px;
|
||||||
|
font-size: 11px;
|
||||||
|
opacity: 0.7;
|
||||||
|
text-shadow: 0 0 5px rgba(255,255,255,0.3);
|
||||||
|
}
|
||||||
|
</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 input
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.06, min: 1.0, max: 1.1 },
|
||||||
|
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.9, playfulness: 0, tension: 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reaction-diffusion parameters
|
||||||
|
const RD = {
|
||||||
|
feedRate: 0.055 + params.complexity * 0.02,
|
||||||
|
killRate: 0.062 + params.complexity * 0.015,
|
||||||
|
diffusionA: 1.0,
|
||||||
|
diffusionB: 0.5,
|
||||||
|
timeStep: 0.16,
|
||||||
|
width: Math.floor(canvas.width / 2),
|
||||||
|
height: Math.floor(canvas.height / 2)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize grids
|
||||||
|
let grid = [];
|
||||||
|
let next = [];
|
||||||
|
for (let i = 0; i < RD.width; i++) {
|
||||||
|
grid[i] = [];
|
||||||
|
next[i] = [];
|
||||||
|
for (let j = 0; j < RD.height; j++) {
|
||||||
|
grid[i][j] = { a: 1, b: 0 };
|
||||||
|
next[i][j] = { a: 1, b: 0 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add initial randomness
|
||||||
|
for (let i = 0; i < RD.width; i++) {
|
||||||
|
for (let j = 0; j < RD.height; j++) {
|
||||||
|
if (Math.random() < 0.1 * params.density) {
|
||||||
|
grid[i][j].b = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Color palette
|
||||||
|
const palette = params.tone.dryness > 0.8 ?
|
||||||
|
{ a: '#f0f0f0', b: '#333333', bg: '#0a0a0a' } :
|
||||||
|
{ a: '#ff00ff', b: '#00ffff', bg: '#0a0a0a' };
|
||||||
|
|
||||||
|
function updateGrid() {
|
||||||
|
const pulseScale = params.pulse.avg * (1 + Math.sin(Date.now() * 0.001) * 0.05);
|
||||||
|
const dA = RD.diffusionA * params.motion * pulseScale;
|
||||||
|
const dB = RD.diffusionB * params.motion * pulseScale;
|
||||||
|
|
||||||
|
for (let i = 1; i < RD.width - 1; i++) {
|
||||||
|
for (let j = 1; j < RD.height - 1; j++) {
|
||||||
|
const a = grid[i][j].a;
|
||||||
|
const b = grid[i][j].b;
|
||||||
|
|
||||||
|
// Reaction
|
||||||
|
const reaction = a * b * b;
|
||||||
|
const newA = a + (dA * laplaceA(i, j) - reaction) * RD.timeStep;
|
||||||
|
const newB = b + (dB * laplaceB(i, j) + reaction) * RD.timeStep;
|
||||||
|
|
||||||
|
next[i][j].a = Math.min(Math.max(newA, 0), 1);
|
||||||
|
next[i][j].b = Math.min(Math.max(newB, 0), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap grids
|
||||||
|
[grid, next] = [next, grid];
|
||||||
|
}
|
||||||
|
|
||||||
|
function laplaceA(x, y) {
|
||||||
|
return (grid[x-1][y].a + grid[x+1][y].a + grid[x][y-1].a + grid[x][y+1].a) * 0.2 +
|
||||||
|
(grid[x-1][y-1].a + grid[x+1][y-1].a + grid[x-1][y+1].a + grid[x+1][y+1].a) * 0.05 -
|
||||||
|
grid[x][y].a * 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
function laplaceB(x, y) {
|
||||||
|
return (grid[x-1][y].b + grid[x+1][y].b + grid[x][y-1].b + grid[x][y+1].b) * 0.2 +
|
||||||
|
(grid[x-1][y-1].b + grid[x+1][y-1].b + grid[x-1][y+1].b + grid[x+1][y+1].b) * 0.05 -
|
||||||
|
grid[x][y].b * 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
const imageData = ctx.createImageData(RD.width, RD.height);
|
||||||
|
const data = imageData.data;
|
||||||
|
|
||||||
|
for (let i = 0; i < RD.width; i++) {
|
||||||
|
for (let j = 0; j < RD.height; j++) {
|
||||||
|
const idx = (j * RD.width + i) * 4;
|
||||||
|
const valB = grid[i][j].b;
|
||||||
|
|
||||||
|
// Color mapping
|
||||||
|
if (params.tone.dryness > 0.8) {
|
||||||
|
data[idx] = data[idx + 1] = data[idx + 2] = valB * 255;
|
||||||
|
} else {
|
||||||
|
data[idx] = valB * 255;
|
||||||
|
data[idx + 1] = 0;
|
||||||
|
data[idx + 2] = 255 - valB * 255;
|
||||||
|
}
|
||||||
|
data[idx + 3] = valB * 255 * 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.putImageData(imageData, 0, 0, 0, 0, RD.width, RD.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
updateGrid();
|
||||||
|
draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue