218 lines
No EOL
7.7 KiB
HTML
218 lines
No EOL
7.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>voronoi · motd.social</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: #555;
|
|
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');
|
|
|
|
// Set canvas to full window size
|
|
function resizeCanvas() {
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
}
|
|
window.addEventListener('resize', resizeCanvas);
|
|
resizeCanvas();
|
|
|
|
// Parameters guided by the input
|
|
const params = {
|
|
motion: 0.513,
|
|
density: 0.452,
|
|
complexity: 0.562,
|
|
connectedness: 0.616,
|
|
lifespan: 0.480,
|
|
pulse: { avg: 0.42, min: 0.30, max: 1.25 },
|
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.20, dryness: 0.90, playfulness: 0.10, tension: 0.00 },
|
|
topology: {
|
|
nodes: 37,
|
|
branches: 32,
|
|
loops: 168,
|
|
maxDepth: 19,
|
|
thicknessRatio: 1.50,
|
|
fractalDim: 0.855,
|
|
energy: 166.7
|
|
}
|
|
};
|
|
|
|
// Dynamic adjustments
|
|
const points = [];
|
|
const edges = [];
|
|
const voronoi = [];
|
|
const diagram = [];
|
|
|
|
// Initialize with low density but growing complexity
|
|
const initialCount = Math.floor(params.topology.nodes * (params.density > 0.5 ? 0.8 : params.density * 1.5));
|
|
for (let i = 0; i < initialCount; i++) {
|
|
points.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
vx: (Math.random() - 0.5) * params.motion * 2,
|
|
vy: (Math.random() - 0.5) * params.motion * 2,
|
|
age: Math.random() * 100,
|
|
lifespan: 100 + Math.random() * 200,
|
|
energy: 50 + Math.random() * 200
|
|
});
|
|
}
|
|
|
|
// Warm-up to build connectivity
|
|
for (let i = 0; i < points.length; i++) {
|
|
for (let j = i + 1; j < points.length && edges.length < params.topology.branches * 2; j++) {
|
|
const dx = points[j].x - points[i].x;
|
|
const dy = points[j].y - points[i].y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
if (dist < 300 * params.connectedness && Math.random() < 0.3 * params.connectedness) {
|
|
edges.push({ a: i, b: j, dist: dist });
|
|
}
|
|
}
|
|
}
|
|
|
|
// Voronoi-like cellular structure
|
|
function generateVoronoi() {
|
|
diagram.length = 0;
|
|
for (let i = 0; i < points.length; i++) {
|
|
diagram.push({
|
|
point: points[i],
|
|
neighbors: [],
|
|
region: []
|
|
});
|
|
}
|
|
|
|
// Find neighbors (simulated)
|
|
for (let i = 0; i < diagram.length; i++) {
|
|
for (let j = i + 1; j < diagram.length; j++) {
|
|
const dx = diagram[j].point.x - diagram[i].point.x;
|
|
const dy = diagram[j].point.y - diagram[i].point.y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
if (dist < 200 * params.complexity && Math.random() < 0.4) {
|
|
diagram[i].neighbors.push(j);
|
|
diagram[j].neighbors.push(i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Animation
|
|
let time = 0;
|
|
let frameCount = 0;
|
|
|
|
function animate() {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Update points
|
|
for (let i = 0; i < points.length; i++) {
|
|
points[i].x += points[i].vx;
|
|
points[i].y += points[i].vy;
|
|
|
|
// Boundary bounce
|
|
if (points[i].x < 0 || points[i].x > canvas.width) {
|
|
points[i].vx *= -0.8;
|
|
if (points[i].x < 0) points[i].x = 0;
|
|
if (points[i].x > canvas.width) points[i].x = canvas.width;
|
|
}
|
|
if (points[i].y < 0 || points[i].y > canvas.height) {
|
|
points[i].vy *= -0.8;
|
|
if (points[i].y < 0) points[i].y = 0;
|
|
if (points[i].y > canvas.height) points[i].y = canvas.height;
|
|
}
|
|
|
|
points[i].age += 0.1;
|
|
points[i].energy *= 0.98;
|
|
|
|
// Occasionally add new points at low density
|
|
if (frameCount % 10 === 0 && points.length < 50 && Math.random() < 0.02) {
|
|
points.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
vx: (Math.random() - 0.5) * params.motion * 2,
|
|
vy: (Math.random() - 0.5) * params.motion * 2,
|
|
age: 0,
|
|
lifespan: 100 + Math.random() * 200,
|
|
energy: 100 + Math.random() * 100
|
|
});
|
|
}
|
|
|
|
// Occasionally remove old points
|
|
if (points[i].energy < 10 || points[i].age > points[i].lifespan) {
|
|
points.splice(i, 1);
|
|
i--;
|
|
}
|
|
}
|
|
|
|
// Rebuild connectivity occasionally
|
|
if (frameCount % 50 === 0) {
|
|
edges.length = 0;
|
|
for (let i = 0; i < points.length; i++) {
|
|
for (let j = i + 1; j < Math.min(i + 5, points.length); j++) {
|
|
const dx = points[j].x - points[i].x;
|
|
const dy = points[j].y - points[i].y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
if (dist < 300 * params.connectedness) {
|
|
edges.push({ a: i, b: j, dist: dist });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
generateVoronoi();
|
|
|
|
// Draw with dry/monochrome palette
|
|
ctx.strokeStyle = `rgba(200, 200, 200, ${params.tone.dryness > 0.8 ? 0.8 : params.tone.dryness})`;
|
|
ctx.lineWidth = 1 + params.topology.thicknessRatio * 0.5;
|
|
|
|
// Draw edges (voronoi connections)
|
|
for (const edge of edges) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(points[edge.a].x, points[edge.a].y);
|
|
ctx.lineTo(points[edge.b].x, points[edge.b].y);
|
|
ctx.stroke();
|
|
}
|
|
|
|
// Draw points with pulsating energy
|
|
const pulseScale = params.pulse.avg + Math.sin(time * 0.05) * params.pulse.max * 0.1;
|
|
for (const p of points) {
|
|
const size = 2 + p.energy * 0.01 * pulseScale;
|
|
ctx.beginPath();
|
|
ctx.arc(p.x, p.y, size, 0, Math.PI * 2);
|
|
ctx.fillStyle = `rgba(220, 220, 220, ${Math.min(0.9, p.energy / 100)})`;
|
|
ctx.fill();
|
|
}
|
|
|
|
time += 0.05;
|
|
frameCount++;
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |