birth: Wisping Currents in Monochrome

This commit is contained in:
motd_admin 2026-09-08 06:21:23 +00:00
parent 6dee2b3c6b
commit b8f5e19aea

207
index.html Normal file
View file

@ -0,0 +1,207 @@
<!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: #000;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
canvas {
display: block;
}
#attribution {
position: fixed;
bottom: 20px;
color: rgba(255, 255, 255, 0.3);
font-size: 12px;
text-align: center;
width: 100%;
}
</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();
// Parameters derived from input
const motion = 0.5;
const density = 0.5;
const complexity = 0.5;
const connectedness = 0.5;
const lifespan = 0.5;
// Tone parameters
const dryness = 0.9;
const curiosity = 0.1;
// Flow field parameters
const particleCount = Math.floor(100 + 300 * density);
const maxSpeed = 1 + motion * 2;
const chaos = 0.1 + motion * 0.4;
const coherence = 0.3 + connectedness * 0.5;
// Particle properties
const particleLength = 5 + complexity * 10;
const particleThickness = 1 + density * 3;
const decayRate = 0.92 - lifespan * 0.2;
const birthRate = 0.02 + motion * 0.05;
// Color palette (dryness/monochrome with slight teal accent for curiosity)
const baseHue = 60 + curiosity * 30; // Yellow-green teal influence
const baseSaturation = 10 + (1 - dryness) * 20;
const baseValue = 80 + (1 - dryness) * 40;
const brightnessVariation = 30 * (1 - dryness);
class Particle {
constructor() {
this.reset();
}
reset() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = 0;
this.vy = 0;
this.life = Math.random();
this.age = 0;
this.length = particleLength * (0.7 + Math.random() * 0.6);
this.color = `hsl(${baseHue + this.life * 20}, ${baseSaturation}%, ${baseValue + this.life * brightnessVariation}%)`;
}
update(field) {
// Apply flow field influence
const cellX = Math.floor(this.x / 30);
const cellY = Math.floor(this.y / 30);
const angle = field[cellY % field.height][cellX % field.width];
const targetAngle = angle + (Math.random() - 0.5) * chaos;
const force = maxSpeed * 0.2 + maxSpeed * 0.8 * coherence;
this.vx = Math.cos(targetAngle) * force;
this.vy = Math.sin(targetAngle) * force;
// Apply slight noise
this.vx += (Math.random() - 0.5) * 0.5;
this.vy += (Math.random() - 0.5) * 0.5;
// Update position
this.x += this.vx;
this.y += this.vy;
// Boundary conditions
if (this.x < 0) this.x = canvas.width;
if (this.x > canvas.width) this.x = 0;
if (this.y < 0) this.y = canvas.height;
if (this.y > canvas.height) this.y = 0;
// Update life and aging
this.life -= (1 - decayRate) * 0.1;
this.age++;
if (this.age > 200 || this.life < 0) return false;
return true;
}
draw() {
const endX = this.x - this.vx * this.length;
const endY = this.y - this.vy * this.length;
const gradient = ctx.createLinearGradient(this.x, this.y, endX, endY);
const startAlpha = Math.min(1, this.life * 2);
const endAlpha = Math.min(0.3, this.life * 0.6);
gradient.addColorStop(0, `${this.color.replace(')', `, ${startAlpha})`)}`);
gradient.addColorStop(1, `${this.color.replace(')', `, ${endAlpha})`)}`);
ctx.strokeStyle = gradient;
ctx.lineWidth = particleThickness * (0.5 + this.life);
ctx.lineCap = 'round';
ctx.beginPath();
ctx.moveTo(this.x, this.y);
ctx.lineTo(endX, endY);
ctx.stroke();
}
}
// Create flow field
const fieldSize = 30;
const field = Array.from({ length: Math.ceil(canvas.height / fieldSize) }, () =>
Array.from({ length: Math.ceil(canvas.width / fieldSize) }, () => Math.random() * Math.PI * 2)
);
// Add some coherent structures based on connectedness
const structureCount = Math.floor(5 + connectedness * 15);
for (let i = 0; i < structureCount; i++) {
const centerX = Math.random() * canvas.width;
const centerY = Math.random() * canvas.height;
const rotation = Math.random() * Math.PI * 2;
const strength = 0.5 + connectedness * 0.5;
for (let y = 0; y < field.length; y++) {
for (let x = 0; x < field[y].length; x++) {
const dx = x * fieldSize - centerX;
const dy = y * fieldSize - centerY;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 100 + connectedness * 150) {
const angle = Math.atan2(dy, dx) + rotation;
const influence = strength * (1 - dist / 200);
field[y][x] = angle * influence + field[y][x] * (1 - influence);
}
}
}
}
// Create particles
const particles = Array.from({ length: particleCount }, () => new Particle());
function animate() {
// Clear with slight fade for trailing effect
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update and draw particles
for (let i = particles.length - 1; i >= 0; i--) {
if (!particles[i].update(field)) {
particles.splice(i, 1);
// Occasionally spawn new particles
if (Math.random() < birthRate) {
particles.push(new Particle());
}
} else {
particles[i].draw();
}
}
// Occasionally add new particles
if (Math.random() < birthRate && particles.length < particleCount * 1.5) {
particles.push(new Particle());
}
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>