birth: Pulsing Fractal Constellations
This commit is contained in:
parent
1b7e9bc3bf
commit
ceb118985b
1 changed files with 209 additions and 0 deletions
209
index.html
Normal file
209
index.html
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba | Motd.social</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a1a;
|
||||
color: #00ffaa;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
font-size: 10px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
</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');
|
||||
|
||||
// Set canvas to full window size
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Parameters derived from input
|
||||
const params = {
|
||||
motion: 0.529,
|
||||
density: 0.564,
|
||||
complexity: 0.549,
|
||||
connectedness: 0.508,
|
||||
lifespan: 0.498,
|
||||
survivingNodes: 68,
|
||||
branchCount: 57,
|
||||
loops: 357,
|
||||
maxDepth: 18,
|
||||
thicknessRatio: 1.5,
|
||||
fractalDim: 1.429,
|
||||
pulseAvg: 0.56,
|
||||
pulseMin: 0.3,
|
||||
pulseMax: 1.8,
|
||||
colors: {
|
||||
curiosity: 0.7,
|
||||
dryness: 0.9,
|
||||
playfulness: 0.1
|
||||
}
|
||||
};
|
||||
|
||||
// Generate palette based on tone
|
||||
function generatePalette() {
|
||||
const baseHue = 170 + (Math.sin(Date.now() * 0.001) * 30); // Teal range
|
||||
const saturation = params.colors.dryness > 0.7 ? params.colors.dryness * 50 + 30 : 70;
|
||||
const lightness = 50 + (Math.sin(Date.now() * 0.002) * 10);
|
||||
|
||||
return {
|
||||
node: `hsl(${baseHue}, ${saturation}%, ${lightness}%)`,
|
||||
edge: `hsl(${baseHue}, ${saturation * 0.7}%, ${lightness * 0.8}%)`,
|
||||
pulse: `hsl(${baseHue}, 100%, 80%)`
|
||||
};
|
||||
}
|
||||
|
||||
// Network graph nodes and edges
|
||||
let nodes = [];
|
||||
let edges = [];
|
||||
|
||||
function initializeGraph() {
|
||||
// Create nodes with positions influenced by connectedness
|
||||
const nodeCount = params.survivingNodes;
|
||||
const centerX = canvas.width / 2;
|
||||
const centerY = canvas.height / 2;
|
||||
const maxRadius = Math.min(canvas.width, canvas.height) * 0.4;
|
||||
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
const angle = (i / nodeCount) * Math.PI * 2;
|
||||
const radius = maxRadius * Math.sqrt(i / nodeCount) * (0.5 + Math.random() * 0.5);
|
||||
nodes.push({
|
||||
x: centerX + radius * Math.cos(angle),
|
||||
y: centerY + radius * Math.sin(angle),
|
||||
radius: 2 + Math.random() * 3,
|
||||
pulse: 0,
|
||||
maxPulse: 0.3 + Math.random() * 0.7
|
||||
});
|
||||
}
|
||||
|
||||
// Create edges with loop bias
|
||||
const edgeCount = params.branchCount * 2; // Double to allow loops
|
||||
for (let i = 0; i < edgeCount; i++) {
|
||||
const from = Math.floor(Math.random() * nodeCount);
|
||||
const to = params.connectedness > 0.5 ?
|
||||
Math.floor(Math.random() * nodeCount) :
|
||||
Math.floor(Math.random() * Math.min(3, nodeCount));
|
||||
|
||||
// Ensure some loops
|
||||
if (from === to || Math.random() < 0.3) {
|
||||
edges.push({
|
||||
from,
|
||||
to: from,
|
||||
thickness: 0.5 + Math.random() * params.thicknessRatio,
|
||||
length: 0
|
||||
});
|
||||
} else {
|
||||
edges.push({
|
||||
from,
|
||||
to,
|
||||
thickness: 0.5 + Math.random() * params.thicknessRatio,
|
||||
length: Math.sqrt(
|
||||
Math.pow(nodes[from].x - nodes[to].x, 2) +
|
||||
Math.pow(nodes[from].y - nodes[to].y, 2)
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Prune edges to get closer to target count
|
||||
edges = edges.slice(0, params.branchCount);
|
||||
}
|
||||
|
||||
// Animation
|
||||
function animate() {
|
||||
const palette = generatePalette();
|
||||
const pulseFactor = params.pulseAvg + Math.sin(Date.now() * 0.001) * (params.pulseMax - params.pulseMin) * 0.5;
|
||||
|
||||
// Clear with slight fade
|
||||
ctx.fillStyle = 'rgba(10, 10, 26, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Update nodes
|
||||
nodes.forEach(node => {
|
||||
node.pulse = node.maxPulse * pulseFactor * 0.5;
|
||||
});
|
||||
|
||||
// Draw edges
|
||||
edges.forEach(edge => {
|
||||
const fromNode = nodes[edge.from];
|
||||
let toNode = edge.from === edge.to ? fromNode : nodes[edge.to];
|
||||
|
||||
// Apply pulse effect to edge length
|
||||
const effectiveLength = edge.length * (1 + edge.from === edge.to ? fromNode.pulse * 0.1 : 0);
|
||||
|
||||
// Draw edge with glow
|
||||
ctx.strokeStyle = palette.edge;
|
||||
ctx.lineWidth = edge.thickness;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(fromNode.x, fromNode.y);
|
||||
|
||||
if (edge.from === edge.to) {
|
||||
// Draw loop
|
||||
const loopRadius = fromNode.radius + 15 + fromNode.pulse * 20;
|
||||
ctx.quadraticCurveTo(
|
||||
fromNode.x + loopRadius,
|
||||
fromNode.y,
|
||||
fromNode.x,
|
||||
fromNode.y - loopRadius
|
||||
);
|
||||
} else {
|
||||
// Calculate direction vector
|
||||
const dx = toNode.x - fromNode.x;
|
||||
const dy = toNode.y - fromNode.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
// Move endpoints inward based on edge thickness
|
||||
const ratio = 1 - (edge.thickness * 0.5 / distance);
|
||||
toNode = {
|
||||
x: fromNode.x + dx * ratio,
|
||||
y: fromNode.y + dy * ratio
|
||||
};
|
||||
|
||||
ctx.lineTo(toNode.x, toNode.y);
|
||||
}
|
||||
|
||||
ctx.stroke();
|
||||
});
|
||||
|
||||
// Draw nodes with glow
|
||||
nodes.forEach(node => {
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, node.radius + node.pulse, 0, Math.PI * 2);
|
||||
ctx.fillStyle = palette.node;
|
||||
ctx.fill();
|
||||
ctx.shadowColor = palette.pulse;
|
||||
ctx.shadowBlur = node.pulse * 5;
|
||||
ctx.shadowOffsetX = 0;
|
||||
ctx.shadowOffsetY = 0;
|
||||
});
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Initialize and start
|
||||
initializeGraph();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue