birth: Fractured Light in Wires
This commit is contained in:
parent
3dc98bdb4c
commit
bf44c2d08f
1 changed files with 172 additions and 0 deletions
172
index.html
Normal file
172
index.html
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Live Canvas</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
color: #555;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #333;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas"></canvas>
|
||||||
|
<div id="info">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();
|
||||||
|
|
||||||
|
// Animation parameters
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: 1.08
|
||||||
|
};
|
||||||
|
|
||||||
|
// Network graph implementation
|
||||||
|
class NetworkNode {
|
||||||
|
constructor(x, y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.vx = 0;
|
||||||
|
this.vy = 0;
|
||||||
|
this.size = 2 + Math.random() * 3;
|
||||||
|
this.lifespan = 50 + Math.random() * 100;
|
||||||
|
this.energy = Math.random();
|
||||||
|
this.connections = [];
|
||||||
|
this.maxConnections = Math.floor(2 + params.connectedness * 4);
|
||||||
|
this.age = 0;
|
||||||
|
this.targetX = x;
|
||||||
|
this.targetY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.age++;
|
||||||
|
|
||||||
|
// Move toward target with some noise
|
||||||
|
const dx = this.targetX - this.x;
|
||||||
|
const dy = this.targetY - this.y;
|
||||||
|
this.vx += dx * 0.01 * params.motion;
|
||||||
|
this.vy += dy * 0.01 * params.motion;
|
||||||
|
|
||||||
|
// Add some randomness to motion
|
||||||
|
this.vx += (Math.random() - 0.5) * 0.2;
|
||||||
|
this.vy += (Math.random() - 0.5) * 0.2;
|
||||||
|
|
||||||
|
// Friction
|
||||||
|
this.vx *= 0.95;
|
||||||
|
this.vy *= 0.95;
|
||||||
|
|
||||||
|
this.x += this.vx;
|
||||||
|
this.y += this.vy;
|
||||||
|
|
||||||
|
// Update connections
|
||||||
|
this.connections = this.connections.filter(conn => {
|
||||||
|
if (conn.target.age > conn.target.lifespan * 0.8) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add new connections
|
||||||
|
if (this.connections.length < this.maxConnections && Math.random() < 0.02) {
|
||||||
|
const otherNode = nodes[Math.floor(Math.random() * nodes.length)];
|
||||||
|
if (otherNode !== this && !this.connections.some(c => c.target === otherNode)) {
|
||||||
|
this.connections.push({ target: otherNode, strength: 0.5 + Math.random() * 0.5 });
|
||||||
|
otherNode.connections.push({ target: this, strength: 0.5 + Math.random() * 0.5 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `rgba(200, 200, 200, ${this.energy})`;
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let nodes = [];
|
||||||
|
function initNodes() {
|
||||||
|
nodes = [];
|
||||||
|
const count = 50 + Math.floor(params.density * 100);
|
||||||
|
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
nodes.push(new NetworkNode(
|
||||||
|
Math.random() * canvas.width,
|
||||||
|
Math.random() * canvas.height
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawConnections() {
|
||||||
|
ctx.strokeStyle = 'rgba(150, 150, 150, 0.1)';
|
||||||
|
ctx.lineWidth = 0.5;
|
||||||
|
|
||||||
|
nodes.forEach(node => {
|
||||||
|
node.connections.forEach(conn => {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(node.x, node.y);
|
||||||
|
ctx.lineTo(conn.target.x, conn.target.y);
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateNodes() {
|
||||||
|
nodes.forEach(node => node.update());
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawNodes() {
|
||||||
|
nodes.forEach(node => node.draw());
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
updateNodes();
|
||||||
|
drawConnections();
|
||||||
|
drawNodes();
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
initNodes();
|
||||||
|
animate();
|
||||||
|
|
||||||
|
// Handle pulse changes (simulated)
|
||||||
|
setInterval(() => {
|
||||||
|
params.pulse = 1.05 + Math.random() * 0.05;
|
||||||
|
}, 5000);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue