birth: Neural Mesh in Static Flux
This commit is contained in:
parent
68541488ae
commit
910f8164dd
1 changed files with 184 additions and 0 deletions
184
index.html
Normal file
184
index.html
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neural Mesh</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
color: rgba(255,255,255,0.3);
|
||||
font-family: 'Courier New', monospace;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
#canvas {
|
||||
display: block;
|
||||
background: radial-gradient(circle at center, #0a0a0a 0%, #000000 100%);
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 10px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
</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;
|
||||
}
|
||||
|
||||
let nodes = [];
|
||||
let edges = [];
|
||||
let pulse = 1.0;
|
||||
let time = 0;
|
||||
|
||||
function init() {
|
||||
resizeCanvas();
|
||||
const density = 0.5;
|
||||
const complexity = 0.5;
|
||||
const connectedness = 0.5;
|
||||
const motion = 0.5;
|
||||
|
||||
// Generate nodes
|
||||
const nodeCount = Math.floor(50 + (250 * density));
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
const angle = (i / nodeCount) * Math.PI * 2;
|
||||
const radius = 0.3 * Math.min(canvas.width, canvas.height) * (0.5 + Math.random() * 0.5);
|
||||
nodes.push({
|
||||
x: canvas.width/2 + Math.cos(angle) * radius,
|
||||
y: canvas.height/2 + Math.sin(angle) * radius,
|
||||
vx: 0,
|
||||
vy: 0,
|
||||
radius: 1 + Math.random() * 3,
|
||||
baseRadius: 1 + Math.random() * 3,
|
||||
charge: Math.random() * 2 - 1,
|
||||
mass: 0.5 + Math.random()
|
||||
});
|
||||
}
|
||||
|
||||
// Generate edges based on connectedness
|
||||
const maxEdges = Math.floor(nodeCount * nodeCount * 0.1 * connectedness);
|
||||
for (let i = 0; i < maxEdges; i++) {
|
||||
const a = Math.floor(Math.random() * nodes.length);
|
||||
const b = Math.floor(Math.random() * nodes.length);
|
||||
if (a !== b) {
|
||||
edges.push({
|
||||
a, b,
|
||||
distance: nodes[a].baseRadius + nodes[b].baseRadius + 20 + Math.random() * 40,
|
||||
strength: 0.1 + Math.random() * 0.2,
|
||||
tension: 0.5 + Math.random() * 0.5
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Initial pulse
|
||||
pulse = 1.0 + (Math.random() * 0.2 - 0.1);
|
||||
}
|
||||
|
||||
function update() {
|
||||
const motionFactor = 0.5;
|
||||
const complexityFactor = 0.5;
|
||||
const connectednessFactor = 0.5;
|
||||
|
||||
// Update nodes with repulsion/attraction
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
nodes[i].vx *= 0.9;
|
||||
nodes[i].vy *= 0.9;
|
||||
|
||||
// Repulsion from other nodes
|
||||
for (let j = 0; j < nodes.length; j++) {
|
||||
if (i !== j) {
|
||||
const dx = nodes[j].x - nodes[i].x;
|
||||
const dy = nodes[j].y - nodes[i].y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
const force = 0.2 * nodes[i].mass * nodes[j].mass / (dist * dist + 1000);
|
||||
|
||||
nodes[i].vx -= dx / dist * force * motionFactor;
|
||||
nodes[i].vy -= dy / dist * force * motionFactor;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply velocity
|
||||
nodes[i].x += nodes[i].vx;
|
||||
nodes[i].y += nodes[i].vy;
|
||||
|
||||
// Boundary check
|
||||
nodes[i].x = Math.max(nodes[i].radius, Math.min(canvas.width - nodes[i].radius, nodes[i].x));
|
||||
nodes[i].y = Math.max(nodes[i].radius, Math.min(canvas.height - nodes[i].radius, nodes[i].y));
|
||||
|
||||
// Pulse effect
|
||||
nodes[i].radius = nodes[i].baseRadius * (1 + Math.sin(time * 2) * 0.1 * pulse);
|
||||
}
|
||||
|
||||
// Update edges
|
||||
for (let edge of edges) {
|
||||
const a = nodes[edge.a];
|
||||
const b = nodes[edge.b];
|
||||
const dx = b.x - a.x;
|
||||
const dy = b.y - a.y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
const force = edge.strength * (dist - edge.distance) / dist;
|
||||
|
||||
// Apply tension
|
||||
a.vx += dx * force * 0.5 * connectednessFactor;
|
||||
a.vy += dy * force * 0.5 * connectednessFactor;
|
||||
b.vx -= dx * force * 0.5 * connectednessFactor;
|
||||
b.vy -= dy * force * 0.5 * connectednessFactor;
|
||||
|
||||
// Draw edge
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(a.x, a.y);
|
||||
ctx.lineTo(b.x, b.y);
|
||||
ctx.strokeStyle = `rgba(255, 255, 255, ${0.1 + 0.3 * complexityFactor})`;
|
||||
ctx.lineWidth = 0.5 + 0.5 * connectednessFactor;
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Draw nodes
|
||||
for (let node of nodes) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, node.radius, 0, Math.PI * 2);
|
||||
ctx.fillStyle = `rgba(255, 255, 255, ${0.7 + 0.3 * Math.sin(time)})`;
|
||||
ctx.fill();
|
||||
|
||||
// Inner glow
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, node.radius * 0.5, 0, Math.PI * 2);
|
||||
ctx.fillStyle = `rgba(180, 180, 255, ${0.5 + 0.3 * Math.sin(time * 1.5)})`;
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
time += 0.01;
|
||||
}
|
||||
|
||||
function animate() {
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
update();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
resizeCanvas();
|
||||
});
|
||||
|
||||
init();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue