birth: Fractured Light Membranes
This commit is contained in:
parent
4dc8b97f62
commit
135782b6e3
1 changed files with 246 additions and 0 deletions
246
index.html
Normal file
246
index.html
Normal file
|
|
@ -0,0 +1,246 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Fractal Veins</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 10px;
|
||||||
|
color: #555;
|
||||||
|
font-size: 10px;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="c"></canvas>
|
||||||
|
<div id="info">neurameba · motd.social</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const canvas = document.getElementById('c');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
function resize() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resize);
|
||||||
|
resize();
|
||||||
|
|
||||||
|
// Parameters derived from the prompt
|
||||||
|
const params = {
|
||||||
|
motion: 0.478,
|
||||||
|
density: 0.476,
|
||||||
|
complexity: 0.521,
|
||||||
|
connectedness: 0.463,
|
||||||
|
lifespan: 0.485,
|
||||||
|
survivingNodes: 78,
|
||||||
|
branchCount: 63,
|
||||||
|
loops: 207,
|
||||||
|
maxDepth: 18,
|
||||||
|
thicknessRatio: 1.25,
|
||||||
|
fractalDim: 1.601,
|
||||||
|
finalEnergy: 396.8,
|
||||||
|
pulse: { avg: 0.63, min: 0.3, max: 1.55 },
|
||||||
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.70, dryness: 0.80, playfulness: 0.10, tension: 0.00 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Palette based on tone
|
||||||
|
const bgColor = '#0a0a0a';
|
||||||
|
const palette = {
|
||||||
|
base: '#e0e0e0',
|
||||||
|
highlight: '#4a6b6b',
|
||||||
|
accent: '#1a2a2a',
|
||||||
|
glow: `rgba(74, 107, 107, ${params.pulse.avg})`
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.fillStyle = bgColor;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Voronoi parameters
|
||||||
|
const pointCount = Math.floor(params.survivingNodes * 50);
|
||||||
|
const points = [];
|
||||||
|
const edges = [];
|
||||||
|
const maxIterations = 100;
|
||||||
|
const minDistance = 50;
|
||||||
|
const edgeThickness = params.thicknessRatio * 0.8;
|
||||||
|
|
||||||
|
// Generate point distribution with controlled density
|
||||||
|
for (let i = 0; i < pointCount; i++) {
|
||||||
|
const angle = Math.random() * Math.PI * 2;
|
||||||
|
const distance = Math.random() * 0.4 + 0.3;
|
||||||
|
const x = canvas.width / 2 + Math.cos(angle) * distance * Math.min(canvas.width, canvas.height) / 2;
|
||||||
|
const y = canvas.height / 2 + Math.sin(angle) * distance * Math.min(canvas.width, canvas.height) / 2;
|
||||||
|
|
||||||
|
// Add some noise based on motion parameter
|
||||||
|
if (params.motion > 0.3) {
|
||||||
|
x += (Math.random() - 0.5) * 100 * params.motion;
|
||||||
|
y += (Math.random() - 0.5) * 100 * params.motion;
|
||||||
|
}
|
||||||
|
|
||||||
|
points.push({ x, y, fixed: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lloyd relaxation to create more organic distribution
|
||||||
|
for (let iter = 0; iter < 3; iter++) {
|
||||||
|
const newPoints = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < points.length; i++) {
|
||||||
|
const point = points[i];
|
||||||
|
const neighbors = [];
|
||||||
|
|
||||||
|
// Find nearest neighbors
|
||||||
|
for (let j = 0; j < points.length; j++) {
|
||||||
|
if (i === j) continue;
|
||||||
|
const dx = points[j].x - point.x;
|
||||||
|
const dy = points[j].y - point.y;
|
||||||
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (distance < minDistance) {
|
||||||
|
neighbors.push(points[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (neighbors.length > 0) {
|
||||||
|
// Calculate centroid
|
||||||
|
let sumX = 0, sumY = 0;
|
||||||
|
for (const neighbor of neighbors) {
|
||||||
|
sumX += neighbor.x;
|
||||||
|
sumY += neighbor.y;
|
||||||
|
}
|
||||||
|
newPoints.push({
|
||||||
|
x: sumX / neighbors.length,
|
||||||
|
y: sumY / neighbors.length,
|
||||||
|
fixed: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
newPoints.push({ ...point });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
points.length = 0;
|
||||||
|
points.push(...newPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build Voronoi diagram
|
||||||
|
function calculateVoronoi() {
|
||||||
|
edges.length = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < points.length; i++) {
|
||||||
|
const point = points[i];
|
||||||
|
|
||||||
|
// Find nearest neighbors
|
||||||
|
const neighbors = [];
|
||||||
|
for (let j = 0; j < points.length; j++) {
|
||||||
|
if (i === j) continue;
|
||||||
|
const dx = points[j].x - point.x;
|
||||||
|
const dy = points[j].y - point.y;
|
||||||
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (distance < minDistance * 1.5) {
|
||||||
|
neighbors.push({ point: points[j], distance });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by distance
|
||||||
|
neighbors.sort((a, b) => a.distance - b.distance);
|
||||||
|
|
||||||
|
// Create edges with complexity factor
|
||||||
|
const edgeCount = Math.min(params.complexity * 10 + 2, neighbors.length);
|
||||||
|
for (let e = 0; e < edgeCount; e++) {
|
||||||
|
if (e >= neighbors.length) break;
|
||||||
|
|
||||||
|
const neighbor = neighbors[e].point;
|
||||||
|
edges.push({
|
||||||
|
from: point,
|
||||||
|
to: neighbor,
|
||||||
|
thickness: edgeThickness * (0.5 + Math.random() * 0.5),
|
||||||
|
distance: neighbors[e].distance
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateVoronoi();
|
||||||
|
|
||||||
|
// Animation variables
|
||||||
|
let time = 0;
|
||||||
|
const pulseScale = d => {
|
||||||
|
const base = 1;
|
||||||
|
const pulseFactor = params.pulse.avg + Math.sin(time * 0.005) * 0.2;
|
||||||
|
return base + (d / canvas.width) * 0.5 * pulseFactor;
|
||||||
|
};
|
||||||
|
|
||||||
|
const drawEdge = (edge, alpha) => {
|
||||||
|
const dx = edge.to.x - edge.from.x;
|
||||||
|
const dy = edge.to.y - edge.from.y;
|
||||||
|
const length = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(edge.from.x, edge.from.y);
|
||||||
|
ctx.lineTo(edge.to.x, edge.to.y);
|
||||||
|
ctx.strokeStyle = `${palette.highlight}${Math.floor(alpha * 255).toString(16)}`;
|
||||||
|
ctx.lineWidth = edge.thickness * pulseScale(length);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
// Add glow effect
|
||||||
|
ctx.shadowBlur = 5;
|
||||||
|
ctx.shadowColor = palette.glow;
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.shadowBlur = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
time++;
|
||||||
|
|
||||||
|
// Clear with some trails based on lifespan
|
||||||
|
ctx.fillStyle = `rgba(10, 10, 10, ${0.1 + params.lifespan * 0.1})`;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Update points based on motion
|
||||||
|
if (params.motion > 0.3) {
|
||||||
|
points.forEach(point => {
|
||||||
|
point.x += (Math.random() - 0.5) * 2 * params.motion;
|
||||||
|
point.y += (Math.random() - 0.5) * 2 * params.motion;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Occasionally recalculate Voronoi
|
||||||
|
if (time % 50 === 0) {
|
||||||
|
calculateVoronoi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw edges with connectedness and complexity influence
|
||||||
|
const edgeCount = Math.min(params.connectedness * edges.length + 10, edges.length);
|
||||||
|
for (let i = 0; i < edgeCount; i++) {
|
||||||
|
const edgeIndex = Math.floor(Math.random() * edges.length);
|
||||||
|
const edge = edges[edgeIndex];
|
||||||
|
|
||||||
|
// Fade based on distance and pulse
|
||||||
|
const distanceFactor = 1 - (edge.distance / (canvas.width/2));
|
||||||
|
const pulseFactor = Math.max(params.pulse.min, Math.min(params.pulse.max,
|
||||||
|
params.pulse.avg + Math.sin(time * 0.005 + edgeIndex * 0.1) * 0.3));
|
||||||
|
const alpha = (params.tone.dryness * 0.8 + params.tone.curiosity * 0.2) * distanceFactor * pulseFactor;
|
||||||
|
|
||||||
|
drawEdge(edge, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue