birth: Fractured Light's Quiet Pulse
This commit is contained in:
parent
68748bc06c
commit
1c30a39fc1
1 changed files with 237 additions and 0 deletions
237
index.html
Normal file
237
index.html
Normal file
|
|
@ -0,0 +1,237 @@
|
||||||
|
<!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: #0a0a0a;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
color: #444;
|
||||||
|
font-size: 10px;
|
||||||
|
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 genetics
|
||||||
|
const params = {
|
||||||
|
motion: 0.459,
|
||||||
|
density: 0.441,
|
||||||
|
complexity: 0.485,
|
||||||
|
connectedness: 0.471,
|
||||||
|
lifespan: 0.505,
|
||||||
|
survivingNodes: 69,
|
||||||
|
branchCount: 59,
|
||||||
|
loops: 369,
|
||||||
|
maxDepth: 16,
|
||||||
|
thicknessRatio: 1.50,
|
||||||
|
fractalDimension: 1.101,
|
||||||
|
finalEnergy: 336.4,
|
||||||
|
pulse: { avg: 0.43, min: 0.30, max: 1.60 },
|
||||||
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Voronoi system
|
||||||
|
const sites = [];
|
||||||
|
const cells = [];
|
||||||
|
const edges = [];
|
||||||
|
const voronoiDiagram = [];
|
||||||
|
let time = 0;
|
||||||
|
|
||||||
|
// Initialize sites based on density
|
||||||
|
function initSites() {
|
||||||
|
sites.length = 0;
|
||||||
|
const count = Math.floor(params.survivingNodes * (300 + 700 * params.density));
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
sites.push({
|
||||||
|
x: Math.random() * canvas.width,
|
||||||
|
y: Math.random() * canvas.height,
|
||||||
|
vx: (Math.random() - 0.5) * 4 * params.motion,
|
||||||
|
vy: (Math.random() - 0.5) * 4 * params.motion,
|
||||||
|
energy: params.finalEnergy * (0.5 + Math.random() * 0.5),
|
||||||
|
lifespan: params.lifespan * (0.3 + Math.random() * 0.7)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Voronoi diagram calculation (simplified)
|
||||||
|
function calculateVoronoi() {
|
||||||
|
cells.length = 0;
|
||||||
|
voronoiDiagram.length = 0;
|
||||||
|
|
||||||
|
// Delaunay triangulation would go here (using simple approximation)
|
||||||
|
for (let i = 0; i < sites.length; i++) {
|
||||||
|
const site = sites[i];
|
||||||
|
const neighbors = [];
|
||||||
|
const cell = {
|
||||||
|
site: site,
|
||||||
|
vertices: [],
|
||||||
|
edges: [],
|
||||||
|
color: `hsl(0, 0%, ${10 + Math.random() * 15}%)`
|
||||||
|
};
|
||||||
|
|
||||||
|
// Find approximate neighbors (voronoi cells)
|
||||||
|
for (let j = 0; j < sites.length; j++) {
|
||||||
|
if (i === j) continue;
|
||||||
|
const dx = sites[j].x - site.x;
|
||||||
|
const dy = sites[j].y - site.y;
|
||||||
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (dist < 200 * params.density) {
|
||||||
|
neighbors.push(sites[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create cell vertices (simplified)
|
||||||
|
neighbors.forEach(neighbor => {
|
||||||
|
const angle = Math.atan2(neighbor.y - site.y, neighbor.x - site.x);
|
||||||
|
const edgeDist = 100 / params.density;
|
||||||
|
cell.vertices.push({
|
||||||
|
x: site.x + Math.cos(angle) * edgeDist,
|
||||||
|
y: site.y + Math.sin(angle) * edgeDist
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
cells.push(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update system
|
||||||
|
function update() {
|
||||||
|
time += 0.01 * params.motion;
|
||||||
|
|
||||||
|
// Update sites
|
||||||
|
sites.forEach(site => {
|
||||||
|
site.x += site.vx;
|
||||||
|
site.y += site.vy;
|
||||||
|
|
||||||
|
// Boundary check
|
||||||
|
if (site.x < 0 || site.x > canvas.width) site.vx *= -1;
|
||||||
|
if (site.y < 0 || site.y > canvas.height) site.vy *= -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Recalculate voronoi occasionally based on complexity
|
||||||
|
if (Math.random() < params.complexity * 0.01) {
|
||||||
|
calculateVoronoi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw system
|
||||||
|
function draw() {
|
||||||
|
// Clear with slightly changing darkness
|
||||||
|
ctx.fillStyle = `rgba(0, 0, 0, ${0.05 + Math.sin(time) * 0.02})`;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Draw voronoi cells
|
||||||
|
cells.forEach(cell => {
|
||||||
|
if (cell.vertices.length < 3) return;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(cell.vertices[0].x, cell.vertices[0].y);
|
||||||
|
|
||||||
|
for (let i = 1; i < cell.vertices.length; i++) {
|
||||||
|
ctx.lineTo(cell.vertices[i].x, cell.vertices[i].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.closePath();
|
||||||
|
|
||||||
|
// Dryness-based coloring
|
||||||
|
ctx.strokeStyle = cell.color;
|
||||||
|
ctx.lineWidth = 1.5 * params.thicknessRatio;
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
// Fill with low-energy color
|
||||||
|
ctx.fillStyle = `rgba(255, 255, 255, ${0.05 + cell.site.energy/1000})`;
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Draw connections based on connectedness
|
||||||
|
if (params.connectedness > 0.3) {
|
||||||
|
sites.forEach(site => {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(site.x, site.y);
|
||||||
|
|
||||||
|
// Find close sites and draw connections
|
||||||
|
sites.forEach(other => {
|
||||||
|
if (site === other) return;
|
||||||
|
const dx = other.x - site.x;
|
||||||
|
const dy = other.y - site.y;
|
||||||
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (dist < 200 * params.connectedness) {
|
||||||
|
ctx.lineTo(other.x, other.y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.strokeStyle = `rgba(255, 255, 255, ${0.01 + params.connectedness * 0.05})`;
|
||||||
|
ctx.lineWidth = 0.5 * params.thicknessRatio;
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw some loops/cycles
|
||||||
|
if (params.loops > 0) {
|
||||||
|
ctx.strokeStyle = `rgba(255, 255, 255, ${0.1 + params.loops/2000})`;
|
||||||
|
ctx.lineWidth = 2 * params.thicknessRatio;
|
||||||
|
|
||||||
|
for (let i = 0; i < params.loops; i += 10) {
|
||||||
|
const a = sites[i % sites.length];
|
||||||
|
const b = sites[(i + Math.floor(params.loops/100)) % sites.length];
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(a.x, a.y);
|
||||||
|
ctx.bezierCurveTo(
|
||||||
|
a.x + (b.x - a.x) * 0.3 + Math.sin(time) * 50,
|
||||||
|
a.y + (b.y - a.y) * 0.3,
|
||||||
|
b.x - (b.x - a.x) * 0.3,
|
||||||
|
b.y - (b.y - a.y) * 0.3,
|
||||||
|
b.x, b.y
|
||||||
|
);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
update();
|
||||||
|
draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start
|
||||||
|
initSites();
|
||||||
|
calculateVoronoi();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue