fractured-monochrome-pulse-.../index.html

145 lines
No EOL
4.5 KiB
HTML

```html
<!DOCTYPE html>
<html>
<head>
<title>Voronoi Fracture</title>
<style>
body { margin: 0; overflow: hidden; background: #0a0a0a; }
canvas { display: block; }
#attr { position: absolute; bottom: 10px; right: 10px; color: #555; font-family: monospace; font-size: 10px; }
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="attr">neurameba · motd.social</div>
<script>
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
function resize() {
canvas.width = innerWidth;
canvas.height = innerHeight;
}
addEventListener('resize', resize);
resize();
// Parameters from prompt
const params = {
motion: 0.414,
density: 0.566,
complexity: 0.292,
connectedness: 0.597,
lifespan: 0.387,
pulse: { avg: 0.41, min: 0.30, max: 1.25 },
tone: { dryness: 0.90, curiosity: 0.10 },
topology: {
nodes: 6,
branches: 5,
loops: 45,
maxDepth: 3,
thicknessRatio: 1.00,
fractalDim: 1.000,
energy: 38.1
}
};
// Voronoi setup
const points = [];
const colors = [];
const edges = [];
const MAX_POINTS = 150;
const GROWTH_RATE = params.density * 2;
// Initialize points with Poisson-like distribution
for (let i = 0; i < MAX_POINTS; i++) {
points.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
vx: (Math.random() - 0.5) * params.motion * 4,
vy: (Math.random() - 0.5) * params.motion * 4,
life: 0,
maxLife: 100 + Math.random() * 200
});
// Monochrome with slight variation from dryness
const gray = 50 + Math.random() * 30;
colors.push(`rgb(${gray},${gray},${gray})`);
}
// Voronoi edges (simplified)
function calculateEdges() {
edges.length = 0;
for (let i = 0; i < points.length; i++) {
for (let j = i + 1; j < points.length; j++) {
const dx = points[i].x - points[j].x;
const dy = points[i].y - points[j].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 100) {
edges.push({
a: i,
b: j,
dist: dist
});
}
}
}
}
// Main animation
let time = 0;
function animate() {
ctx.fillStyle = 'rgba(5, 5, 10, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Move points with pulse modulation
const pulse = params.pulse.avg + Math.sin(time * 0.05) * (params.pulse.max - params.pulse.avg) * 0.5;
points.forEach(p => {
p.x += p.vx * pulse;
p.y += p.vy * pulse;
// Wrap around edges
if (p.x < 0) p.x = canvas.width;
if (p.x > canvas.width) p.x = 0;
if (p.y < 0) p.y = canvas.height;
if (p.y > canvas.height) p.y = 0;
p.life += 1;
if (p.life > p.maxLife) {
p.x = Math.random() * canvas.width;
p.y = Math.random() * canvas.height;
p.life = 0;
}
});
calculateEdges();
// Draw connections
ctx.strokeStyle = `rgba(120, 120, 140, 0.1)`;
ctx.lineWidth = 1 * params.thicknessRatio;
edges.forEach(e => {
const p1 = points[e.a];
const p2 = points[e.b];
ctx.beginPath();
ctx.moveTo(p1.x, p1.y);
ctx.lineTo(p2.x, p2.y);
ctx.stroke();
});
// Draw points as simple circles
points.forEach((p, i) => {
const size = Math.min(4, 2 + (p.life / p.maxLife) * 4);
ctx.fillStyle = colors[i];
ctx.beginPath();
ctx.arc(p.x, p.y, size, 0, Math.PI * 2);
ctx.fill();
});
time += 1;
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```