birth: Pulsing Neural Drift
This commit is contained in:
parent
c4836e859f
commit
87328a3ebc
1 changed files with 197 additions and 0 deletions
197
index.html
Normal file
197
index.html
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba · motd.social</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
color: #fff;
|
||||
font-family: monospace;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
left: 20px;
|
||||
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');
|
||||
|
||||
// Set canvas to full window size
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Parameters
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.08, min: 1.05, max: 1.10 },
|
||||
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.9, playfulness: 0, tension: 0 },
|
||||
time: 0
|
||||
};
|
||||
|
||||
// Network graph implementation
|
||||
class NetworkNode {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.vx = (Math.random() - 0.5) * params.motion * 2;
|
||||
this.vy = (Math.random() - 0.5) * params.motion * 2;
|
||||
this.size = 2 + Math.random() * 8 * params.density;
|
||||
this.connections = [];
|
||||
this.maxConnections = Math.floor(5 * params.connectedness);
|
||||
this.lifetime = 0;
|
||||
this.maxLifetime = 1000 * (0.5 + params.lifespan * 0.5);
|
||||
}
|
||||
|
||||
update() {
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
// Bounce off edges
|
||||
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
|
||||
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
|
||||
|
||||
// Random movement
|
||||
this.vx += (Math.random() - 0.5) * params.motion * 0.1;
|
||||
this.vy += (Math.random() - 0.5) * params.motion * 0.1;
|
||||
|
||||
// Normalize velocity
|
||||
const speed = Math.sqrt(this.vx * this.vx + this.vy * this.vy);
|
||||
if (speed > params.motion * 2) {
|
||||
this.vx = (this.vx / speed) * params.motion * 2;
|
||||
this.vy = (this.vy / speed) * params.motion * 2;
|
||||
}
|
||||
|
||||
// Age
|
||||
this.lifetime++;
|
||||
if (this.lifetime > this.maxLifetime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Connect to others
|
||||
if (this.connections.length < this.maxConnections && Math.random() < params.connectedness * 0.1) {
|
||||
const available = nodes.filter(n =>
|
||||
n !== this &&
|
||||
!this.connections.includes(n) &&
|
||||
n.connections.length < n.maxConnections &&
|
||||
Math.random() < 0.3
|
||||
);
|
||||
|
||||
if (available.length > 0) {
|
||||
const target = available[Math.floor(Math.random() * available.length)];
|
||||
this.connections.push(target);
|
||||
target.connections.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
draw() {
|
||||
// Draw connections
|
||||
ctx.strokeStyle = `rgba(255, 255, 255, ${0.2 + this.connections.length * 0.05})`;
|
||||
ctx.lineWidth = 1 + this.connections.length * 0.5;
|
||||
this.connections.forEach(conn => {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.x, this.y);
|
||||
ctx.lineTo(conn.x, conn.y);
|
||||
ctx.stroke();
|
||||
});
|
||||
|
||||
// Draw node
|
||||
ctx.fillStyle = `hsl(200, ${80 * params.tone.dryness}%, ${50 + this.connections.length * 5}%)`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
// Draw inner circle based on age
|
||||
const ageRatio = Math.min(1, this.lifetime / this.maxLifetime);
|
||||
ctx.fillStyle = `hsla(220, ${80 * params.tone.dryness}%, ${30 + ageRatio * 20}%, 0.7)`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, this.size * 0.5, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
// Draw connections to center
|
||||
ctx.strokeStyle = `rgba(255, 255, 255, ${0.1 + ageRatio * 0.3})`;
|
||||
ctx.lineWidth = 1;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.x, this.y);
|
||||
ctx.lineTo(this.x, this.y - this.size * 2 * ageRatio);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
let nodes = [];
|
||||
function initNodes() {
|
||||
nodes = [];
|
||||
const count = 100 + Math.floor(params.density * 200);
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
nodes.push(new NetworkNode(
|
||||
Math.random() * canvas.width,
|
||||
Math.random() * canvas.height
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function updateNodes() {
|
||||
// Remove dead nodes
|
||||
nodes = nodes.filter(node => node.update());
|
||||
}
|
||||
|
||||
function drawNodes() {
|
||||
nodes.forEach(node => node.draw());
|
||||
}
|
||||
|
||||
function animate() {
|
||||
params.time += 0.01;
|
||||
|
||||
// Clear with fade effect
|
||||
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Occasionally add new nodes
|
||||
if (Math.random() < 0.02) {
|
||||
nodes.push(new NetworkNode(
|
||||
Math.random() * canvas.width,
|
||||
Math.random() * canvas.height
|
||||
));
|
||||
}
|
||||
|
||||
updateNodes();
|
||||
drawNodes();
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
initNodes();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue