birth: Fractal Web of Persistent Motion
This commit is contained in:
parent
f1d8645fdf
commit
6e7e17481d
1 changed files with 220 additions and 0 deletions
220
index.html
Normal file
220
index.html
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Fractal Network</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a1a;
|
||||
color: #4a5568;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
#canvas {
|
||||
display: block;
|
||||
background: #0a0a1a;
|
||||
}
|
||||
#attribution {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
font-size: 10px;
|
||||
color: #4a5568;
|
||||
opacity: 0.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
</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 resize() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resize);
|
||||
resize();
|
||||
|
||||
// Configuration from parameters
|
||||
const params = {
|
||||
motion: 0.494,
|
||||
density: 0.491,
|
||||
complexity: 0.516,
|
||||
connectedness: 0.512,
|
||||
lifespan: 0.500,
|
||||
pulse: { avg: 1.00, min: 0.30, max: 2.00 },
|
||||
tone: {
|
||||
anger: 0.00,
|
||||
sadness: 0.00,
|
||||
curiosity: 0.30,
|
||||
dryness: 0.80,
|
||||
playfulness: 0.10,
|
||||
tension: 0.00
|
||||
}
|
||||
};
|
||||
|
||||
// Network graph implementation
|
||||
class NetworkNode {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.vx = (Math.random() - 0.5) * 2 * params.motion;
|
||||
this.vy = (Math.random() - 0.5) * 2 * params.motion;
|
||||
this.size = 1 + Math.random() * 2 * params.density;
|
||||
this.life = 0;
|
||||
this.maxLife = 100 + Math.random() * 100 * params.lifespan;
|
||||
this.connections = [];
|
||||
this.color = `hsl(180, ${70 + Math.random() * 20}%, ${30 + Math.random() * 20}%)`;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
// Boundary collision
|
||||
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
|
||||
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
|
||||
|
||||
this.life++;
|
||||
if (this.life > this.maxLife) {
|
||||
this.life = this.maxLife;
|
||||
this.size *= 0.95;
|
||||
}
|
||||
|
||||
// Decay connections
|
||||
this.connections = this.connections.filter(conn =>
|
||||
conn.node.life > conn.node.maxLife * 0.7 &&
|
||||
conn.node.size > 0.1
|
||||
);
|
||||
}
|
||||
|
||||
draw() {
|
||||
const pulseFactor = params.pulse.min + (params.pulse.max - params.pulse.min) *
|
||||
(0.5 + 0.5 * Math.sin(Date.now() * 0.0005));
|
||||
|
||||
ctx.globalAlpha = Math.min(this.life / this.maxLife, 1) * 0.9;
|
||||
ctx.fillStyle = this.color;
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, this.size * pulseFactor, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
// Draw connections
|
||||
ctx.strokeStyle = this.color;
|
||||
ctx.lineWidth = 0.5 * params.connectedness;
|
||||
for (const conn of this.connections) {
|
||||
if (conn.node.life > conn.node.maxLife * 0.7) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.x, this.y);
|
||||
ctx.lineTo(conn.node.x, conn.node.y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkGraph {
|
||||
constructor() {
|
||||
this.nodes = [];
|
||||
const count = 100 + Math.floor(params.density * 150);
|
||||
this.maxNodes = count;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
this.nodes.push(new NetworkNode(
|
||||
Math.random() * canvas.width,
|
||||
Math.random() * canvas.height
|
||||
));
|
||||
}
|
||||
|
||||
this.energy = 0;
|
||||
this.maxEnergy = 1000;
|
||||
}
|
||||
|
||||
update() {
|
||||
// Create new nodes based on energy
|
||||
if (this.nodes.length < this.maxNodes && this.energy > this.maxEnergy * 0.8) {
|
||||
this.nodes.push(new NetworkNode(
|
||||
Math.random() * canvas.width,
|
||||
Math.random() * canvas.height
|
||||
));
|
||||
this.energy = 0;
|
||||
}
|
||||
|
||||
// Update all nodes
|
||||
for (const node of this.nodes) {
|
||||
node.update();
|
||||
}
|
||||
|
||||
// Update connections based on complexity and connectedness
|
||||
for (let i = 0; i < this.nodes.length; i++) {
|
||||
for (let j = i + 1; j < this.nodes.length; j++) {
|
||||
const a = this.nodes[i];
|
||||
const b = this.nodes[j];
|
||||
|
||||
const dist = Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
|
||||
const maxDist = 200 - params.complexity * 150;
|
||||
if (dist < maxDist) {
|
||||
const strength = (1 - dist / maxDist) * params.connectedness;
|
||||
if (Math.random() < 0.01 * params.complexity * strength) {
|
||||
a.connections.push({ node: b, strength });
|
||||
b.connections.push({ node: a, strength });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate energy based on network activity
|
||||
this.energy = this.nodes.reduce((sum, node) =>
|
||||
sum + node.connections.length * node.size, 0) / 10;
|
||||
}
|
||||
|
||||
draw() {
|
||||
// Draw faint connections first
|
||||
ctx.globalAlpha = 0.3;
|
||||
for (const node of this.nodes) {
|
||||
for (const conn of node.connections) {
|
||||
if (conn.node.life > conn.node.maxLife * 0.5) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(node.x, node.y);
|
||||
ctx.lineTo(conn.node.x, conn.node.y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
// Draw nodes
|
||||
for (const node of this.nodes) {
|
||||
node.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const graph = new NetworkGraph();
|
||||
let lastTime = 0;
|
||||
|
||||
function animate(time) {
|
||||
const deltaTime = time - lastTime;
|
||||
lastTime = time;
|
||||
|
||||
// Clear with fade effect
|
||||
ctx.fillStyle = 'rgba(10, 10, 26, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Update and draw
|
||||
graph.update();
|
||||
graph.draw();
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue