182 lines
No EOL
5.6 KiB
HTML
182 lines
No EOL
5.6 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 Graph</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
color: #fff;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
#info {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
left: 10px;
|
|
font-size: 10px;
|
|
opacity: 0.5;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="c"></canvas>
|
|
<div id="info">neurameba · motd.social</div>
|
|
<script>
|
|
const canvas = document.getElementById('c');
|
|
const c = canvas.getContext('2d');
|
|
|
|
function resize() {
|
|
canvas.width = innerWidth;
|
|
canvas.height = innerHeight;
|
|
}
|
|
window.addEventListener('resize', resize);
|
|
resize();
|
|
|
|
// Parameters derived from input
|
|
const motion = 0.5;
|
|
const density = 0.5;
|
|
const complexity = 0.5;
|
|
const connectedness = 0.5;
|
|
const lifespan = 0.5;
|
|
const pulseAvg = 1.06;
|
|
const dryness = 0.9;
|
|
const tension = 0.0;
|
|
|
|
// Helper: monochrome palette with slight variation
|
|
const baseColor = dryness > 0.7 ? Math.floor(100 + Math.random() * 50) : 255;
|
|
function color(val) {
|
|
const v = Math.max(0, Math.min(255, val * 1.5));
|
|
return `rgb(${baseColor - v}, ${baseColor - v}, ${baseColor - v})`;
|
|
}
|
|
|
|
// Network nodes
|
|
class Node {
|
|
constructor() {
|
|
this.x = Math.random() * canvas.width;
|
|
this.y = Math.random() * canvas.height;
|
|
this.velX = (Math.random() - 0.5) * motion * 2;
|
|
this.velY = (Math.random() - 0.5) * motion * 2;
|
|
this.size = 1 + Math.random() * (1 + density * 4);
|
|
this.life = 0;
|
|
this.maxLife = 100 + Math.random() * 200;
|
|
}
|
|
|
|
update() {
|
|
this.x += this.velX;
|
|
this.y += this.velY;
|
|
if (this.x < 0 || this.x > canvas.width) this.velX *= -1;
|
|
if (this.y < 0 || this.y > canvas.height) this.velY *= -1;
|
|
this.life++;
|
|
}
|
|
|
|
draw() {
|
|
const ageRatio = this.life / this.maxLife;
|
|
const alpha = 1 - Math.min(1, ageRatio * 2);
|
|
c.globalAlpha = alpha;
|
|
c.fillStyle = color(ageRatio * 255);
|
|
c.beginPath();
|
|
c.arc(this.x, this.y, this.size * (0.8 + ageRatio * 0.2), 0, Math.PI * 2);
|
|
c.fill();
|
|
c.globalAlpha = 1;
|
|
}
|
|
}
|
|
|
|
// Connections between nodes
|
|
class Connection {
|
|
constructor(a, b) {
|
|
this.a = a;
|
|
this.b = b;
|
|
this.length = Math.hypot(a.x - b.x, a.y - b.y);
|
|
this.strength = 0.1 + Math.random() * 0.3;
|
|
this.age = 0;
|
|
}
|
|
|
|
update() {
|
|
this.age++;
|
|
}
|
|
|
|
draw() {
|
|
const ageRatio = this.age / 100;
|
|
if (ageRatio > 1) return;
|
|
|
|
const width = 0.3 + this.strength * (1 - ageRatio) * 2;
|
|
const alpha = (1 - ageRatio) * this.strength * 0.7;
|
|
|
|
c.strokeStyle = color(180 + ageRatio * 75);
|
|
c.lineWidth = width;
|
|
c.globalAlpha = alpha;
|
|
|
|
c.beginPath();
|
|
c.moveTo(this.a.x, this.a.y);
|
|
c.lineTo(this.b.x, this.b.y);
|
|
c.stroke();
|
|
|
|
c.globalAlpha = 1;
|
|
}
|
|
}
|
|
|
|
// Create nodes and connections
|
|
const nodes = [];
|
|
const connections = [];
|
|
const nodeCount = 50 + Math.floor(density * 150);
|
|
|
|
for (let i = 0; i < nodeCount; i++) {
|
|
nodes.push(new Node());
|
|
}
|
|
|
|
// Connect nodes based on connectedness
|
|
for (let i = 0; i < nodes.length; i++) {
|
|
for (let j = i + 1; j < nodes.length; j++) {
|
|
if (Math.random() < connectedness) {
|
|
connections.push(new Connection(nodes[i], nodes[j]));
|
|
}
|
|
}
|
|
}
|
|
|
|
// Animation loop
|
|
function animate() {
|
|
c.clearRect(0, 0, canvas.width, canvas.height);
|
|
c.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
|
c.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Update and draw connections
|
|
for (let i = connections.length - 1; i >= 0; i--) {
|
|
connections[i].update();
|
|
connections[i].draw();
|
|
if (connections[i].age > 100) {
|
|
connections.splice(i, 1);
|
|
if (Math.random() < 0.3) {
|
|
connections.push(new Connection(
|
|
nodes[Math.floor(Math.random() * nodes.length)],
|
|
nodes[Math.floor(Math.random() * nodes.length)]
|
|
));
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update and draw nodes
|
|
for (const node of nodes) {
|
|
node.update();
|
|
node.draw();
|
|
if (node.life > node.maxLife) {
|
|
nodes.push(new Node());
|
|
nodes.splice(nodes.indexOf(node), 1);
|
|
}
|
|
}
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |