177 lines
No EOL
5.8 KiB
HTML
177 lines
No EOL
5.8 KiB
HTML
```html
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Dust Memory</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
font-family: 'Courier New', monospace;
|
|
color: #ddd;
|
|
}
|
|
#attribution {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
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();
|
|
|
|
const points = [];
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.07, min: 0.9, max: 1.2 },
|
|
tone: {
|
|
anger: 0.0,
|
|
sadness: 0.0,
|
|
curiosity: 0.8,
|
|
dryness: 0.9,
|
|
playfulness: 0.1,
|
|
tension: 0.0
|
|
}
|
|
};
|
|
|
|
// Initialize points
|
|
const pointCount = Math.floor(100 + params.density * 400);
|
|
for (let i = 0; i < pointCount; i++) {
|
|
points.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
vx: (Math.random() - 0.5) * 0.5,
|
|
vy: (Math.random() - 0.5) * 0.5,
|
|
size: Math.random() * 1.5 + 0.5,
|
|
life: Math.random() * 100 + 50,
|
|
maxLife: Math.random() * 100 + 50
|
|
});
|
|
}
|
|
|
|
let time = 0;
|
|
|
|
function animate() {
|
|
// Clear with low opacity for motion trails
|
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Update points
|
|
points.forEach(point => {
|
|
// Gentle movement with pulse variation
|
|
const pulse = params.pulse.min + (params.pulse.max - params.pulse.min) * (Math.sin(time * 0.01) * 0.5 + 0.5);
|
|
point.vx += (Math.random() - 0.5) * 0.02 * params.motion * pulse;
|
|
point.vy += (Math.random() - 0.5) * 0.02 * params.motion * pulse;
|
|
|
|
// Boundary check
|
|
if (point.x < 0 || point.x > canvas.width) point.vx *= -0.5;
|
|
if (point.y < 0 || point.y > canvas.height) point.vy *= -0.5;
|
|
|
|
point.x += point.vx;
|
|
point.y += point.vy;
|
|
point.life -= 0.1;
|
|
|
|
// Size variation based on life
|
|
point.size = 0.5 + (point.life / point.maxLife) * 2;
|
|
});
|
|
|
|
// Create Voronoi cells
|
|
const diagram = voronoi(points);
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Draw edges with dryness-based color
|
|
const hue = 180 + Math.sin(time * 0.001) * 30;
|
|
const saturation = 30 + Math.sin(time * 0.002) * 20;
|
|
const lightness = 20 + Math.sin(time * 0.003) * 10;
|
|
const edgeColor = `hsl(${hue}, ${saturation}%, ${lightness}%)`;
|
|
|
|
ctx.strokeStyle = edgeColor;
|
|
ctx.lineWidth = 0.5;
|
|
diagram.edges.forEach(edge => {
|
|
if (edge) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(edge.va.x, edge.va.y);
|
|
ctx.lineTo(edge.vb.x, edge.vb.y);
|
|
ctx.stroke();
|
|
}
|
|
});
|
|
|
|
// Draw points
|
|
points.forEach(point => {
|
|
if (point.life > 0) {
|
|
const alpha = point.life / point.maxLife * 0.8;
|
|
ctx.fillStyle = `rgba(200, 255, 255, ${alpha})`;
|
|
ctx.beginPath();
|
|
ctx.arc(point.x, point.y, point.size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
}
|
|
});
|
|
|
|
// Replace dead points
|
|
if (Math.random() < 0.02) {
|
|
points.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
vx: (Math.random() - 0.5) * 0.5,
|
|
vy: (Math.random() - 0.5) * 0.5,
|
|
size: Math.random() * 1.5 + 0.5,
|
|
life: 150,
|
|
maxLife: 150
|
|
});
|
|
}
|
|
|
|
time++;
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Simple Voronoi implementation (simplified from standard algorithm)
|
|
function voronoi(points) {
|
|
const edges = [];
|
|
|
|
// Simplified edge detection - just connect close points
|
|
for (let i = 0; i < points.length; i++) {
|
|
for (let j = i + 1; j < points.length; j++) {
|
|
const p1 = points[i];
|
|
const p2 = points[j];
|
|
const dx = p2.x - p1.x;
|
|
const dy = p2.y - p1.y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
if (dist < 50 * params.connectedness) {
|
|
edges.push({
|
|
va: { x: p1.x, y: p1.y },
|
|
vb: { x: p2.x, y: p2.y },
|
|
length: dist
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
return { edges };
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html>
|
|
``` |