244 lines
No EOL
8.4 KiB
HTML
244 lines
No EOL
8.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</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background-color: #0a0a0a;
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
#info {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
color: #666;
|
|
font-size: 10px;
|
|
font-weight: 300;
|
|
letter-spacing: 1px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="canvas"></canvas>
|
|
<div id="info">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;
|
|
}
|
|
resizeCanvas();
|
|
window.addEventListener('resize', resizeCanvas);
|
|
|
|
// Parameters matching the abstract specification
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: 1.08,
|
|
tone: {
|
|
anger: 0.00,
|
|
sadness: 0.00,
|
|
curiosity: 0.10,
|
|
dryness: 0.90,
|
|
playfulness: 0.00,
|
|
tension: 0.00
|
|
}
|
|
};
|
|
|
|
// Derived values
|
|
const nodeCount = Math.floor(150 + params.density * 300);
|
|
const edgeCount = Math.floor(200 + params.connectedness * 600);
|
|
const minEdgeLength = 50;
|
|
const maxEdgeLength = 200 * params.complexity;
|
|
const nodeRadius = 2 + params.density * 4;
|
|
const edgeThickness = 0.5 + params.connectedness * 2;
|
|
const pulseFactor = params.pulse;
|
|
const lineColor = `hsl(0, 0%, ${params.tone.dryness * 20 + 10}%)`;
|
|
const nodeColor = `hsl(0, 0%, ${80 - params.tone.dryness * 20}%)`;
|
|
|
|
// Network graph state
|
|
const nodes = [];
|
|
const edges = [];
|
|
const origins = [];
|
|
const nodeEnergy = new Map();
|
|
const edgeEnergy = new Map();
|
|
|
|
// Initialize network
|
|
function initNetwork() {
|
|
// Create nodes with random positions
|
|
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,
|
|
radius: nodeRadius
|
|
});
|
|
nodeEnergy.set(i, 1.0);
|
|
}
|
|
|
|
// Create edges connecting nodes within proximity
|
|
const maxDist = canvas.width * 0.3 * params.connectedness;
|
|
const edgesCreated = new Set();
|
|
|
|
for (let i = 0; i < nodes.length; i++) {
|
|
for (let j = i + 1; j < nodes.length; j++) {
|
|
const dx = nodes[i].x - nodes[j].x;
|
|
const dy = nodes[i].y - nodes[j].y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
if (dist < maxDist && !edgesCreated.has(`${i},${j}`)) {
|
|
edges.push({
|
|
from: i,
|
|
to: j,
|
|
length: dist,
|
|
angle: Math.atan2(dy, dx),
|
|
energy: 0.8
|
|
});
|
|
edgeEnergy.set(`${i},${j}`, 1.0);
|
|
edgesCreated.add(`${i},${j}`);
|
|
edgesCreated.add(`${j},${i}`);
|
|
|
|
if (edges.length >= edgeCount) break;
|
|
}
|
|
}
|
|
if (edges.length >= edgeCount) break;
|
|
}
|
|
}
|
|
|
|
// Add some cyclic structures
|
|
function createCycles() {
|
|
for (let i = 0; i < Math.min(5, Math.floor(params.connectedness * 10)); i++) {
|
|
const cycleLength = Math.floor(3 + Math.random() * 5);
|
|
const startNode = Math.floor(Math.random() * nodes.length);
|
|
|
|
for (let j = 0; j < cycleLength; j++) {
|
|
const from = (startNode + j) % nodes.length;
|
|
const to = (startNode + (j + 1) % cycleLength) % nodes.length;
|
|
|
|
if (!edges.some(e => (e.from === from && e.to === to) || (e.from === to && e.to === from))) {
|
|
edges.push({
|
|
from,
|
|
to,
|
|
length: 80 + Math.random() * 40,
|
|
angle: Math.random() * Math.PI * 2,
|
|
energy: 0.9
|
|
});
|
|
edgeEnergy.set(`${from},${to}`, 1.0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Pulse effect
|
|
let pulseTime = 0;
|
|
function updatePulse() {
|
|
pulseTime += 0.01;
|
|
params.pulse = 1.05 + Math.sin(pulseTime) * 0.05;
|
|
}
|
|
|
|
// Main animation loop
|
|
function animate() {
|
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.95)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
updatePulse();
|
|
|
|
// Update node positions with boundaries
|
|
nodes.forEach((node, i) => {
|
|
node.x += node.vx * params.pulse;
|
|
node.y += node.vy * params.pulse;
|
|
|
|
// Bounce off edges
|
|
if (node.x < 0 || node.x > canvas.width) {
|
|
node.vx *= -0.8;
|
|
node.x = Math.max(0, Math.min(canvas.width, node.x));
|
|
}
|
|
if (node.y < 0 || node.y > canvas.height) {
|
|
node.vy *= -0.8;
|
|
node.y = Math.max(0, Math.min(canvas.height, node.y));
|
|
}
|
|
|
|
// Fade energy
|
|
nodeEnergy.set(i, Math.max(0, nodeEnergy.get(i) * 0.99));
|
|
});
|
|
|
|
// Update edges with energy transfer
|
|
edges.forEach(edge => {
|
|
// Energy transfer along edge
|
|
const fromEnergy = nodeEnergy.get(edge.from);
|
|
const toEnergy = nodeEnergy.get(edge.to);
|
|
|
|
const energyTransfer = (fromEnergy + toEnergy) * 0.002;
|
|
nodeEnergy.set(edge.from, fromEnergy + energyTransfer * 0.5);
|
|
nodeEnergy.set(edge.to, toEnergy + energyTransfer * 0.5);
|
|
edge.energy = Math.min(1.0, edge.energy + energyTransfer * 0.1);
|
|
});
|
|
|
|
// Draw edges with energy-based thickness
|
|
edges.forEach(edge => {
|
|
const fromNode = nodes[edge.from];
|
|
const toNode = nodes[edge.to];
|
|
|
|
const dx = toNode.x - fromNode.x;
|
|
const dy = toNode.y - fromNode.y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
if (dist > 0) {
|
|
edge.angle = Math.atan2(dy, dx);
|
|
}
|
|
|
|
// Energy-based alpha
|
|
const alpha = edge.energy * 0.8;
|
|
ctx.strokeStyle = `rgba(255, 255, 255, ${alpha})`;
|
|
ctx.lineWidth = edgeThickness * edge.energy * 2;
|
|
ctx.lineCap = 'round';
|
|
|
|
ctx.beginPath();
|
|
ctx.moveTo(fromNode.x, fromNode.y);
|
|
ctx.lineTo(toNode.x, toNode.y);
|
|
ctx.stroke();
|
|
});
|
|
|
|
// Draw nodes with energy-based size and color
|
|
nodes.forEach((node, i) => {
|
|
const energy = nodeEnergy.get(i);
|
|
const glow = energy * 10;
|
|
|
|
// Draw glow
|
|
ctx.beginPath();
|
|
ctx.arc(node.x, node.y, node.radius * 2 + glow * 0.5, 0, Math.PI * 2);
|
|
ctx.fillStyle = `rgba(255, 255, 255, ${energy * 0.1})`;
|
|
ctx.fill();
|
|
|
|
// Draw node
|
|
ctx.beginPath();
|
|
ctx.arc(node.x, node.y, node.radius, 0, Math.PI * 2);
|
|
ctx.fillStyle = nodeColor;
|
|
ctx.fill();
|
|
});
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Initialize and start
|
|
initNetwork();
|
|
createCycles();
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |