221 lines
No EOL
7.3 KiB
HTML
221 lines
No EOL
7.3 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 Pulse Field</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
font-family: 'Courier New', monospace;
|
|
color: #44ff88;
|
|
}
|
|
#attribution {
|
|
position: fixed;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
font-size: 10px;
|
|
opacity: 0.7;
|
|
text-shadow: 0 0 5px #44ff88;
|
|
z-index: 100;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
</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();
|
|
|
|
// Parameters derived from abstract specifications
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: 1.08,
|
|
curiosity: 0.7,
|
|
dryness: 0.8,
|
|
playfulness: 0.3
|
|
};
|
|
|
|
// Network graph configuration
|
|
const nodeCount = 60 + Math.floor(params.density * 80);
|
|
const baseLinkCount = Math.floor(params.connectedness * nodeCount * 1.5);
|
|
const maxLinkDistance = 250 + params.complexity * 150;
|
|
const nodeSize = 1.5 + params.complexity;
|
|
const lineWidth = 0.3 + params.dryness * 0.7;
|
|
const pulseSpeed = 0.005 + params.motion * 0.02;
|
|
|
|
// Network state
|
|
const nodes = [];
|
|
const links = [];
|
|
let energy = 0;
|
|
|
|
// Initialize nodes
|
|
class Node {
|
|
constructor() {
|
|
this.x = Math.random() * canvas.width;
|
|
this.y = Math.random() * canvas.height;
|
|
this.vx = (Math.random() - 0.5) * params.motion * 2;
|
|
this.vy = (Math.random() - 0.5) * params.motion * 2;
|
|
this.connections = [];
|
|
this.life = params.lifespan * 200 + 50;
|
|
this.target = { x: this.x, y: this.y };
|
|
this.size = nodeSize;
|
|
this.pulse = 1;
|
|
}
|
|
|
|
update() {
|
|
// Gentle movement
|
|
this.x += this.vx;
|
|
this.y += this.vy;
|
|
|
|
// Boundary check
|
|
if (this.x < 0) { this.x = canvas.width; }
|
|
if (this.x > canvas.width) { this.x = 0; }
|
|
if (this.y < 0) { this.y = canvas.height; }
|
|
if (this.y > canvas.height) { this.y = 0; }
|
|
|
|
// Energy-based pulse
|
|
this.pulse = 0.8 + Math.sin(Date.now() * pulseSpeed) * 0.2;
|
|
this.size = nodeSize * this.pulse;
|
|
|
|
// Lifespan decay
|
|
this.life--;
|
|
if (this.life < 0) {
|
|
this.life = params.lifespan > 0.5 ? params.lifespan * 200 + 50 : 0;
|
|
this.x = Math.random() * canvas.width;
|
|
this.y = Math.random() * canvas.height;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Initialize the network
|
|
for (let i = 0; i < nodeCount; i++) {
|
|
nodes.push(new Node());
|
|
}
|
|
|
|
// Create links
|
|
for (let i = 0; i < baseLinkCount; i++) {
|
|
const a = Math.floor(Math.random() * nodes.length);
|
|
const b = Math.floor(Math.random() * nodes.length);
|
|
if (a !== b) {
|
|
const distance = Math.sqrt(
|
|
Math.pow(nodes[a].x - nodes[b].x, 2) +
|
|
Math.pow(nodes[a].y - nodes[b].y, 2)
|
|
);
|
|
|
|
if (distance < maxLinkDistance) {
|
|
links.push({
|
|
from: nodes[a],
|
|
to: nodes[b],
|
|
distance: distance,
|
|
strength: 0.3 + params.connectedness * 0.7
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
// Simulate hive mind behavior
|
|
function updateNetwork() {
|
|
// Nodes influence each other's targets
|
|
nodes.forEach(node => {
|
|
let avgX = 0, avgY = 0;
|
|
let count = 0;
|
|
|
|
links.forEach(link => {
|
|
if (link.from === node) {
|
|
avgX += link.to.x;
|
|
avgY += link.to.y;
|
|
count++;
|
|
} else if (link.to === node) {
|
|
avgX += link.from.x;
|
|
avgY += link.from.y;
|
|
count++;
|
|
}
|
|
});
|
|
|
|
if (count > 0) {
|
|
node.target.x = avgX / count;
|
|
node.target.y = avgY / count;
|
|
}
|
|
|
|
// Move toward target
|
|
node.vx += (node.target.x - node.x) * 0.01 * params.motion;
|
|
node.vy += (node.target.y - node.y) * 0.01 * params.motion;
|
|
});
|
|
}
|
|
|
|
// Animation loop
|
|
function animate() {
|
|
ctx.fillStyle = 'rgba(5, 5, 10, 0.1)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Update network
|
|
updateNetwork();
|
|
nodes.forEach(node => node.update());
|
|
|
|
// Draw links with pulse effects
|
|
links.forEach(link => {
|
|
const distPulse = 0.8 + Math.sin(Date.now() * pulseSpeed * 0.7) * 0.2;
|
|
const currentDistance = link.distance * distPulse * link.strength;
|
|
|
|
const dx = link.to.x - link.from.x;
|
|
const dy = link.to.y - link.from.y;
|
|
const angle = Math.atan2(dy, dx);
|
|
const length = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
// Only draw if within current distance
|
|
if (length < currentDistance) {
|
|
ctx.strokeStyle = `rgba(68, 255, 136, ${0.3 + params.curiosity * 0.5})`;
|
|
ctx.lineWidth = lineWidth * (0.5 + params.connectedness * 0.5);
|
|
ctx.beginPath();
|
|
ctx.moveTo(link.from.x, link.from.y);
|
|
ctx.lineTo(link.to.x, link.to.y);
|
|
ctx.stroke();
|
|
}
|
|
});
|
|
|
|
// Draw nodes
|
|
nodes.forEach(node => {
|
|
ctx.fillStyle = params.dryness > 0.7 ?
|
|
`rgba(68, 255, 136, 0.8)` :
|
|
`rgba(68, 220, 130, 0.9)`;
|
|
|
|
ctx.beginPath();
|
|
ctx.arc(node.x, node.y, node.size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
});
|
|
|
|
// Draw active nodes with energy pulse
|
|
const activeNodes = nodes.filter(n => n.life > 100);
|
|
energy = activeNodes.length / nodes.length * params.pulse;
|
|
|
|
if (energy > 1.1) {
|
|
ctx.filter = 'brightness(1.2) contrast(1.1)';
|
|
} else {
|
|
ctx.filter = 'none';
|
|
}
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |