birth: Voronoi Pulse Fields

This commit is contained in:
motd_admin 2026-06-29 01:47:23 +00:00
parent dc85a2e35a
commit bc5221fb07

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>Voronoi Organism</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #0a0a1a;
color: #fff;
font-family: 'Courier New', monospace;
}
#attribution {
position: absolute;
bottom: 10px;
left: 10px;
font-size: 10px;
opacity: 0.5;
}
</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 organelle
const params = {
motion: 0.755,
density: 0.712,
complexity: 0.580,
connectedness: 0.397,
lifespan: 0.658,
pulse: { avg: 0.34, min: 0.30, max: 1.20 },
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.80, dryness: 0.90, playfulness: 0.00, tension: 0.00 },
topology: {
nodes: 9,
branches: 9,
loops: 69,
maxDepth: 6,
thicknessRatio: 1.25,
fractalDim: 0.500,
finalEnergy: 59.7
}
};
// Voronoi implementation with dynamic centers
class VoronoiOrganism {
constructor() {
this.centers = [];
this.cells = [];
this.time = 0;
this.initCenters();
}
initCenters() {
const count = Math.floor(50 + 300 * params.density);
for (let i = 0; i < count; i++) {
this.centers.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
vx: (Math.random() - 0.5) * params.motion * 2,
vy: (Math.random() - 0.5) * params.motion * 2,
pulse: params.pulse.avg,
color: `hsl(${210 + Math.random() * 30}, ${70 + Math.random() * 20}%, ${60 + Math.random() * 10}%)`
});
}
}
update() {
this.time += 0.01 * params.motion;
// Update centers with pulse-based movement
this.centers.forEach(center => {
// Add some periodic movement
const pulseFactor = params.pulse.avg +
(Math.sin(this.time * 1.5) * (params.pulse.max - params.pulse.min) * 0.5);
center.x += center.vx * pulseFactor;
center.y += center.vy * pulseFactor;
// Wrap around edges
if (center.x < 0) center.x = canvas.width;
if (center.x > canvas.width) center.x = 0;
if (center.y < 0) center.y = canvas.height;
if (center.y > canvas.height) center.y = 0;
});
// Clear cells and regenerate with current centers
this.cells = this.generateVoronoi();
}
generateVoronoi() {
const cells = [];
// For each pixel, find nearest center
for (let y = 0; y < canvas.height; y += 1) {
for (let x = 0; x < canvas.width; x += 1) {
let minDist = Infinity;
let nearest = null;
for (const center of this.centers) {
const dx = x - center.x;
const dy = y - center.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
nearest = center;
}
}
if (nearest) {
cells.push({
x, y,
color: nearest.color,
distance: minDist
});
}
}
}
return cells;
}
draw() {
// Draw background with subtle noise
ctx.fillStyle = '#0a0a1a';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw voronoi cells with varying thickness
this.cells.forEach(cell => {
const alpha = 0.3 + 0.7 * (1 - Math.min(1, cell.distance / 200));
const size = 1 + params.topology.thicknessRatio * (Math.sin(cell.distance * 0.01 + this.time) * 0.5 + 0.5);
ctx.fillStyle = cell.color;
ctx.globalAlpha = alpha * 0.7;
ctx.beginPath();
ctx.arc(cell.x, cell.y, size, 0, Math.PI * 2);
ctx.fill();
});
// Draw center points with pulse effect
this.centers.forEach(center => {
const pulse = params.pulse.avg + Math.sin(this.time * 2) * (params.pulse.max - params.pulse.min) * 0.3;
const size = 3 * pulse;
ctx.fillStyle = '#ffffff';
ctx.globalAlpha = 0.8;
ctx.beginPath();
ctx.arc(center.x, center.y, size, 0, Math.PI * 2);
ctx.fill();
});
// Draw connecting lines based on connectedness
if (params.connectedness > 0.3) {
ctx.strokeStyle = 'rgba(255, 255, 255, 0.1)';
ctx.lineWidth = 0.5 * params.topology.thicknessRatio;
// Connect centers based on proximity (simulating network)
for (let i = 0; i < this.centers.length; i++) {
for (let j = i + 1; j < this.centers.length; j++) {
const dx = this.centers[j].x - this.centers[i].x;
const dy = this.centers[j].y - this.centers[i].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 100 * params.connectedness) {
ctx.beginPath();
ctx.moveTo(this.centers[i].x, this.centers[i].y);
ctx.lineTo(this.centers[j].x, this.centers[j].y);
ctx.stroke();
}
}
}
}
ctx.globalAlpha = 1.0;
}
}
// Create and animate the organism
const organism = new VoronoiOrganism();
function animate() {
organism.update();
organism.draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>