birth: Pulsing Voronoi Tendrils
This commit is contained in:
parent
f7972978ce
commit
27012eedbe
1 changed files with 176 additions and 0 deletions
176
index.html
Normal file
176
index.html
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
<!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;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: #444;
|
||||
font-size: 10px;
|
||||
pointer-events: none;
|
||||
}
|
||||
</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();
|
||||
|
||||
// Organism parameters
|
||||
const params = {
|
||||
motion: 0.525,
|
||||
density: 0.530,
|
||||
complexity: 0.460,
|
||||
connectedness: 0.415,
|
||||
lifespan: 0.471,
|
||||
survivingNodes: 74,
|
||||
branchCount: 54,
|
||||
loops: 167,
|
||||
maxDepth: 16,
|
||||
thicknessRatio: 1.50,
|
||||
fractalDim: 1.601,
|
||||
finalEnergy: 369.7,
|
||||
pulse: { avg: 0.56, min: 0.30, max: 1.55 },
|
||||
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.70, dryness: 0.90, playfulness: 0.10, tension: 0.00 }
|
||||
};
|
||||
|
||||
// State
|
||||
const state = {
|
||||
nodes: [],
|
||||
edges: [],
|
||||
time: 0,
|
||||
colors: {
|
||||
bg: '#0a0a0a',
|
||||
node: 'rgba(200, 230, 220, 0.8)',
|
||||
edge: 'rgba(180, 210, 200, 0.3)',
|
||||
pulse: 'rgba(100, 255, 200, 0.6)'
|
||||
},
|
||||
pulseFactor: 0
|
||||
};
|
||||
|
||||
// Initialize Voronoi-like structure
|
||||
function initVoronoi() {
|
||||
const count = Math.floor(74 * params.density);
|
||||
const size = Math.min(canvas.width, canvas.height) * 0.8;
|
||||
|
||||
// Generate points
|
||||
for (let i = 0; i < count; i++) {
|
||||
state.nodes.push({
|
||||
x: canvas.width/2 + (Math.random()-0.5) * size,
|
||||
y: canvas.height/2 + (Math.random()-0.5) * size,
|
||||
vx: (Math.random()-0.5) * 0.1,
|
||||
vy: (Math.random()-0.5) * 0.1,
|
||||
age: Math.random(),
|
||||
maxAge: 0.5 + Math.random() * 0.5,
|
||||
pulse: Math.random() * params.pulse.max
|
||||
});
|
||||
}
|
||||
|
||||
// Connect nearest neighbors
|
||||
for (let i = 0; i < state.nodes.length; i++) {
|
||||
for (let j = i+1; j < state.nodes.length; j++) {
|
||||
const dx = state.nodes[j].x - state.nodes[i].x;
|
||||
const dy = state.nodes[j].y - state.nodes[i].y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
|
||||
if (dist < 150 * params.connectedness) {
|
||||
state.edges.push({
|
||||
from: i,
|
||||
to: j,
|
||||
length: dist,
|
||||
thickness: 1 + params.thicknessRatio * (1 - dist/150),
|
||||
color: 'rgba(180, 210, 200, ' + (0.1 + 0.2 * (1 - dist/150)) + ')'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update nodes
|
||||
function updateNodes() {
|
||||
state.pulseFactor = params.pulse.avg * (0.8 + 0.4 * Math.sin(state.time * 0.002));
|
||||
|
||||
state.nodes.forEach(node => {
|
||||
// Movement with pulse influence
|
||||
const pulseEffect = 0.5 * state.pulseFactor * (node.pulse - params.pulse.avg);
|
||||
node.x += node.vx * params.motion * (1 + pulseEffect);
|
||||
node.y += node.vy * params.motion * (1 + pulseEffect);
|
||||
|
||||
// Wrap around edges
|
||||
if (node.x < 0) node.x = canvas.width;
|
||||
if (node.x > canvas.width) node.x = 0;
|
||||
if (node.y < 0) node.y = canvas.height;
|
||||
if (node.y > canvas.height) node.y = 0;
|
||||
|
||||
// Update age
|
||||
node.age += 0.001;
|
||||
if (node.age > node.maxAge) {
|
||||
node.age = 0;
|
||||
node.x = canvas.width/2 + (Math.random()-0.5) * canvas.width/2;
|
||||
node.y = canvas.height/2 + (Math.random()-0.5) * canvas.height/2;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Draw
|
||||
function draw() {
|
||||
ctx.fillStyle = state.colors.bg;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw edges
|
||||
state.edges.forEach(edge => {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(state.nodes[edge.from].x, state.nodes[edge.from].y);
|
||||
ctx.lineTo(state.nodes[edge.to].x, state.nodes[edge.to].y);
|
||||
ctx.strokeStyle = edge.color;
|
||||
ctx.lineWidth = edge.thickness;
|
||||
ctx.stroke();
|
||||
});
|
||||
|
||||
// Draw nodes with pulse effect
|
||||
state.nodes.forEach(node => {
|
||||
const pulseSize = 8 + 4 * (node.pulse - params.pulse.avg) * state.pulseFactor;
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, pulseSize, 0, Math.PI * 2);
|
||||
ctx.fillStyle = state.colors.node;
|
||||
ctx.fill();
|
||||
});
|
||||
|
||||
state.time++;
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
updateNodes();
|
||||
draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
initVoronoi();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue