birth: Teal Pulse in the Dark
This commit is contained in:
parent
57fe84db42
commit
c3cd67d568
1 changed files with 230 additions and 0 deletions
230
index.html
Normal file
230
index.html
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
<!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-color: #0a0a0a;
|
||||
color: #33ffaa;
|
||||
font-family: monospace;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
canvas {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
font-size: 12px;
|
||||
opacity: 0.5;
|
||||
z-index: 10;
|
||||
}
|
||||
</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;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Parameters based on organism metrics
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulseRange: { min: 1.05, max: 1.20, avg: 1.14 },
|
||||
tone: {
|
||||
anger: 0.00,
|
||||
sadness: 0.00,
|
||||
curiosity: 0.70,
|
||||
dryness: 0.90,
|
||||
playfulness: 0.10,
|
||||
tension: 0.00
|
||||
}
|
||||
};
|
||||
|
||||
// Network graph setup
|
||||
const nodes = [];
|
||||
const edges = [];
|
||||
const nodeCount = Math.floor(params.density * 200) + 20;
|
||||
const linkCount = Math.floor(params.connectedness * 100) + 10;
|
||||
|
||||
class Node {
|
||||
constructor() {
|
||||
this.x = Math.random() * canvas.width;
|
||||
this.y = Math.random() * canvas.height;
|
||||
this.baseX = this.x;
|
||||
this.baseY = this.y;
|
||||
this.vx = 0;
|
||||
this.vy = 0;
|
||||
this.radius = 2 + Math.random() * 3 * params.complexity;
|
||||
this.color = `hsl(${200 + Math.random() * 30}, 80%, 70%)`;
|
||||
this.pulse = params.pulseRange.min +
|
||||
(params.pulseRange.max - params.pulseRange.min) * Math.random();
|
||||
this.life = 0;
|
||||
this.maxLife = 1000 * (0.5 + params.lifespan);
|
||||
}
|
||||
|
||||
update() {
|
||||
this.life++;
|
||||
|
||||
// Gentle movement away from center
|
||||
const centerDist = Math.sqrt(
|
||||
Math.pow(this.x - canvas.width/2, 2) +
|
||||
Math.pow(this.y - canvas.height/2, 2)
|
||||
);
|
||||
|
||||
this.vx += (Math.random() - 0.5) * 0.1 * params.motion;
|
||||
this.vy += (Math.random() - 0.5) * 0.1 * params.motion;
|
||||
this.vx += (this.x - this.baseX) * 0.001 * params.motion;
|
||||
this.vy += (this.y - this.baseY) * 0.001 * params.motion;
|
||||
|
||||
// Add slight repulsion from other nodes
|
||||
nodes.forEach(other => {
|
||||
if (other !== this) {
|
||||
const dx = other.x - this.x;
|
||||
const dy = other.y - this.y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
if (dist < 50) {
|
||||
const force = 0.5 * (1 - dist/50) * params.motion;
|
||||
this.vx -= dx * force;
|
||||
this.vy -= dy * force;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Apply velocity with damping
|
||||
this.vx *= 0.85;
|
||||
this.vy *= 0.85;
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
// Update color based on pulse
|
||||
const hue = 210 + Math.sin(this.life * 0.01 * this.pulse) * 10;
|
||||
this.color = `hsl(${hue}, ${70 + Math.sin(this.life * 0.001) * 20}%, ${60 + Math.sin(this.life * 0.0007) * 10}%)`;
|
||||
}
|
||||
|
||||
draw() {
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, this.radius * (0.8 + 0.2 * Math.sin(this.life * 0.01)), 0, Math.PI * 2);
|
||||
ctx.fillStyle = this.color;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
class Edge {
|
||||
constructor(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.length = Math.sqrt(
|
||||
Math.pow(b.x - a.x, 2) +
|
||||
Math.pow(b.y - a.y, 2)
|
||||
);
|
||||
this.strength = 0.5 + Math.random() * 0.5 * params.connectedness;
|
||||
}
|
||||
|
||||
update() {
|
||||
// Adjust length based on connectedness
|
||||
this.length = Math.sqrt(
|
||||
Math.pow(this.b.x - this.a.x, 2) +
|
||||
Math.pow(this.b.y - this.a.y, 2)
|
||||
) * (0.9 + 0.2 * this.strength);
|
||||
}
|
||||
|
||||
draw() {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.a.x, this.a.y);
|
||||
ctx.lineTo(this.b.x, this.b.y);
|
||||
ctx.strokeStyle = `rgba(51, 255, 170, ${0.3 + 0.7 * this.strength * (0.7 + 0.3 * params.connectedness)})`;
|
||||
ctx.lineWidth = 0.1 + 1.0 * this.strength;
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize network
|
||||
function initNetwork() {
|
||||
nodes.length = 0;
|
||||
edges.length = 0;
|
||||
|
||||
// Create nodes
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
nodes.push(new Node());
|
||||
}
|
||||
|
||||
// Create edges
|
||||
for (let i = 0; i < linkCount; i++) {
|
||||
const a = nodes[Math.floor(Math.random() * nodes.length)];
|
||||
const b = nodes[Math.floor(Math.random() * nodes.length)];
|
||||
if (a !== b) {
|
||||
edges.push(new Edge(a, b));
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to nearest neighbors for higher complexity
|
||||
nodes.forEach(node => {
|
||||
const nearest = [];
|
||||
nodes.forEach(other => {
|
||||
if (other !== node) {
|
||||
const dx = other.x - node.x;
|
||||
const dy = other.y - node.y;
|
||||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||||
nearest.push({ node: other, dist });
|
||||
}
|
||||
});
|
||||
nearest.sort((a, b) => a.dist - b.dist);
|
||||
nearest.slice(0, Math.floor(3 * params.complexity)).forEach(near => {
|
||||
edges.push(new Edge(node, near.node));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
initNetwork();
|
||||
|
||||
// Main animation loop
|
||||
function animate() {
|
||||
// Clear with fade effect
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Update nodes and edges
|
||||
nodes.forEach(node => node.update());
|
||||
edges.forEach(edge => edge.update());
|
||||
|
||||
// Draw edges first
|
||||
edges.forEach(edge => edge.draw());
|
||||
|
||||
// Then draw nodes
|
||||
nodes.forEach(node => node.draw());
|
||||
|
||||
// Occasionally reset network if lifespan is high
|
||||
if (Math.random() < 0.001 * params.lifespan) {
|
||||
initNetwork();
|
||||
}
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Start animation
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue