birth: Organic Voronoi Pulse Fields
This commit is contained in:
parent
ac84defcfd
commit
30b4e89c0c
1 changed files with 304 additions and 0 deletions
304
index.html
Normal file
304
index.html
Normal file
|
|
@ -0,0 +1,304 @@
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Organic Voronoi Bloom</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #0a0a1a;
|
||||||
|
color: #f0f0f0;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
#canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 10px;
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
</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();
|
||||||
|
|
||||||
|
// Parameters derived from the specification
|
||||||
|
const params = {
|
||||||
|
motion: 0.546,
|
||||||
|
density: 0.519,
|
||||||
|
complexity: 0.492,
|
||||||
|
connectedness: 0.498,
|
||||||
|
lifespan: 0.567,
|
||||||
|
pulse: { avg: 0.70, min: 0.30, max: 1.90 },
|
||||||
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.70, dryness: 0.90, playfulness: 0.10, tension: 0.00 },
|
||||||
|
topology: {
|
||||||
|
nodes: 77,
|
||||||
|
branches: 58,
|
||||||
|
loops: 153,
|
||||||
|
maxDepth: 19,
|
||||||
|
thicknessRatio: 1.75,
|
||||||
|
fractalDim: 1.616,
|
||||||
|
energy: 378.8
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cellular automaton grid
|
||||||
|
const gridSize = Math.floor(120 + params.density * 80);
|
||||||
|
const cellSize = Math.min(canvas.width, canvas.height) / gridSize;
|
||||||
|
const cols = Math.ceil(canvas.width / cellSize);
|
||||||
|
const rows = Math.ceil(canvas.height / cellSize);
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
let points = [];
|
||||||
|
let edges = [];
|
||||||
|
let time = 0;
|
||||||
|
let energy = params.topology.energy;
|
||||||
|
const pulseScale = params.pulse.avg + Math.sin(time * 0.5) * (params.pulse.max - params.pulse.min) * 0.3;
|
||||||
|
|
||||||
|
// Palette based on tone parameters
|
||||||
|
const huePrimary = 170 + (Math.sin(time * 0.1) * 20); // teal/cyan for curiosity
|
||||||
|
const saturation = params.tone.dryness < 0.5 ? 0.8 : 0.4; // lower for dryness
|
||||||
|
const brightness = params.tone.playfulness > 0.5 ? 1.0 : 0.8;
|
||||||
|
const palette = {
|
||||||
|
bg: '#0a0a1a',
|
||||||
|
point: `hsl(${huePrimary}, ${saturation * 100}%, ${brightness * 30 + 10}%)`,
|
||||||
|
edge: `hsl(${huePrimary}, ${saturation * 70}%, ${brightness * 40 + 5}%)`,
|
||||||
|
highlight: `hsl(${huePrimary}, ${saturation * 50}%, ${brightness * 60}%)`
|
||||||
|
};
|
||||||
|
|
||||||
|
// Generate Voronoi points with controlled randomness
|
||||||
|
function generatePoints() {
|
||||||
|
points = [];
|
||||||
|
const pointCount = Math.floor(params.topology.nodes * (0.7 + params.connectedness * 0.8));
|
||||||
|
|
||||||
|
for (let i = 0; i < pointCount; i++) {
|
||||||
|
// Cluster points toward center with perturbations
|
||||||
|
const angle = Math.random() * Math.PI * 2;
|
||||||
|
const distance = Math.random() * 0.4 + 0.3;
|
||||||
|
const centerX = canvas.width / 2;
|
||||||
|
const centerY = canvas.height / 2;
|
||||||
|
|
||||||
|
const x = centerX + Math.cos(angle) * distance * canvas.width * (0.5 + Math.random() * 0.2);
|
||||||
|
const y = centerY + Math.sin(angle) * distance * canvas.height * (0.5 + Math.random() * 0.2);
|
||||||
|
|
||||||
|
// Add some deterministic movement based on time
|
||||||
|
const orbitX = Math.cos(time * 0.03 + i * 0.05) * 20;
|
||||||
|
const orbitY = Math.sin(time * 0.03 + i * 0.05) * 15;
|
||||||
|
|
||||||
|
points.push({
|
||||||
|
x: x + orbitX,
|
||||||
|
y: y + orbitY,
|
||||||
|
baseX: x,
|
||||||
|
baseY: y,
|
||||||
|
size: 1 + Math.random() * params.density * 2,
|
||||||
|
lifespan: params.lifespan > 0.5 ? Infinity : Math.random() * 500 + 200
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate edges with controlled complexity
|
||||||
|
function generateEdges() {
|
||||||
|
edges = [];
|
||||||
|
const possibleEdges = [];
|
||||||
|
|
||||||
|
// Delaunay-like edges (limited to nearby points)
|
||||||
|
for (let i = 0; i < points.length; i++) {
|
||||||
|
const point = points[i];
|
||||||
|
const nearPoints = points.filter((p, j) => {
|
||||||
|
if (i === j) return false;
|
||||||
|
const dist = Math.sqrt((p.x - point.x) ** 2 + (p.y - point.y) ** 2);
|
||||||
|
return dist < canvas.width * 0.2 * (0.7 + params.complexity * 0.6);
|
||||||
|
}).sort((a, b) => {
|
||||||
|
// Sort by angle for Delaunay-like connections
|
||||||
|
const angleA = Math.atan2(a.y - point.y, a.x - point.x);
|
||||||
|
const angleB = Math.atan2(b.y - point.y, b.x - point.x);
|
||||||
|
return angleA - angleB;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Connect to nearest 3-5 points based on complexity
|
||||||
|
const connectCount = Math.max(2, Math.floor(2 + params.complexity * 4));
|
||||||
|
for (let j = 0; j < Math.min(connectCount, nearPoints.length); j++) {
|
||||||
|
possibleEdges.push({
|
||||||
|
from: i,
|
||||||
|
to: points.indexOf(nearPoints[j]),
|
||||||
|
strength: 0.3 + Math.random() * 0.7,
|
||||||
|
phase: Math.random() * Math.PI * 2,
|
||||||
|
baseLength: Math.sqrt((nearPoints[j].x - point.x) ** 2 + (nearPoints[j].y - point.y) ** 2)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add some organic branching patterns
|
||||||
|
for (let i = 0; i < params.topology.branches; i++) {
|
||||||
|
const from = Math.floor(Math.random() * points.length);
|
||||||
|
const to = Math.floor(Math.random() * points.length);
|
||||||
|
if (from !== to) {
|
||||||
|
possibleEdges.push({
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
strength: 0.5 + Math.random() * 0.5,
|
||||||
|
phase: Math.random() * Math.PI * 2,
|
||||||
|
baseLength: points[from].size + points[to].size + 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add some loop connections based on topology metrics
|
||||||
|
for (let i = 0; i < params.topology.loops; i++) {
|
||||||
|
const a = Math.floor(Math.random() * points.length);
|
||||||
|
const b = Math.floor(Math.random() * points.length);
|
||||||
|
const c = Math.floor(Math.random() * points.length);
|
||||||
|
|
||||||
|
// Form a small triangle/loop
|
||||||
|
if (a !== b && b !== c && a !== c) {
|
||||||
|
possibleEdges.push({
|
||||||
|
from: a, to: b,
|
||||||
|
strength: 0.2 + Math.random() * 0.3,
|
||||||
|
phase: 0,
|
||||||
|
baseLength: points[a].size + points[b].size + 5
|
||||||
|
});
|
||||||
|
possibleEdges.push({
|
||||||
|
from: b, to: c,
|
||||||
|
strength: 0.2 + Math.random() * 0.3,
|
||||||
|
phase: Math.PI/3,
|
||||||
|
baseLength: points[b].size + points[c].size + 5
|
||||||
|
});
|
||||||
|
possibleEdges.push({
|
||||||
|
from: c, to: a,
|
||||||
|
strength: 0.2 + Math.random() * 0.3,
|
||||||
|
phase: Math.PI*2/3,
|
||||||
|
baseLength: points[c].size + points[a].size + 5
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter and select edges based on connectedness
|
||||||
|
edges = possibleEdges.filter((_, i) => i % (2 + Math.floor((1 - params.connectedness) * 8)) === 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
generatePoints();
|
||||||
|
generateEdges();
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
// Clear with subtle trails
|
||||||
|
ctx.fillStyle = `rgba(0, 0, 0, ${0.1 + params.motion * 0.1})`;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
time += params.motion * 0.05 + 0.01;
|
||||||
|
|
||||||
|
// Update points with organic movement
|
||||||
|
points.forEach(point => {
|
||||||
|
if (point.lifespan !== Infinity) {
|
||||||
|
point.lifespan--;
|
||||||
|
if (point.lifespan <= 0) {
|
||||||
|
// Regenerate this point
|
||||||
|
const angle = Math.random() * Math.PI * 2;
|
||||||
|
const distance = 0.3 + Math.random() * 0.7;
|
||||||
|
point.x = canvas.width / 2 + Math.cos(angle) * distance * canvas.width * 0.5;
|
||||||
|
point.y = canvas.height / 2 + Math.sin(angle) * distance * canvas.height * 0.5;
|
||||||
|
point.lifespan = params.lifespan > 0.5 ? Infinity : Math.random() * 500 + 200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Organic wandering
|
||||||
|
point.x += (point.baseX - point.x) * 0.01 + (Math.random() - 0.5) * 0.3 * params.motion;
|
||||||
|
point.y += (point.baseY - point.y) * 0.01 + (Math.random() - 0.5) * 0.3 * params.motion;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update edges with pulsing and thickness
|
||||||
|
const pulseEffect = params.pulse.avg + Math.sin(time * 0.3) * (params.pulse.max - params.pulse.min) * 0.2;
|
||||||
|
|
||||||
|
edges.forEach(edge => {
|
||||||
|
const p1 = points[edge.from];
|
||||||
|
const p2 = points[edge.to];
|
||||||
|
if (!p1 || !p2) return;
|
||||||
|
|
||||||
|
const dist = Math.sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2);
|
||||||
|
const ratio = dist / edge.baseLength;
|
||||||
|
|
||||||
|
// Adjust thickness based on motion and connectedness
|
||||||
|
const thickness = 0.5 + params.topology.thicknessRatio * (0.3 + params.complexity * 0.7);
|
||||||
|
|
||||||
|
// Pulse effect
|
||||||
|
const pulse = 1 + Math.sin(edge.phase + time * 0.2) * pulseEffect * 0.2;
|
||||||
|
const currentThickness = thickness * (pulse * edge.strength);
|
||||||
|
|
||||||
|
// Use alpha based on energy and distance
|
||||||
|
const alpha = params.tone.dryness > 0.8 ?
|
||||||
|
0.2 + 0.8 * (1 - ratio) :
|
||||||
|
0.3 + 0.7 * (1 - ratio);
|
||||||
|
|
||||||
|
// Draw edge with gradient for organic feel
|
||||||
|
const gradient = ctx.createLinearGradient(p1.x, p1.y, p2.x, p2.y);
|
||||||
|
gradient.addColorStop(0, `${palette.edge}80`);
|
||||||
|
gradient.addColorStop(1, `${palette.edge}20`);
|
||||||
|
|
||||||
|
ctx.strokeStyle = gradient;
|
||||||
|
ctx.lineWidth = currentThickness;
|
||||||
|
ctx.globalAlpha = alpha;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(p1.x, p1.y);
|
||||||
|
ctx.lineTo(p2.x, p2.y);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
// Highlight thriving connections
|
||||||
|
if (params.topology.energy > 300 && alpha > 0.4) {
|
||||||
|
ctx.strokeStyle = palette.highlight;
|
||||||
|
ctx.lineWidth = currentThickness * 0.3;
|
||||||
|
ctx.globalAlpha = 0.15 + 0.1 * Math.sin(time * 0.5 + edge.phase);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(p1.x, p1.y);
|
||||||
|
ctx.lineTo(p2.x, p2.y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Draw points
|
||||||
|
points.forEach(point => {
|
||||||
|
const size = point.size * (1 + Math.sin(time * 0.1 + point.baseX * 0.01) * 0.2);
|
||||||
|
const alpha = params.tone.dryness > 0.8 ? 0.4 : 0.6;
|
||||||
|
ctx.fillStyle = `${palette.point}${Math.floor(alpha * 255).toString(16).padStart(2, '0')}`;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(point.x, point.y, size * pulseEffect * 0.8, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Occasionally regenerate points and edges
|
||||||
|
if (Math.random() < 0.02 * params.complexity) {
|
||||||
|
generatePoints();
|
||||||
|
}
|
||||||
|
if (Math.random() < 0.01 * params.connectedness) {
|
||||||
|
generateEdges();
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.globalAlpha = 1;
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
Loading…
Add table
Reference in a new issue