chilled-constellations-in-m.../index.html

200 lines
No EOL
7.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>neurameba · motd.social</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #0a0a0a;
font-family: 'Courier New', monospace;
color: #666;
display: flex;
flex-direction: column;
height: 100vh;
}
canvas {
display: block;
flex: 1;
}
.attribution {
text-align: right;
padding: 8px 12px;
font-size: 10px;
letter-spacing: 1px;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="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();
// Animation parameters
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: { avg: 1.25, min: 1.00, max: 1.55 },
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.20, dryness: 0.80, playfulness: 0.00, tension: 0.00 }
};
// Network graph with controlled randomness
class NetworkGraph {
constructor() {
this.nodes = [];
this.edges = [];
this.trail = [];
this.maxTrailLength = 100;
this.time = 0;
this.pulseScale = 1;
this.speed = 0.002;
this.nodeCount = Math.floor(100 + params.density * 200);
this.maxConnections = Math.floor(1 + params.connectedness * 3);
this.initNodes();
this.initEdges();
}
initNodes() {
for (let i = 0; i < this.nodeCount; i++) {
this.nodes.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
vx: (Math.random() - 0.5) * params.motion,
vy: (Math.random() - 0.5) * params.motion,
radius: 1 + Math.random() * 2,
lifetime: Math.random(),
color: `hsl(200, ${10 + params.tone.curiosity * 80}%, ${30 + params.tone.dryness * 30}%)`
});
}
}
initEdges() {
for (let i = 0; i < this.nodes.length; i++) {
const connections = Math.floor(Math.random() * this.maxConnections);
for (let j = 0; j < connections; j++) {
const target = Math.floor(Math.random() * this.nodes.length);
if (target !== i && !this.edges.some(e =>
(e.from === i && e.to === target) || (e.from === target && e.to === i))) {
this.edges.push({ from: i, to: target, strength: 0.5 + Math.random() * 0.5 });
}
}
}
}
update() {
// Pulse effect
const pulseTarget = params.pulse.avg + Math.sin(this.time * 0.005) * (params.pulse.max - params.pulse.min) * 0.5;
this.pulseScale += (pulseTarget - this.pulseScale) * 0.1;
// Update nodes
this.nodes.forEach(node => {
node.x += node.vx * this.pulseScale;
node.y += node.vy * this.pulseScale;
// Wrap around edges
if (node.x < 0) node.x = canvas.width;
if (node.x > canvas.width) node.x = 0;
if (node.y < 0) node.y = canvas.height;
if (node.y > canvas.height) node.y = 0;
// Fade in/out based on lifespan
node.lifetime += 0.001 * (params.lifespan * 2 - 1);
if (node.lifetime > 1) node.lifetime = 0;
});
// Update trail
this.trail.unshift({
x: this.nodes[0].x,
y: this.nodes[0].y
});
if (this.trail.length > this.maxTrailLength) this.trail.pop();
this.time += 1;
}
draw() {
// Clear with slight fade
ctx.fillStyle = `rgba(10, 10, 10, ${0.1 * params.tone.dryness + 0.02})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw edges (fading based on connection strength)
this.edges.forEach(edge => {
const from = this.nodes[edge.from];
const to = this.nodes[edge.to];
const dist = Math.sqrt(Math.pow(to.x - from.x, 2) + Math.pow(to.y - from.y, 2));
const strength = edge.strength * 0.5 + 0.5;
const alpha = 0.1 * strength * (1 - params.tone.dryness);
ctx.strokeStyle = `rgba(150, 200, 255, ${alpha * this.pulseScale})`;
ctx.lineWidth = 0.5 * strength;
ctx.beginPath();
ctx.moveTo(from.x, from.y);
ctx.lineTo(to.x, to.y);
ctx.stroke();
});
// Draw nodes with varying opacity based on lifetime
this.nodes.forEach(node => {
const pulseSize = node.radius * (0.8 + this.pulseScale * 0.2);
const alpha = 0.3 + 0.7 * node.lifetime * (1 - params.tone.dryness);
const size = pulseSize * (0.7 + 0.3 * node.lifetime);
ctx.fillStyle = node.color;
ctx.globalAlpha = alpha;
ctx.beginPath();
ctx.arc(node.x, node.y, size, 0, Math.PI * 2);
ctx.fill();
// Inner glow
ctx.fillStyle = `rgba(200, 255, 255, ${0.2 * alpha * this.pulseScale})`;
ctx.beginPath();
ctx.arc(node.x, node.y, size * 0.4, 0, Math.PI * 2);
ctx.fill();
});
// Draw trail
if (this.trail.length > 1) {
ctx.strokeStyle = `rgba(180, 220, 255, ${0.2 * this.pulseScale})`;
ctx.lineWidth = 1;
ctx.beginPath();
this.trail.forEach((point, i) => {
const nextPoint = this.trail[i + 1];
if (nextPoint) {
ctx.moveTo(point.x, point.y);
ctx.lineTo(nextPoint.x, nextPoint.y);
}
});
ctx.stroke();
}
ctx.globalAlpha = 1;
}
}
// Initialize and animate
const graph = new NetworkGraph();
function animate() {
graph.update();
graph.draw();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>