birth: Living Voronoi Sigils

This commit is contained in:
motd_admin 2026-11-13 02:21:25 +00:00
parent 38774795f8
commit e40a3936ba

219
index.html Normal file
View file

@ -0,0 +1,219 @@
<!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: #0a0a0a;
font-family: 'Courier New', monospace;
color: #fff;
display: flex;
flex-direction: column;
height: 100vh;
}
canvas {
display: block;
flex: 1;
}
.attribution {
text-align: right;
padding: 10px;
font-size: 10px;
opacity: 0.7;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="attribution">neurameba · motd.social</div>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
// Set canvas to full window size
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
// Parameters derived from abstract inputs
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.05, 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 },
colorScheme: { r: 220, g: 220, b: 220 } // dryness = monochrome
};
// Voronoi structure variables
let sites = [];
let edges = [];
const pointCount = Math.floor(100 + 200 * params.density);
const siteSpeed = 0.5 + params.motion * 0.5;
const cellComplexity = 3 + Math.floor(params.complexity * 3);
const connectionDensity = 0.3 + params.connectedness * 0.4;
const persistence = 0.95 + params.lifespan * 0.05;
const pulseRange = params.pulse.max - params.pulse.min;
// Initialize Voronoi sites
class Site {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = (Math.random() - 0.5) * siteSpeed;
this.vy = (Math.random() - 0.5) * siteSpeed;
this.color = `rgba(${params.colorScheme.r}, ${params.colorScheme.g}, ${params.colorScheme.b}, 0.8)`;
this.originalColor = this.color;
this.life = 1;
this.neighbors = [];
}
update() {
this.x += this.vx;
this.y += this.vy;
// Boundary collision
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
// Apply pulsing effect
const pulseFactor = params.pulse.avg + Math.sin(Date.now() * 0.002) * params.pulse.max * 0.05;
this.color = this.originalColor.replace(/(\d+\.?\d*)(?=\))/, (match) => match * pulseFactor);
}
}
// Initialize sites
for (let i = 0; i < pointCount; i++) {
sites.push(new Site());
}
// Connect sites based on distance
function updateConnections() {
sites.forEach(site => site.neighbors = []);
for (let i = 0; i < sites.length; i++) {
for (let j = i + 1; j < sites.length; j++) {
const d = distance(sites[i], sites[j]);
if (d < 200 * connectionDensity) {
sites[i].neighbors.push(sites[j]);
sites[j].neighbors.push(sites[i]);
}
}
}
}
function distance(a, b) {
return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
}
// Voronoi edge generation (simplified)
function generateEdges() {
edges = [];
sites.forEach(site => {
if (site.neighbors.length > 0) {
site.neighbors.forEach(neighbor => {
// Only draw if this is the closest pair (simplified)
const alreadyConnected = edges.some(e =>
(e.from === site && e.to === neighbor) ||
(e.from === neighbor && e.to === site)
);
if (!alreadyConnected && Math.random() < connectionDensity) {
edges.push({
from: site,
to: neighbor,
thickness: 1 + Math.random() * 2,
alpha: 0.3 + Math.random() * 0.4
});
}
});
}
});
}
// Draw Voronoi cells (simplified representation)
function drawCells() {
// Create a density map for cell boundaries
const gridSize = 10;
const grid = Array(Math.floor(canvas.width/gridSize)).fill().map(() =>
Array(Math.floor(canvas.height/gridSize)).fill(0)
);
sites.forEach(site => {
const cx = Math.floor(site.x / gridSize);
const cy = Math.floor(site.y / gridSize);
for (let i = Math.max(0, cx - 2); i < Math.min(grid.length, cx + 3); i++) {
for (let j = Math.max(0, cy - 2); j < Math.min(grid[0].length, cy + 3); j++) {
if (Math.random() > 0.7) {
grid[i][j] += 1;
}
}
}
});
// Draw cell boundaries
ctx.strokeStyle = `rgba(220, 220, 220, 0.1)`;
ctx.lineWidth = 0.5;
for (let i = 0; i < grid.length - 1; i++) {
for (let j = 0; j < grid[0].length - 1; j++) {
if (grid[i][j] !== grid[i+1][j] ||
grid[i][j] !== grid[i][j+1] ||
grid[i+1][j] !== grid[i][j+1]) {
ctx.beginPath();
ctx.moveTo(i * gridSize, j * gridSize);
ctx.lineTo((i+1) * gridSize, j * gridSize);
ctx.stroke();
}
}
}
}
// Draw connections
function drawConnections() {
edges.forEach(edge => {
ctx.strokeStyle = edge.from.color;
ctx.lineWidth = edge.thickness;
ctx.globalAlpha = edge.alpha;
ctx.beginPath();
ctx.moveTo(edge.from.x, edge.from.y);
ctx.lineTo(edge.to.x, edge.to.y);
ctx.stroke();
});
ctx.globalAlpha = 1;
}
// Main animation loop
function animate() {
// Clear with fade effect
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update and draw
sites.forEach(site => site.update());
updateConnections();
generateEdges();
drawCells();
drawConnections();
requestAnimationFrame(animate);
}
// Start animation
animate();
</script>
</body>
</html>