gossamer-web-of-static-hgr7/index.html

185 lines
No EOL
6.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 Motion</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #0a0a0a;
font-family: 'Courier New', monospace;
color: #555;
}
#attribution {
position: absolute;
bottom: 20px;
left: 20px;
font-size: 10px;
text-transform: uppercase;
opacity: 0.5;
letter-spacing: 1px;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="attribution">neurameba · motd.social</div>
<script>
(function() {
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;
}
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
// Parameters
const params = {
motion: 0.5,
density: 0.5,
complexity: 0.5,
connectedness: 0.5,
lifespan: 0.5,
pulse: {
avg: 1.1,
min: 0.9,
max: 1.2
},
tone: {
anger: 0.0,
sadness: 0.0,
curiosity: 0.0,
dryness: 0.8,
playfulness: 0.1,
tension: 0.0
}
};
// Calculate node count based on density
const nodeCount = Math.floor(200 + params.density * 600);
// Network parameters
let nodes = [];
let edges = [];
const maxConnections = Math.floor(params.connectedness * 5);
const maxEdgeLength = 300;
const nodeSize = 2 + params.density * 4;
const edgeWidth = 0.5 + params.connectedness * 1.5;
// Initialize nodes
for (let i = 0; i < nodeCount; i++) {
nodes.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,
size: nodeSize * (0.8 + Math.random() * 0.4),
lifetime: params.lifespan * 1000 + Math.random() * 500,
createdAt: Date.now(),
color: getNodeColor()
});
}
// Initialize edges
for (let i = 0; i < nodes.length; i++) {
const connections = Math.floor(Math.random() * maxConnections * params.connectedness);
for (let j = 0; j < connections; j++) {
const targetIdx = Math.floor(Math.random() * nodes.length);
if (targetIdx !== i && !nodes[i].connections.includes(targetIdx)) {
nodes[i].connections = nodes[i].connections || [];
nodes[i].connections.push(targetIdx);
}
}
}
// Calculate distance between two points
function distance(x1, y1, x2, y2) {
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
}
// Get node color based on tone
function getNodeColor() {
if (params.tone.dryness > 0.7) {
const gray = 50 + Math.floor(Math.random() * 50);
return `rgb(${gray}, ${gray}, ${gray})`;
} else if (params.tone.playfulness > 0.7) {
const hue = Math.floor(Math.random() * 360);
return `hsl(${hue}, 100%, 70%)`;
}
return '#999';
}
// Get edge color
function getEdgeColor(baseColor) {
if (params.tone.dryness > 0.7) {
const gray = Math.min(255, baseColor[0] + 20);
return `rgb(${gray}, ${gray}, ${gray})`;
}
return baseColor;
}
// Animation
let lastTime = 0;
function animate(currentTime) {
// Calculate delta time
const deltaTime = currentTime - lastTime;
lastTime = currentTime;
// Clear with slight fade
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update nodes
nodes.forEach(node => {
// Move node
node.x += node.vx;
node.y += node.vy;
// Bounce off edges
if (node.x < 0 || node.x > canvas.width) node.vx *= -1;
if (node.y < 0 || node.y > canvas.height) node.vy *= -1;
// Draw node
ctx.beginPath();
ctx.arc(node.x, node.y, node.size, 0, Math.PI * 2);
ctx.fillStyle = node.color;
ctx.fill();
});
// Draw edges
ctx.lineWidth = edgeWidth;
nodes.forEach(node => {
if (node.connections) {
node.connections.forEach(targetIdx => {
const target = nodes[targetIdx];
const dist = distance(node.x, node.y, target.x, target.y);
if (dist < maxEdgeLength) {
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(target.x, target.y);
ctx.strokeStyle = getEdgeColor(node.color);
ctx.stroke();
}
});
}
});
requestAnimationFrame(animate);
}
// Start animation
requestAnimationFrame(animate);
})();
</script>
</body>
</html>