birth: Chromatic Fractures in Motion
This commit is contained in:
parent
0877f198f3
commit
7cb21cd524
1 changed files with 207 additions and 0 deletions
207
index.html
Normal file
207
index.html
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Motion</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
color: #aaa;
|
||||
}
|
||||
#attribution {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
font-size: 10px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
</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 based on input
|
||||
const params = {
|
||||
motion: 0.578,
|
||||
density: 0.467,
|
||||
complexity: 0.489,
|
||||
connectedness: 0.529,
|
||||
lifespan: 0.494,
|
||||
survivingNodes: 148,
|
||||
branchCount: 138,
|
||||
loops: 588,
|
||||
maxDepth: 27,
|
||||
thicknessRatio: 1.25,
|
||||
fractalDimension: 1.632,
|
||||
finalEnergy: 1661.0,
|
||||
pulseAvg: 0.70,
|
||||
pulseMin: 0.30,
|
||||
pulseMax: 2.00,
|
||||
tone: {
|
||||
anger: 0.00,
|
||||
sadness: 0.00,
|
||||
curiosity: 0.80,
|
||||
dryness: 0.90,
|
||||
playfulness: 0.10,
|
||||
tension: 0.00
|
||||
}
|
||||
};
|
||||
|
||||
// Voronoi configuration
|
||||
const siteCount = Math.max(50, Math.floor(params.density * 500));
|
||||
const sites = [];
|
||||
const cells = [];
|
||||
let time = 0;
|
||||
|
||||
// Initialize sites
|
||||
function initSites() {
|
||||
sites.length = 0;
|
||||
for (let i = 0; i < siteCount; i++) {
|
||||
sites.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: Math.random() * canvas.height,
|
||||
vx: (Math.random() - 0.5) * 2 * params.motion,
|
||||
vy: (Math.random() - 0.5) * 2 * params.motion,
|
||||
size: Math.max(0.5, Math.random() * 5 * params.thicknessRatio),
|
||||
color: getCellColor()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Get cell color based on tone
|
||||
function getCellColor() {
|
||||
if (params.tone.dryness > 0.7) {
|
||||
// Monochrome based on energy
|
||||
const hue = Math.floor(200 + (params.tone.curiosity * 55));
|
||||
const saturation = Math.min(10, 10 + params.tone.curiosity * 20);
|
||||
const brightness = 30 + params.finalEnergy * 0.05;
|
||||
return `hsl(${hue}, ${saturation}%, ${brightness}%)`;
|
||||
}
|
||||
return `hsl(${Math.random() * 60 + 180}, 70%, 60%)`;
|
||||
}
|
||||
|
||||
// Distance metric for Voronoi
|
||||
function distance(p1, p2) {
|
||||
return Math.sqrt((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2);
|
||||
}
|
||||
|
||||
// Compute Voronoi diagram
|
||||
function computeVoronoi() {
|
||||
cells.length = 0;
|
||||
for (let i = 0; i < sites.length; i++) {
|
||||
const site = sites[i];
|
||||
const cell = { site, edges: [] };
|
||||
|
||||
// Find neighbors
|
||||
for (let j = 0; j < sites.length; j++) {
|
||||
if (i === j) continue;
|
||||
const other = sites[j];
|
||||
const midX = (site.x + other.x) / 2;
|
||||
const midY = (site.y + other.y) / 2;
|
||||
const dx = other.x - site.x;
|
||||
const dy = other.y - site.y;
|
||||
const length = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
// Perpendicular bisector
|
||||
const angle = Math.atan2(dy, dx);
|
||||
const perpAngle = angle + Math.PI / 2;
|
||||
|
||||
// Edge segment
|
||||
const edgeLength = length * 1.5; // Extend edges
|
||||
cell.edges.push({
|
||||
x1: midX - Math.cos(perpAngle) * edgeLength,
|
||||
y1: midY - Math.sin(perpAngle) * edgeLength,
|
||||
x2: midX + Math.cos(perpAngle) * edgeLength,
|
||||
y2: midY + Math.sin(perpAngle) * edgeLength
|
||||
});
|
||||
}
|
||||
cells.push(cell);
|
||||
}
|
||||
}
|
||||
|
||||
// Update sites
|
||||
function updateSites() {
|
||||
for (let i = 0; i < sites.length; i++) {
|
||||
const site = sites[i];
|
||||
|
||||
// Move with pulsing effect
|
||||
const pulse = params.pulseAvg * (1 + Math.sin(time * 0.5) * 0.3);
|
||||
site.x += site.vx * pulse;
|
||||
site.y += site.vy * pulse;
|
||||
|
||||
// Boundary check
|
||||
if (site.x < 0) site.x = canvas.width;
|
||||
if (site.x > canvas.width) site.x = 0;
|
||||
if (site.y < 0) site.y = canvas.height;
|
||||
if (site.y > canvas.height) site.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Voronoi cells
|
||||
function drawVoronoi() {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw cells with varying opacity based on energy
|
||||
for (let i = 0; i < cells.length; i++) {
|
||||
const cell = cells[i];
|
||||
ctx.strokeStyle = cell.site.color;
|
||||
ctx.lineWidth = cell.site.size * 0.5;
|
||||
|
||||
// Draw cell edges
|
||||
for (let j = 0; j < cell.edges.length; j++) {
|
||||
const edge = cell.edges[j];
|
||||
const opacity = 0.2 + 0.8 * (params.tone.curiosity);
|
||||
ctx.globalAlpha = opacity;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(edge.x1, edge.y1);
|
||||
ctx.lineTo(edge.x2, edge.y2);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
// Draw sites
|
||||
for (let i = 0; i < sites.length; i++) {
|
||||
const site = sites[i];
|
||||
ctx.globalAlpha = 0.8;
|
||||
ctx.fillStyle = site.color;
|
||||
ctx.beginPath();
|
||||
ctx.arc(site.x, site.y, site.size * 1.5, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
ctx.globalAlpha = 1.0;
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
time += 0.01;
|
||||
|
||||
updateSites();
|
||||
computeVoronoi();
|
||||
drawVoronoi();
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Initialize and start
|
||||
initSites();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue