birth: Flowing Quiet Curiosity
This commit is contained in:
parent
c6a168fdf3
commit
e7019b7409
1 changed files with 321 additions and 0 deletions
321
index.html
Normal file
321
index.html
Normal file
|
|
@ -0,0 +1,321 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Flow Field</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #0a0a0a;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 11px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</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();
|
||||||
|
|
||||||
|
// Flow field parameters derived from organism specs
|
||||||
|
const params = {
|
||||||
|
motion: 0.523,
|
||||||
|
density: 0.530,
|
||||||
|
complexity: 0.445,
|
||||||
|
connectedness: 0.487,
|
||||||
|
lifespan: 0.498,
|
||||||
|
pulse: {
|
||||||
|
avg: 0.70,
|
||||||
|
min: 0.30,
|
||||||
|
max: 1.85
|
||||||
|
},
|
||||||
|
tone: {
|
||||||
|
curiosity: 0.70,
|
||||||
|
dryness: 0.90,
|
||||||
|
playfulness: 0.10
|
||||||
|
},
|
||||||
|
topology: {
|
||||||
|
nodes: 84,
|
||||||
|
branchCount: 66,
|
||||||
|
loops: 187,
|
||||||
|
maxDepth: 18,
|
||||||
|
thicknessRatio: 1.50,
|
||||||
|
fractalDimension: 1.661
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Flow field implementation
|
||||||
|
const particles = [];
|
||||||
|
const flowField = [];
|
||||||
|
const flowResolution = 30 * (1 + params.complexity * 2);
|
||||||
|
const particleCount = 100 * params.density;
|
||||||
|
|
||||||
|
// Initialize flow field with Perlin noise variations
|
||||||
|
function initFlowField() {
|
||||||
|
for (let y = 0; y < canvas.height; y += flowResolution) {
|
||||||
|
for (let x = 0; x < canvas.width; x += flowResolution) {
|
||||||
|
const index = (y / flowResolution) * (canvas.width / flowResolution) + (x / flowResolution);
|
||||||
|
flowField[index] = {
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
vx: 0,
|
||||||
|
vy: 0,
|
||||||
|
strength: 0,
|
||||||
|
pulse: params.pulse.avg
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add noise-based flow patterns
|
||||||
|
for (let i = 0; i < flowField.length; i++) {
|
||||||
|
const x = flowField[i].x / canvas.width;
|
||||||
|
const y = flowField[i].y / canvas.height;
|
||||||
|
const angle = noise(x * 3, y * 3) * Math.PI * 2;
|
||||||
|
const strength = noise(x * 1.5 + 100, y * 1.5 + 100) * 0.5 + 0.5;
|
||||||
|
flowField[i].vx = Math.cos(angle) * strength * 2;
|
||||||
|
flowField[i].vy = Math.sin(angle) * strength * 2;
|
||||||
|
flowField[i].strength = strength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perlin noise implementation (simplified)
|
||||||
|
const p = new Array(512);
|
||||||
|
const permutation = [151,160,137,91,90,15,
|
||||||
|
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
|
||||||
|
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
|
||||||
|
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
|
||||||
|
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
|
||||||
|
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
|
||||||
|
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
|
||||||
|
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
|
||||||
|
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
|
||||||
|
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
|
||||||
|
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
|
||||||
|
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
|
||||||
|
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];
|
||||||
|
|
||||||
|
for (let i=0; i < 256 ; i++) {
|
||||||
|
p[i] = p[i + 256] = permutation[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
function noise(x, y, z) {
|
||||||
|
const X = Math.floor(x) & 255;
|
||||||
|
const Y = Math.floor(y) & 255;
|
||||||
|
const Z = Math.floor(z) & 255;
|
||||||
|
|
||||||
|
x -= Math.floor(x);
|
||||||
|
y -= Math.floor(y);
|
||||||
|
z -= Math.floor(z);
|
||||||
|
|
||||||
|
const u = fade(x);
|
||||||
|
const v = fade(y);
|
||||||
|
const w = fade(z);
|
||||||
|
|
||||||
|
const A = p[X ]+Y;
|
||||||
|
const AA = p[A]+Z;
|
||||||
|
const AB = p[A+1]+Z;
|
||||||
|
const B = p[X+1]+Y;
|
||||||
|
const BA = p[B]+Z;
|
||||||
|
const BB = p[B+1]+Z;
|
||||||
|
|
||||||
|
return lerp(w, lerp(v, lerp(u, grad(p[AA ], x , y , z ),
|
||||||
|
grad(p[BA ], x-1, y , z )),
|
||||||
|
lerp(u, grad(p[AB ], x , y-1, z ),
|
||||||
|
grad(p[BB ], x-1, y-1, z ))),
|
||||||
|
lerp(v, lerp(u, grad(p[AA+1], x , y , z-1 ),
|
||||||
|
grad(p[BA+1], x-1, y , z-1 )),
|
||||||
|
lerp(u, grad(p[AB+1], x , y-1, z-1 ),
|
||||||
|
grad(p[BB+1], x-1, y-1, z-1 ))));
|
||||||
|
}
|
||||||
|
|
||||||
|
function fade(t) {
|
||||||
|
return t * t * t * (t * (t * 6 - 15) + 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
function lerp(t, a, b) {
|
||||||
|
return a + t * (b - a);
|
||||||
|
}
|
||||||
|
|
||||||
|
function grad(hash, x, y, z) {
|
||||||
|
const h = hash & 15;
|
||||||
|
const u = h < 8 ? x : y;
|
||||||
|
const v = h < 4 ? y : h === 12 || h === 14 ? x : z;
|
||||||
|
return ((h & 1) === 0 ? u : -u) + ((h & 2) === 0 ? v : -v);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Particle class
|
||||||
|
class Particle {
|
||||||
|
constructor() {
|
||||||
|
this.reset();
|
||||||
|
this.prevX = this.x;
|
||||||
|
this.prevY = this.y;
|
||||||
|
this.history = [];
|
||||||
|
this.size = 1 + Math.random() * 2 * params.density;
|
||||||
|
this.maxHistory = 20 + Math.random() * 40;
|
||||||
|
this.color = `hsl(180, ${70 + Math.random() * 30}%, ${80 + Math.random() * 10}%)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.x = Math.random() * canvas.width;
|
||||||
|
this.y = Math.random() * canvas.height;
|
||||||
|
this.speed = 0.5 + Math.random() * params.motion * 2;
|
||||||
|
this.vx = 0;
|
||||||
|
this.vy = 0;
|
||||||
|
this.lifespan = params.lifespan * (0.5 + Math.random() * 0.5);
|
||||||
|
this.age = 0;
|
||||||
|
this.opacity = params.tone.dryness > 0.8 ? 0.8 : Math.random() * 0.5 + 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.prevX = this.x;
|
||||||
|
this.prevY = this.y;
|
||||||
|
|
||||||
|
// Find nearest flow field point
|
||||||
|
const gridX = Math.floor(this.x / flowResolution);
|
||||||
|
const gridY = Math.floor(this.y / flowResolution);
|
||||||
|
const index = gridY * (canvas.width / flowResolution) + gridX;
|
||||||
|
const field = flowField[index];
|
||||||
|
|
||||||
|
// Update velocity with field influence
|
||||||
|
this.vx = field.vx * this.speed * field.pulse;
|
||||||
|
this.vy = field.vy * this.speed * field.pulse;
|
||||||
|
|
||||||
|
// Add small randomness
|
||||||
|
this.vx += (Math.random() - 0.5) * 0.3;
|
||||||
|
this.vy += (Math.random() - 0.5) * 0.3;
|
||||||
|
|
||||||
|
// Update position
|
||||||
|
this.x += this.vx;
|
||||||
|
this.y += this.vy;
|
||||||
|
|
||||||
|
// Boundary checks
|
||||||
|
if (this.x < 0) {
|
||||||
|
this.x = canvas.width;
|
||||||
|
this.prevX = this.x;
|
||||||
|
} else if (this.x > canvas.width) {
|
||||||
|
this.x = 0;
|
||||||
|
this.prevX = this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.y < 0) {
|
||||||
|
this.y = canvas.height;
|
||||||
|
this.prevY = this.y;
|
||||||
|
} else if (this.y > canvas.height) {
|
||||||
|
this.y = 0;
|
||||||
|
this.prevY = this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update history
|
||||||
|
this.history.push({x: this.x, y: this.y});
|
||||||
|
if (this.history.length > this.maxHistory) {
|
||||||
|
this.history.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update age and pulse
|
||||||
|
this.age++;
|
||||||
|
field.pulse = params.pulse.avg + (params.pulse.max - params.pulse.min) *
|
||||||
|
(0.5 + 0.5 * Math.sin(Date.now() * 0.001 * params.pulse.avg));
|
||||||
|
|
||||||
|
// Fade out near edges
|
||||||
|
const edgeDist = Math.min(
|
||||||
|
this.x / 100,
|
||||||
|
(canvas.width - this.x) / 100,
|
||||||
|
this.y / 100,
|
||||||
|
(canvas.height - this.y) / 100
|
||||||
|
);
|
||||||
|
this.opacity = edgeDist * 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.strokeStyle = this.color;
|
||||||
|
ctx.lineWidth = this.size;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.prevX, this.prevY);
|
||||||
|
|
||||||
|
// Draw history with decreasing opacity
|
||||||
|
for (let i = 0; i < this.history.length; i++) {
|
||||||
|
const point = this.history[i];
|
||||||
|
const opacity = this.opacity * (i / this.history.length);
|
||||||
|
ctx.globalAlpha = opacity;
|
||||||
|
ctx.lineTo(point.x, point.y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.globalAlpha = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize particles
|
||||||
|
function initParticles() {
|
||||||
|
particles.length = 0;
|
||||||
|
for (let i = 0; i < particleCount; i++) {
|
||||||
|
particles.push(new Particle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
// Dark background with subtle noise texture
|
||||||
|
ctx.fillStyle = `rgba(0, 0, 0, ${0.95 - params.motion * 0.1})`;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Draw subtle noise pattern
|
||||||
|
if (params.tone.dryness > 0.8) {
|
||||||
|
drawNoiseTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update and draw particles
|
||||||
|
particles.forEach(particle => {
|
||||||
|
particle.update();
|
||||||
|
particle.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawNoiseTexture() {
|
||||||
|
ctx.fillStyle = 'rgba(5, 5, 10, 0.1)';
|
||||||
|
for (let i = 0; i < canvas.width * canvas.height * 0.0002; i++) {
|
||||||
|
const x = Math.random() * canvas.width;
|
||||||
|
const y = Math.random() * canvas.height;
|
||||||
|
const size = Math.random() * 0.5;
|
||||||
|
const opacity = Math.random() * 0.05;
|
||||||
|
ctx.fillRect(x, y, size, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start animation
|
||||||
|
initFlowField();
|
||||||
|
initParticles();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue