vortex-of-stillness-dp06/index.html

167 lines
No EOL
5.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vortex of Stillness</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
}
canvas {
display: block;
}
#attribution {
position: absolute;
bottom: 10px;
left: 10px;
color: rgba(255, 255, 255, 0.3);
font-size: 10px;
text-shadow: 0 0 5px rgba(0, 0, 0, 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 resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
// Configuration based on parameters
const config = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
pulse: { avg: 1.1, min: 0.9, max: 1.2 },
tone: { dryness: 0.8, playfulness: 0.1 }
};
// Voronoi parameters
const sites = [];
const points = [];
const palette = {
bg: '#0a0a0a',
fg: '#f0f0f0',
highlight: '#888888'
};
// Initialize points
function initPoints() {
const count = Math.floor(200 + config.density * 300);
const size = Math.min(canvas.width, canvas.height) * 0.8;
for (let i = 0; i < count; i++) {
const angle = Math.random() * Math.PI * 2;
const distance = Math.random() * size * 0.4 + size * 0.1;
const x = canvas.width/2 + Math.cos(angle) * distance;
const y = canvas.height/2 + Math.sin(angle) * distance;
points.push({ x, y, vx: 0, vy: 0 });
// Add some random movement
points[i].vx = (Math.random() - 0.5) * config.motion * 2;
points[i].vy = (Math.random() - 0.5) * config.motion * 2;
}
// Create Voronoi sites
for (let i = 0; i < points.length; i++) {
sites.push(points[i]);
}
}
// Simple Voronoi diagram using distance fields
function drawVoronoi() {
const imageData = ctx.createImageData(canvas.width, canvas.height);
const data = imageData.data;
// Precompute distances
for (let y = 0; y < canvas.height; y++) {
for (let x = 0; x < canvas.width; x++) {
let minDist = Infinity;
let closestSite = 0;
const idx = (y * canvas.width + x) * 4;
for (let i = 0; i < sites.length; i++) {
const dx = x - sites[i].x;
const dy = y - sites[i].y;
const dist = Math.sqrt(dx*dx + dy*dy) * (1 + Math.sin(Date.now() * 0.001 * config.pulse.avg) * 0.1 * config.motion);
if (dist < minDist) {
minDist = dist;
closestSite = i;
}
}
// Color based on site index and distance
const brightness = Math.max(10, 255 - minDist * 2);
data[idx] = Math.floor(brightness * (0.8 + 0.2 * Math.sin(closestSite)));
data[idx+1] = Math.floor(brightness * (0.8 + 0.2 * Math.cos(closestSite)));
data[idx+2] = Math.floor(brightness * 0.9);
data[idx+3] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
}
// Update point positions
function updatePoints() {
const centerX = canvas.width/2;
const centerY = canvas.height/2;
const centerDist = Math.sqrt((centerX - canvas.width/2)**2 + (centerY - canvas.height/2)**2);
for (let i = 0; i < points.length; i++) {
// Add slight attraction to center
const dx = centerX - points[i].x;
const dy = centerY - points[i].y;
const dist = Math.sqrt(dx*dx + dy*dy);
points[i].vx += dx * 0.0001 * config.connectedness;
points[i].vy += dy * 0.0001 * config.connectedness;
// Add small random movement
points[i].vx += (Math.random() - 0.5) * 0.02 * config.motion;
points[i].vy += (Math.random() - 0.5) * 0.02 * config.motion;
// Update position
points[i].x += points[i].vx;
points[i].y += points[i].vy;
// Bounce off edges
if (points[i].x < 0 || points[i].x > canvas.width) points[i].vx *= -0.8;
if (points[i].y < 0 || points[i].y > canvas.height) points[i].vy *= -0.8;
}
// Update Voronoi sites
for (let i = 0; i < sites.length; i++) {
sites[i] = points[i];
}
}
function animate() {
// Clear with slight fade
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
updatePoints();
drawVoronoi();
requestAnimationFrame(animate);
}
initPoints();
animate();
</script>
</body>
</html>