birth: Luminous Neural Tides
This commit is contained in:
parent
58fa87c331
commit
e39a74b0db
1 changed files with 322 additions and 0 deletions
322
index.html
Normal file
322
index.html
Normal file
|
|
@ -0,0 +1,322 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Sketch</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
#canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: rgba(255, 255, 255, 0.3);
|
||||
font-size: 10px;
|
||||
text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
</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 adjusted to morphological values
|
||||
const params = {
|
||||
nodeCount: 97,
|
||||
branchCount: 84,
|
||||
loopCount: 537,
|
||||
maxDepth: 23,
|
||||
thicknessRatio: 1.25,
|
||||
fractalDim: 1.792,
|
||||
pulse: {
|
||||
avg: 0.54,
|
||||
min: 0.30,
|
||||
max: 1.80
|
||||
},
|
||||
color: {
|
||||
primary: 'rgba(150, 255, 230, 0.7)',
|
||||
secondary: 'rgba(100, 200, 255, 0.4)',
|
||||
tertiary: 'rgba(200, 255, 255, 0.2)'
|
||||
},
|
||||
motion: 0.532,
|
||||
density: 0.479,
|
||||
complexity: 0.530,
|
||||
connectedness: 0.526,
|
||||
lifespan: 0.495,
|
||||
energy: 483.0 / 1000,
|
||||
dryness: 0.90
|
||||
};
|
||||
|
||||
// Network graph node and edge structures
|
||||
class Node {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.vx = 0;
|
||||
this.vy = 0;
|
||||
this.radius = 0.5 + Math.random() * 1.5;
|
||||
this.connections = [];
|
||||
this.lifetime = 0;
|
||||
this.maxConnections = Math.floor(3 + Math.random() * 5);
|
||||
this.energy = 0;
|
||||
}
|
||||
|
||||
addConnection(node) {
|
||||
if (this.connections.length < this.maxConnections) {
|
||||
this.connections.push(node);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
update(activeNodes) {
|
||||
this.lifetime++;
|
||||
|
||||
// Subtle movement based on density
|
||||
if (params.motion > 0.5 && Math.random() < params.motion * 0.01) {
|
||||
this.vx += (Math.random() - 0.5) * params.motion;
|
||||
this.vy += (Math.random() - 0.5) * params.motion;
|
||||
}
|
||||
|
||||
// Natural decay of velocity
|
||||
this.vx *= 0.9;
|
||||
this.vy *= 0.9;
|
||||
|
||||
// Update position with boundary check
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
const margin = 50;
|
||||
if (this.x < -margin) this.x = canvas.width + margin;
|
||||
if (this.x > canvas.width + margin) this.x = -margin;
|
||||
if (this.y < -margin) this.y = canvas.height + margin;
|
||||
if (y > canvas.height + margin) this.y = -margin;
|
||||
|
||||
// Update energy based on connections
|
||||
this.energy = this.connections.length * 10;
|
||||
}
|
||||
|
||||
draw(ctx, pulseScale) {
|
||||
const baseAlpha = params.dryness > 0.8 ? 0.6 : 0.8;
|
||||
const size = this.radius * (0.8 + 0.4 * pulseScale);
|
||||
const glow = Math.sin(Date.now() * 0.001 + this.lifetime * 0.01) * 20 + 20;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, size, 0, Math.PI * 2);
|
||||
ctx.fillStyle = `rgba(150, 220, 240, ${baseAlpha * (0.5 + 0.5 * pulseScale)})`;
|
||||
ctx.shadowBlur = glow * pulseScale;
|
||||
ctx.shadowColor = `rgba(150, 220, 240, ${0.3 * pulseScale})`;
|
||||
ctx.fill();
|
||||
ctx.shadowBlur = 0;
|
||||
|
||||
// Draw only the most recent connections
|
||||
const recentConnections = this.connections.slice(-2);
|
||||
recentConnections.forEach(conn => {
|
||||
const dist = Math.sqrt((this.x - conn.x) ** 2 + (this.y - conn.y) ** 2);
|
||||
const thickness = Math.min(1.5, params.thicknessRatio * (0.5 + 0.5 * pulseScale));
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.x, this.y);
|
||||
ctx.lineTo(conn.x, conn.y);
|
||||
ctx.strokeStyle = params.color.secondary;
|
||||
ctx.lineWidth = thickness * (0.7 + 0.3 * pulseScale);
|
||||
ctx.globalAlpha = baseAlpha * 0.4;
|
||||
ctx.stroke();
|
||||
});
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Network graph system
|
||||
class NetworkGraph {
|
||||
constructor() {
|
||||
this.nodes = [];
|
||||
this.edges = [];
|
||||
this.nodeEnergy = [];
|
||||
this.time = 0;
|
||||
this.pulseTimer = 0;
|
||||
this.pulseScale = 1;
|
||||
|
||||
this.initializeNodes();
|
||||
this.createConnections();
|
||||
}
|
||||
|
||||
initializeNodes() {
|
||||
const area = canvas.width * canvas.height;
|
||||
const targetDensity = params.density * 0.00002;
|
||||
const nodeCount = Math.floor(params.nodeCount * 0.8 + Math.random() * params.nodeCount * 0.4);
|
||||
|
||||
// Distribute nodes more evenly when density is high
|
||||
const spacing = Math.sqrt(area / nodeCount) * (1 - params.density * 0.8);
|
||||
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
let x, y, validPos = false;
|
||||
let attempts = 0;
|
||||
|
||||
// Try to find a non-overlapping position
|
||||
while (!validPos && attempts < 100) {
|
||||
x = Math.random() * canvas.width;
|
||||
y = Math.random() * canvas.height;
|
||||
validPos = true;
|
||||
|
||||
// Check proximity to existing nodes
|
||||
for (let j = 0; j < this.nodes.length; j++) {
|
||||
const dist = Math.sqrt((x - this.nodes[j].x) ** 2 + (y - this.nodes[j].y) ** 2);
|
||||
if (dist < spacing * 0.6) {
|
||||
validPos = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
attempts++;
|
||||
}
|
||||
|
||||
this.nodes.push(new Node(x || Math.random() * canvas.width,
|
||||
y || Math.random() * canvas.height));
|
||||
}
|
||||
}
|
||||
|
||||
createConnections() {
|
||||
const complexConnections = Math.floor(params.connectedness * params.branchCount * 1.5);
|
||||
|
||||
// Create a base tree-like structure
|
||||
const root = this.nodes[Math.floor(Math.random() * this.nodes.length)];
|
||||
const queue = [root];
|
||||
const visited = new Set([root]);
|
||||
|
||||
while (queue.length > 0 && visited.size < this.nodes.length) {
|
||||
const current = queue.shift();
|
||||
|
||||
// Find nearest unvisited nodes
|
||||
const otherNodes = this.nodes.filter(n => !visited.has(n));
|
||||
otherNodes.sort((a, b) => {
|
||||
const distA = Math.sqrt((a.x - current.x) ** 2 + (a.y - current.y) ** 2);
|
||||
const distB = Math.sqrt((b.x - current.x) ** 2 + (b.y - current.y) ** 2);
|
||||
return distA - distB;
|
||||
});
|
||||
|
||||
const connectionTarget = otherNodes[0];
|
||||
if (connectionTarget && current.addConnection(connectionTarget)) {
|
||||
visited.add(connectionTarget);
|
||||
queue.push(connectionTarget);
|
||||
}
|
||||
|
||||
// Occasionally create long-range connections
|
||||
if (Math.random() < params.complexity * 0.1 && otherNodes.length > 5) {
|
||||
const longRange = otherNodes[Math.floor(Math.random() * Math.min(10, otherNodes.length))];
|
||||
if (current.addConnection(longRange)) {
|
||||
visited.add(longRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add random loops
|
||||
for (let i = 0; i < params.loopCount * 0.8; i++) {
|
||||
const nodeA = this.nodes[Math.floor(Math.random() * this.nodes.length)];
|
||||
const nodeB = this.nodes[Math.floor(Math.random() * this.nodes.length)];
|
||||
|
||||
if (nodeA !== nodeB && !nodeA.connections.includes(nodeB) && nodeA.addConnection(nodeB)) {
|
||||
nodeB.addConnection(nodeA); // Make it a proper loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update() {
|
||||
this.time++;
|
||||
|
||||
// Pulse effect
|
||||
this.pulseTimer += 0.01;
|
||||
const pulseProgress = (Math.sin(this.pulseTimer) + 1) * 0.5;
|
||||
this.pulseScale = params.pulse.min +
|
||||
pulseProgress * (params.pulse.max - params.pulse.min);
|
||||
|
||||
// Update nodes
|
||||
this.nodes.forEach(node => node.update(this.nodes));
|
||||
|
||||
// Occasionally add new nodes to maintain density
|
||||
if (this.time % 100 === 0 && this.nodes.length < params.nodeCount * 1.5) {
|
||||
if (Math.random() < params.density * 0.2) {
|
||||
this.nodes.push(new Node(
|
||||
Math.random() * canvas.width,
|
||||
Math.random() * canvas.height
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Occasionally create new connections
|
||||
if (this.time % 150 === 0 && Math.random() < params.connectedness * 0.3) {
|
||||
const nodeA = this.nodes[Math.floor(Math.random() * this.nodes.length)];
|
||||
const nodeB = this.nodes[Math.floor(Math.random() * this.nodes.length)];
|
||||
|
||||
if (nodeA !== nodeB && !nodeA.connections.includes(nodeB)) {
|
||||
nodeA.addConnection(nodeB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
draw() {
|
||||
// Clear with strong alpha for trails
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Sort nodes by energy for drawing order
|
||||
const sortedNodes = [...this.nodes].sort((a, b) => b.energy - a.energy);
|
||||
|
||||
// Draw connections with varying opacity
|
||||
ctx.globalAlpha = params.dryness > 0.8 ? 0.3 : 0.5;
|
||||
|
||||
sortedNodes.forEach(node => {
|
||||
node.connections.forEach(conn => {
|
||||
const alpha = 0.3 + (conn.energy > 50 ? 0.2 : 0);
|
||||
const dist = Math.sqrt((node.x - conn.x) ** 2 + (node.y - conn.y) ** 2);
|
||||
const thickness = params.thicknessRatio * (0.4 + 0.6 * (1 - dist / Math.max(canvas.width, canvas.height)));
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(node.x, node.y);
|
||||
ctx.lineTo(conn.x, conn.y);
|
||||
ctx.strokeStyle = `rgba(120, 220, 255, ${alpha * this.pulseScale})`;
|
||||
ctx.lineWidth = thickness;
|
||||
ctx.stroke();
|
||||
});
|
||||
});
|
||||
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
// Draw nodes
|
||||
sortedNodes.forEach(node => {
|
||||
node.draw(ctx, this.pulseScale);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let networkGraph = new NetworkGraph();
|
||||
|
||||
function animate() {
|
||||
networkGraph.update();
|
||||
networkGraph.draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue