birth: pulsing neural tendrils
This commit is contained in:
parent
9b92f1e9c5
commit
df041b6ab1
1 changed files with 198 additions and 0 deletions
198
index.html
Normal file
198
index.html
Normal file
|
|
@ -0,0 +1,198 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neural Amoeba</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
color: #888;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.attribution {
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
</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');
|
||||||
|
|
||||||
|
function resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters based on input
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.12, min: 0.9, max: 1.3 },
|
||||||
|
tone: { anger: 0, sadness: 0, curiosity: 0.3, dryness: 0.8, playfulness: 0.1, tension: 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Colors based on tone
|
||||||
|
const hue = 160 + params.tone.curiosity * 40;
|
||||||
|
const sat = params.tone.dryness > 0.7 ? 10 : 70;
|
||||||
|
const lum = params.tone.playfulness > 0.1 ? 80 : 50;
|
||||||
|
|
||||||
|
// Network nodes and connections
|
||||||
|
let nodes = [];
|
||||||
|
let connections = [];
|
||||||
|
const nodeCount = Math.floor(params.density * 200) + 50;
|
||||||
|
const connectionCount = Math.floor(params.connectedness * 500) + 100;
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
function init() {
|
||||||
|
nodes = [];
|
||||||
|
connections = [];
|
||||||
|
|
||||||
|
// Create nodes
|
||||||
|
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,
|
||||||
|
size: Math.random() * 5 + 1,
|
||||||
|
life: 1,
|
||||||
|
pulse: params.pulse.avg * (0.9 + Math.random() * 0.2)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create connections
|
||||||
|
for (let i = 0; i < connectionCount; i++) {
|
||||||
|
if (nodes.length < 2) break;
|
||||||
|
const a = Math.floor(Math.random() * nodes.length);
|
||||||
|
const b = Math.floor(Math.random() * nodes.length);
|
||||||
|
if (a !== b) {
|
||||||
|
connections.push({
|
||||||
|
from: a,
|
||||||
|
to: b,
|
||||||
|
strength: Math.random() * params.connectedness * 0.5 + 0.5,
|
||||||
|
phase: Math.random() * Math.PI * 2
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
function update() {
|
||||||
|
// Update nodes
|
||||||
|
nodes.forEach(node => {
|
||||||
|
// Movement with slightly different speeds
|
||||||
|
node.x += node.vx * node.pulse;
|
||||||
|
node.y += node.vy * node.pulse;
|
||||||
|
|
||||||
|
// Boundary check
|
||||||
|
if (node.x < 0) { node.x = canvas.width; node.vx *= -0.8; }
|
||||||
|
if (node.x > canvas.width) { node.x = 0; node.vx *= -0.8; }
|
||||||
|
if (node.y < 0) { node.y = canvas.height; node.vy *= -0.8; }
|
||||||
|
if (node.y > canvas.height) { node.y = 0; node.vy *= -0.8; }
|
||||||
|
|
||||||
|
// Pulse variation
|
||||||
|
node.pulse = params.pulse.avg * (0.9 + Math.random() * 0.2);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update connections
|
||||||
|
connections.forEach(conn => {
|
||||||
|
conn.phase += 0.01 * params.motion;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
function draw() {
|
||||||
|
// Clear with fade
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Draw connections
|
||||||
|
connections.forEach(conn => {
|
||||||
|
const a = nodes[conn.from];
|
||||||
|
const b = nodes[conn.to];
|
||||||
|
const dist = Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
|
||||||
|
const maxDist = 200;
|
||||||
|
|
||||||
|
// Only draw if not too far
|
||||||
|
if (dist < maxDist) {
|
||||||
|
const alpha = Math.min(1, conn.strength) * (dist / maxDist);
|
||||||
|
const thickness = Math.min(3, conn.strength * 2);
|
||||||
|
const hue1 = hue + 30;
|
||||||
|
const hue2 = hue - 30;
|
||||||
|
|
||||||
|
// Gradient based on phase
|
||||||
|
const grad = ctx.createLinearGradient(a.x, a.y, b.x, b.y);
|
||||||
|
grad.addColorStop(0, `hsl(${hue1}, ${sat}%, ${lum}%, ${alpha})`);
|
||||||
|
grad.addColorStop(0.5, `hsl(${hue}, ${sat}%, ${lum}%, ${alpha})`);
|
||||||
|
grad.addColorStop(1, `hsl(${hue2}, ${sat}%, ${lum}%, ${alpha})`);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(a.x, a.y);
|
||||||
|
ctx.lineTo(b.x, b.y);
|
||||||
|
ctx.strokeStyle = grad;
|
||||||
|
ctx.lineWidth = thickness;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Draw nodes
|
||||||
|
nodes.forEach(node => {
|
||||||
|
const size = node.size * node.pulse;
|
||||||
|
|
||||||
|
// Outer glow
|
||||||
|
const outerGlow = size * 1.5;
|
||||||
|
const gradient = ctx.createRadialGradient(
|
||||||
|
node.x, node.y, size * 0.3,
|
||||||
|
node.x, node.y, outerGlow
|
||||||
|
);
|
||||||
|
gradient.addColorStop(0, `hsl(${hue}, ${sat}%, ${lum}%, 0.8)`);
|
||||||
|
gradient.addColorStop(1, `hsl(${hue}, ${sat}%, ${lum}%, 0)`);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(node.x, node.y, size, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `hsl(${hue}, ${sat}%, ${lum}%)`;
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
// Inner highlight
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(node.x, node.y, size * 0.3, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `hsla(${hue + 20}, ${sat + 30}%, 90%, 0.8)`;
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation loop
|
||||||
|
function animate() {
|
||||||
|
update();
|
||||||
|
draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize and start
|
||||||
|
init();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue