birth: Fractured Light Memory
This commit is contained in:
parent
25fd9ea400
commit
d03cd1aac7
1 changed files with 190 additions and 0 deletions
190
index.html
Normal file
190
index.html
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba Network</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
.info {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: #666;
|
||||
font-size: 10px;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div class="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();
|
||||
|
||||
// Network parameters
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.1, min: 1.0, max: 1.2 },
|
||||
tone: { anger: 0, sadness: 0, curiosity: 0.1, dryness: 0.9, playfulness: 0, tension: 0 }
|
||||
};
|
||||
|
||||
// Graph nodes and edges
|
||||
let nodes = [];
|
||||
let edges = [];
|
||||
const maxNodes = 100;
|
||||
const baseSize = 2 + params.density * 4;
|
||||
const maxConnections = 3 + Math.floor(params.connectedness * 5);
|
||||
|
||||
class Node {
|
||||
constructor() {
|
||||
this.x = Math.random() * canvas.width;
|
||||
this.y = Math.random() * canvas.height;
|
||||
this.size = baseSize * (0.5 + Math.random());
|
||||
this.vx = (Math.random() - 0.5) * 2 * params.motion;
|
||||
this.vy = (Math.random() - 0.5) * 2 * params.motion;
|
||||
this.color = `rgba(255, 255, 255, ${0.5 + Math.random() * 0.5})`;
|
||||
this.life = params.lifespan * (0.3 + Math.random() * 0.7);
|
||||
this.maxLife = this.life;
|
||||
this.pulse = 1;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
// Bounce at edges
|
||||
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
|
||||
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
|
||||
|
||||
// Pulse effect
|
||||
const pulseFactor = params.pulse.avg + (Math.random() * (params.pulse.max - params.pulse.min) - (params.pulse.max - params.pulse.min)/2);
|
||||
this.pulse = 1 + (pulseFactor - 1) * 0.2;
|
||||
|
||||
// Lifespan decay
|
||||
this.life -= 0.001;
|
||||
}
|
||||
|
||||
draw() {
|
||||
const age = 1 - (this.life / this.maxLife);
|
||||
const pulseSize = this.size * this.pulse * (0.9 + age * 0.1);
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, pulseSize, 0, Math.PI * 2);
|
||||
ctx.fillStyle = this.color;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
class Edge {
|
||||
constructor(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.age = 0;
|
||||
this.maxAge = 1000 * params.lifespan;
|
||||
this.color = `rgba(255, 255, 255, ${0.2 + Math.random() * 0.3})`;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.age++;
|
||||
}
|
||||
|
||||
draw() {
|
||||
const age = this.age / this.maxAge;
|
||||
const lineWidth = 0.5 + (1 - age) * 1.5;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.a.x, this.a.y);
|
||||
ctx.lineTo(this.b.x, this.b.y);
|
||||
ctx.strokeStyle = this.color;
|
||||
ctx.lineWidth = lineWidth * (0.8 + Math.sin(Date.now() * 0.002) * 0.2);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
function initNetwork() {
|
||||
nodes = [];
|
||||
edges = [];
|
||||
|
||||
// Create nodes
|
||||
const nodeCount = Math.floor(maxNodes * params.density);
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
nodes.push(new Node());
|
||||
}
|
||||
|
||||
// Create connections
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const connections = Math.floor(maxConnections * params.connectedness);
|
||||
for (let j = 0; j < connections; j++) {
|
||||
const target = Math.floor(Math.random() * nodes.length);
|
||||
if (target !== i && !edges.some(e => (e.a === nodes[i] && e.b === nodes[target]) || (e.a === nodes[target] && e.b === nodes[i]))) {
|
||||
edges.push(new Edge(nodes[i], nodes[target]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateNetwork() {
|
||||
// Remove dead nodes
|
||||
nodes = nodes.filter(node => node.life > 0);
|
||||
|
||||
// Remove dead edges
|
||||
edges = edges.filter(edge => edge.age < edge.maxAge);
|
||||
|
||||
// Add new connections dynamically
|
||||
if (edges.length < maxNodes * params.density * 2 && Math.random() < 0.02) {
|
||||
const a = Math.floor(Math.random() * nodes.length);
|
||||
const b = Math.floor(Math.random() * nodes.length);
|
||||
if (a !== b) {
|
||||
edges.push(new Edge(nodes[a], nodes[b]));
|
||||
}
|
||||
}
|
||||
|
||||
// Update nodes and edges
|
||||
nodes.forEach(node => node.update());
|
||||
edges.forEach(edge => edge.update());
|
||||
}
|
||||
|
||||
function drawNetwork() {
|
||||
// Clear with fade effect
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw edges first
|
||||
edges.forEach(edge => edge.draw());
|
||||
|
||||
// Draw nodes
|
||||
nodes.forEach(node => node.draw());
|
||||
}
|
||||
|
||||
function animate() {
|
||||
updateNetwork();
|
||||
drawNetwork();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
initNetwork();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue