119 lines
No EOL
4.1 KiB
HTML
119 lines
No EOL
4.1 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 Tissue</title>
|
|
<style>
|
|
body { margin: 0; overflow: hidden; background: #0a0a0a; }
|
|
canvas { display: block; }
|
|
#attribution { position: fixed; bottom: 10px; right: 10px; color: #555; font-family: monospace; font-size: 12px; }
|
|
</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();
|
|
|
|
// Voronoi parameters
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.05, min: 1.0, max: 1.1 },
|
|
tone: { anger: 0.0, sadness: 0.0, curiosity: 0.1, dryness: 0.8, playfulness: 0.0, tension: 0.0 }
|
|
};
|
|
|
|
// Color scheme (dryness/monochrome dominant)
|
|
const colorBase = 50 + Math.sin(Date.now() * 0.001) * 30;
|
|
const color = `hsl(0, 0%, ${colorBase}%)`;
|
|
|
|
// Voronoi sites
|
|
const sites = [];
|
|
const siteCount = 50 + Math.floor(params.density * 150);
|
|
|
|
// Initialize sites
|
|
for (let i = 0; i < siteCount; i++) {
|
|
sites.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() * 1000,
|
|
maxAge: 2000 + Math.random() * 2000,
|
|
thickness: params.connectedness * 2
|
|
});
|
|
}
|
|
|
|
// Main animation
|
|
function animate() {
|
|
// Clear with dark background
|
|
ctx.fillStyle = '#0a0a0a';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Age sites
|
|
sites.forEach(site => {
|
|
site.age += params.motion * 0.5;
|
|
if (site.age > site.maxAge) {
|
|
site.age = 0;
|
|
site.maxAge = 2000 + Math.random() * 2000;
|
|
}
|
|
|
|
// Move sites
|
|
site.x += site.vx;
|
|
site.y += site.vy;
|
|
|
|
// Bounce at edges
|
|
if (site.x < 0 || site.x > canvas.width) site.vx *= -1;
|
|
if (site.y < 0 || site.y > canvas.height) site.vy *= -1;
|
|
|
|
// Update thickness based on age
|
|
site.thickness = params.connectedness * 2 * (1 - site.age / site.maxAge);
|
|
});
|
|
|
|
// Draw Voronoi diagram
|
|
ctx.strokeStyle = color;
|
|
ctx.lineWidth = 0.5 + params.complexity * 1.5;
|
|
|
|
// Use distance-based for simplicity (more like a field)
|
|
const cells = [];
|
|
for (let y = 0; y < canvas.height; y += 2) {
|
|
for (let x = 0; x < canvas.width; x += 2) {
|
|
let minDist = Infinity;
|
|
let closestSite = null;
|
|
|
|
for (const site of sites) {
|
|
const dist = Math.sqrt((x - site.x) ** 2 + (y - site.y) ** 2);
|
|
if (dist < minDist) {
|
|
minDist = dist;
|
|
closestSite = site;
|
|
}
|
|
}
|
|
|
|
// Draw cells with varying thickness based on site properties
|
|
ctx.globalAlpha = 0.3 + 0.7 * (closestSite.thickness / (params.connectedness * 2));
|
|
ctx.fillStyle = color;
|
|
ctx.fillRect(x, y, 2, 2);
|
|
}
|
|
}
|
|
ctx.globalAlpha = 1.0;
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Start animation
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |