birth: Fractal Hive Pulse
This commit is contained in:
parent
364a3aa0a6
commit
a1bcbdeb0d
1 changed files with 217 additions and 0 deletions
217
index.html
Normal file
217
index.html
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Flow</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
color: #555;
|
||||||
|
font-size: 10px;
|
||||||
|
text-shadow: 0 0 5px rgba(0,0,0,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');
|
||||||
|
|
||||||
|
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,
|
||||||
|
pulse: { avg: 1.05, min: 1, max: 1.1 },
|
||||||
|
dryness: 0.9
|
||||||
|
};
|
||||||
|
|
||||||
|
// Node class
|
||||||
|
class Node {
|
||||||
|
constructor(x, y, index) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.index = index;
|
||||||
|
this.target = { x, y };
|
||||||
|
this.velocity = { x: 0, y: 0 };
|
||||||
|
this.connections = [];
|
||||||
|
this.size = 1 + Math.random() * 2;
|
||||||
|
this.hue = Math.random() * 360;
|
||||||
|
this.maxConnections = 1 + Math.floor(params.connectedness * 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(targetX, targetY) {
|
||||||
|
this.target.x += (targetX - this.target.x) * 0.05 * params.motion;
|
||||||
|
this.target.y += (targetY - this.target.y) * 0.05 * params.motion;
|
||||||
|
|
||||||
|
this.velocity.x += (this.target.x - this.x) * 0.01 * params.motion;
|
||||||
|
this.velocity.y += (this.target.y - this.y) * 0.01 * params.motion;
|
||||||
|
|
||||||
|
this.x += this.velocity.x;
|
||||||
|
this.y += this.velocity.y;
|
||||||
|
|
||||||
|
this.velocity.x *= 0.9;
|
||||||
|
this.velocity.y *= 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `hsl(${this.hue}, 50%, ${80 + Math.sin(Date.now() * 0.001) * 10}%)`;
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connection class
|
||||||
|
class Connection {
|
||||||
|
constructor(a, b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.age = 0;
|
||||||
|
this.strength = 0.5 + Math.random() * 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.age++;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
const d = Math.hypot(this.a.x - this.b.x, this.a.y - this.b.y);
|
||||||
|
const thickness = 0.5 + this.strength * (0.5 + Math.sin(this.age * 0.1) * 0.3);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.a.x, this.a.y);
|
||||||
|
ctx.lineTo(this.b.x, this.b.y);
|
||||||
|
ctx.strokeStyle = `hsla(${this.a.hue}, 70%, 70%, ${this.strength * 0.7})`;
|
||||||
|
ctx.lineWidth = thickness;
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
// Glow effect
|
||||||
|
if (params.dryness < 0.5) {
|
||||||
|
ctx.shadowColor = `hsla(${this.a.hue}, 70%, 70%, 0.3)`;
|
||||||
|
ctx.shadowBlur = this.strength * 5;
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.shadowBlur = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Network
|
||||||
|
const nodes = [];
|
||||||
|
const connections = [];
|
||||||
|
const maxNodes = 40 + Math.floor(params.density * 60);
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
nodes.length = 0;
|
||||||
|
connections.length = 0;
|
||||||
|
|
||||||
|
// Create nodes
|
||||||
|
for (let i = 0; i < maxNodes; i++) {
|
||||||
|
nodes.push(new Node(
|
||||||
|
Math.random() * canvas.width,
|
||||||
|
Math.random() * canvas.height,
|
||||||
|
i
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial connections
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
for (let j = i + 1; j < nodes.length; j++) {
|
||||||
|
if (Math.random() < params.connectedness * 0.3) {
|
||||||
|
nodes[i].connections.push(j);
|
||||||
|
nodes[j].connections.push(i);
|
||||||
|
connections.push(new Connection(nodes[i], nodes[j]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
function updateConnections() {
|
||||||
|
// Remove old connections
|
||||||
|
for (let i = connections.length - 1; i >= 0; i--) {
|
||||||
|
if (connections[i].age > 100 + Math.random() * 100 ||
|
||||||
|
Math.random() < 0.005 * params.connectedness) {
|
||||||
|
connections.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new connections
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
if (nodes[i].connections.length < nodes[i].maxConnections && Math.random() < 0.02 * params.connectedness) {
|
||||||
|
const possible = nodes.filter(n =>
|
||||||
|
n !== nodes[i] &&
|
||||||
|
!nodes[i].connections.includes(n.index) &&
|
||||||
|
n.index > nodes[i].index
|
||||||
|
);
|
||||||
|
|
||||||
|
if (possible.length > 0) {
|
||||||
|
const target = possible[Math.floor(Math.random() * possible.length)];
|
||||||
|
nodes[i].connections.push(target.index);
|
||||||
|
target.connections.push(nodes[i].index);
|
||||||
|
connections.push(new Connection(nodes[i], target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Mouse influence
|
||||||
|
const mouse = {
|
||||||
|
x: canvas.width / 2 + Math.sin(Date.now() * 0.0005) * canvas.width * 0.3,
|
||||||
|
y: canvas.height / 2 + Math.cos(Date.now() * 0.0003) * canvas.height * 0.3
|
||||||
|
};
|
||||||
|
|
||||||
|
// Update nodes
|
||||||
|
nodes.forEach(node => {
|
||||||
|
node.update(
|
||||||
|
mouse.x + (Math.random() - 0.5) * canvas.width * 0.2 * params.motion,
|
||||||
|
mouse.y + (Math.random() - 0.5) * canvas.height * 0.2 * params.motion
|
||||||
|
);
|
||||||
|
node.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update and draw connections
|
||||||
|
updateConnections();
|
||||||
|
connections.forEach(conn => {
|
||||||
|
conn.update();
|
||||||
|
conn.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
|
||||||
|
// Handle window focus to reset if needed
|
||||||
|
window.addEventListener('focus', init);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue