birth: Veins of the Unseen

This commit is contained in:
motd_admin 2026-11-11 02:21:25 +00:00
parent efdc7ea876
commit 1d62bff9ad

204
index.html Normal file
View file

@ -0,0 +1,204 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flow Field Organism</title>
<style>
body { margin: 0; overflow: hidden; background: #0a0a0a; }
canvas { display: block; }
#attribution {
position: fixed;
bottom: 10px;
right: 10px;
color: #333;
font-family: monospace;
font-size: 10px;
text-shadow: 0 0 5px #fff;
}
</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();
// Flow field parameters
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.07, min: 1.0, max: 1.1 },
tone: { anger: 0.0, sadness: 0.0, curiosity: 0.1, dryness: 0.9, playfulness: 0.0, tension: 0.0 }
};
// Initialize flow field
const fieldResolution = 30 * (1 - params.density) + 10;
const field = createFlowField(fieldResolution, fieldResolution);
// Particle system
const particles = [];
const particleCount = 100 + Math.floor(50 * params.density);
const particleSize = 1 + (1 - params.dryness) * 3;
// Particle class
class Particle {
constructor() {
this.reset();
this.age = 0;
this.lifespan = 100 + Math.random() * 200 * (1 - params.lifespan);
this.noiseOffset = Math.random() * 1000;
}
reset() {
this.pos = {
x: Math.random() * canvas.width,
y: Math.random() * canvas.height
};
this.vel = { x: 0, y: 0 };
this.prevPos = { ...this.pos };
}
update() {
this.age++;
if (this.age > this.lifespan) {
this.reset();
this.age = 0;
}
// Sample flow field
const gridX = Math.floor(this.pos.x / (canvas.width / field.width));
const gridY = Math.floor(this.pos.y / (canvas.height / field.height));
const flow = field[gridX][gridY];
// Update velocity with some randomness
this.vel.x = flow[0] * params.pulse.avg + (Math.random() - 0.5) * params.motion;
this.vel.y = flow[1] * params.pulse.avg + (Math.random() - 0.5) * params.motion;
// Clamp velocity
const speed = Math.sqrt(this.vel.x * this.vel.x + this.vel.y * this.vel.y);
if (speed > 5) {
this.vel.x = this.vel.x / speed * 5;
this.vel.y = this.vel.y / speed * 5;
}
// Update position
this.prevPos.x = this.pos.x;
this.prevPos.y = this.pos.y;
this.pos.x += this.vel.x;
this.pos.y += this.vel.y;
// Wrap around edges
if (this.pos.x < 0) this.pos.x = canvas.width;
if (this.pos.x > canvas.width) this.pos.x = 0;
if (this.pos.y < 0) this.pos.y = canvas.height;
if (this.pos.y > canvas.height) this.pos.y = 0;
}
draw() {
const progress = this.age / this.lifespan;
const size = particleSize * (1 - progress * 0.7);
const alpha = 1 - progress * 0.8;
const hue = 200 + 30 * params.tone.curiosity;
ctx.strokeStyle = `hsla(${hue}, 80%, 60%, ${alpha})`;
ctx.lineWidth = size;
ctx.beginPath();
ctx.moveTo(this.prevPos.x, this.prevPos.y);
ctx.lineTo(this.pos.x, this.pos.y);
ctx.stroke();
}
}
// Create particles
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
// Flow field generation
function createFlowField(width, height) {
const field = [];
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
for (let x = 0; x < width; x++) {
field[x] = [];
for (let y = 0; y < height; y++) {
const relX = (x / width - 0.5) * 2;
const relY = (y / height - 0.5) * 2;
const angle = Math.atan2(relY, relX) + Math.PI;
const length = 0.1 + 0.9 * (1 - params.complexity * 0.5);
field[x][y] = [
Math.cos(angle) * length,
Math.sin(angle) * length
];
}
}
return field;
}
// Draw flow field (optional visualization)
function drawFlowField() {
if (params.tone.dryness < 0.3) {
ctx.globalAlpha = 0.1;
ctx.strokeStyle = 'white';
ctx.lineWidth = 0.5;
for (let x = 0; x < field.length; x++) {
for (let y = 0; y < field[x].length; y++) {
const fx = x / field.length * canvas.width;
const fy = y / field[x].length * canvas.height;
const flow = field[x][y];
ctx.beginPath();
ctx.moveTo(fx, fy);
ctx.lineTo(fx + flow[0] * 20, fy + flow[1] * 20);
ctx.stroke();
}
}
ctx.globalAlpha = 1.0;
}
}
// Animation loop
let lastTime = 0;
function animate(time) {
const deltaTime = time - lastTime;
lastTime = time;
// Update pulse
params.pulse.avg = params.pulse.min + (params.pulse.max - params.pulse.min) *
(0.5 + 0.5 * Math.sin(time * 0.001));
// Clear with fade
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update and draw particles
particles.forEach(p => {
p.update();
p.draw();
});
// Optional flow field visualization
drawFlowField();
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>