birth: Pulsing Monochrome Network
This commit is contained in:
parent
26b1ad1734
commit
ec4e98a0e5
1 changed files with 209 additions and 0 deletions
209
index.html
Normal file
209
index.html
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
<!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: #0a0a0a;
|
||||
color: #aaa;
|
||||
font-family: 'Courier New', monospace;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
.attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
font-size: 10px;
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div class="attribution">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;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Parameters derived from the abstract description
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.06, min: 0.9, max: 1.2 },
|
||||
tone: { dryness: 0.8, playfulness: 0.1 },
|
||||
time: 0,
|
||||
nodes: [],
|
||||
connections: [],
|
||||
maxNodes: 200 * params.density,
|
||||
maxConnections: 400 * params.connectedness,
|
||||
linkDistance: 150,
|
||||
nodeSize: 3 + params.density * 5,
|
||||
pulseScale: 0.05,
|
||||
decay: 0.97,
|
||||
hue: 0
|
||||
};
|
||||
|
||||
// Initialize nodes
|
||||
function initNodes() {
|
||||
params.nodes = [];
|
||||
for (let i = 0; i < params.maxNodes; i++) {
|
||||
params.nodes.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: Math.random() * canvas.height,
|
||||
vx: (Math.random() - 0.5) * 2 * params.motion,
|
||||
vy: (Math.random() - 0.5) * 2 * params.motion,
|
||||
size: params.nodeSize + Math.random() * 2,
|
||||
pulse: 1,
|
||||
pulseSpeed: 0.01 + Math.random() * 0.02,
|
||||
life: Math.random() * 100,
|
||||
color: `hsl(0, 0%, ${70 + Math.random() * 15}%)`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize connections
|
||||
function initConnections() {
|
||||
params.connections = [];
|
||||
for (let i = 0; i < params.nodes.length; i++) {
|
||||
for (let j = i + 1; j < Math.min(i + 5, params.nodes.length); j++) {
|
||||
if (Math.random() < params.connectedness * 0.3) {
|
||||
params.connections.push({
|
||||
from: i,
|
||||
to: j,
|
||||
strength: 0.5 + Math.random() * 0.5,
|
||||
distance: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update node positions
|
||||
function updateNodes() {
|
||||
params.nodes.forEach(node => {
|
||||
// Add small random walk based on motion
|
||||
node.vx += (Math.random() - 0.5) * 0.1 * params.motion;
|
||||
node.vy += (Math.random() - 0.5) * 0.1 * params.motion;
|
||||
|
||||
// Dampen velocity
|
||||
node.vx *= 0.95;
|
||||
node.vy *= 0.95;
|
||||
|
||||
// Update position
|
||||
node.x += node.vx;
|
||||
node.y += node.vy;
|
||||
|
||||
// Boundary check
|
||||
if (node.x < 0 || node.x > canvas.width) node.vx *= -1;
|
||||
if (node.y < 0 || node.y > canvas.height) node.vy *= -1;
|
||||
|
||||
// Pulse effect
|
||||
node.pulse = 0.9 + Math.sin(params.time * node.pulseSpeed) * 0.1 * params.pulseScale;
|
||||
|
||||
// Life decay
|
||||
node.life *= params.decay;
|
||||
if (node.life < 10) {
|
||||
node.life = 100;
|
||||
node.x = Math.random() * canvas.width;
|
||||
node.y = Math.random() * canvas.height;
|
||||
}
|
||||
|
||||
// Update color based on pulse and parameters
|
||||
const baseLightness = 70 + Math.sin(params.time * 0.01) * 5;
|
||||
node.color = `hsl(0, 0%, ${baseLightness + (node.pulse - 1) * 20}%)`;
|
||||
});
|
||||
}
|
||||
|
||||
// Update connections
|
||||
function updateConnections() {
|
||||
params.connections.forEach(conn => {
|
||||
const from = params.nodes[conn.from];
|
||||
const to = params.nodes[conn.to];
|
||||
const dx = to.x - from.x;
|
||||
const dy = to.y - from.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
conn.distance = distance;
|
||||
|
||||
// Adjust connection strength based on distance
|
||||
if (distance < params.linkDistance) {
|
||||
conn.strength = 0.5 + (1 - distance / params.linkDistance);
|
||||
} else {
|
||||
conn.strength = 0.1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Draw everything
|
||||
function draw() {
|
||||
// Fade background slightly
|
||||
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw connections
|
||||
ctx.lineWidth = 1;
|
||||
params.connections.forEach(conn => {
|
||||
if (conn.strength > 0.2) {
|
||||
const from = params.nodes[conn.from];
|
||||
const to = params.nodes[conn.to];
|
||||
const alpha = conn.strength * 0.7;
|
||||
ctx.strokeStyle = `rgba(255, 255, 255, ${alpha})`;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(from.x, from.y);
|
||||
ctx.lineTo(to.x, to.y);
|
||||
ctx.stroke();
|
||||
}
|
||||
});
|
||||
|
||||
// Draw nodes
|
||||
params.nodes.forEach(node => {
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, node.size * node.pulse, 0, Math.PI * 2);
|
||||
ctx.fillStyle = node.color;
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = 'rgba(255, 255, 255, 0.3)';
|
||||
ctx.stroke();
|
||||
});
|
||||
|
||||
// Update time
|
||||
params.time += 0.01;
|
||||
}
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
updateNodes();
|
||||
updateConnections();
|
||||
draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Initialize and start
|
||||
initNodes();
|
||||
initConnections();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue