birth: Veins of Static Light
This commit is contained in:
parent
67368f2655
commit
3486f195c0
1 changed files with 204 additions and 0 deletions
204
index.html
Normal file
204
index.html
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba · Generative Network</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a1a;
|
||||||
|
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;
|
||||||
|
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 resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Parameters derived from abstract inputs
|
||||||
|
const params = {
|
||||||
|
nodes: 80 + Math.floor(100 * 0.5), // Density 0.5 → ~130 nodes
|
||||||
|
connections: 150 + Math.floor(300 * 0.5), // Connectedness 0.5 → ~300 connections
|
||||||
|
complexity: 0.5,
|
||||||
|
motion: 0.5,
|
||||||
|
pulse: { avg: 1.05, min: 1.00, max: 1.10 },
|
||||||
|
tone: { dryness: 0.9, curiosity: 0.1 }
|
||||||
|
};
|
||||||
|
|
||||||
|
class Node {
|
||||||
|
constructor() {
|
||||||
|
this.x = Math.random() * canvas.width;
|
||||||
|
this.y = Math.random() * canvas.height;
|
||||||
|
this.vx = (Math.random() - 0.5) * 2 * params.motion;
|
||||||
|
this.vy = (Math.random() - 0.5) * 2 * params.motion;
|
||||||
|
this.size = 1 + Math.random() * 3 * params.complexity;
|
||||||
|
this.pulse = 1.0;
|
||||||
|
this.targetPulse = params.pulse.avg + (Math.random() - 0.5) * (params.pulse.max - params.pulse.min);
|
||||||
|
this.maxConnections = 3 + Math.floor(7 * params.connectedness);
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
// Movement with slight randomness
|
||||||
|
this.x += this.vx;
|
||||||
|
this.y += this.vy;
|
||||||
|
|
||||||
|
// Bounce off edges
|
||||||
|
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
|
||||||
|
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
|
||||||
|
|
||||||
|
// Pulse
|
||||||
|
this.pulse += (this.targetPulse - this.pulse) * 0.05;
|
||||||
|
this.targetPulse = params.pulse.avg + (Math.random() - 0.5) * (params.pulse.max - params.pulse.min);
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.size * this.pulse, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `rgba(255, 255, 255, ${0.5 + 0.5 * params.tone.dryness})`;
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Connection {
|
||||||
|
constructor(a, b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.strength = 0.3 + Math.random() * 0.7 * params.connectedness;
|
||||||
|
this.age = 0;
|
||||||
|
this.maxAge = 100 + Math.floor(200 * params.lifespan);
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.age++;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.a.x, this.a.y);
|
||||||
|
ctx.lineTo(this.b.x, this.b.y);
|
||||||
|
ctx.strokeStyle = `rgba(70, 130, 180, ${this.strength * (1 - this.age / this.maxAge)})`;
|
||||||
|
ctx.lineWidth = 0.5 + this.strength * 2;
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
// Draw arrowhead if connection is strong
|
||||||
|
if (this.strength > 0.7) {
|
||||||
|
const angle = Math.atan2(this.b.y - this.a.y, this.b.x - this.a.x);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.b.x - 10 * Math.cos(angle - Math.PI/6), this.b.y - 10 * Math.sin(angle - Math.PI/6));
|
||||||
|
ctx.lineTo(this.b.x, this.b.y);
|
||||||
|
ctx.lineTo(this.b.x - 10 * Math.cos(angle + Math.PI/6), this.b.y - 10 * Math.sin(angle + Math.PI/6));
|
||||||
|
ctx.strokeStyle = `rgba(70, 130, 180, ${this.strength * (1 - this.age / this.maxAge)})`;
|
||||||
|
ctx.lineWidth = 0.5 + this.strength * 2;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const nodes = [];
|
||||||
|
const connections = [];
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
// Create nodes
|
||||||
|
for (let i = 0; i < params.nodes; i++) {
|
||||||
|
nodes.push(new Node());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create connections
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
for (let j = i + 1; j < Math.min(i + 4, nodes.length); j++) {
|
||||||
|
const distance = Math.hypot(nodes[i].x - nodes[j].x, nodes[i].y - nodes[j].y);
|
||||||
|
if (distance < 300) {
|
||||||
|
connections.push(new Connection(nodes[i], nodes[j]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit total connections
|
||||||
|
if (connections.length > params.connections) {
|
||||||
|
connections.length = params.connections;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
// Update nodes
|
||||||
|
nodes.forEach(node => node.update());
|
||||||
|
|
||||||
|
// Update connections
|
||||||
|
connections.forEach(conn => conn.update());
|
||||||
|
|
||||||
|
// Remove old connections
|
||||||
|
for (let i = connections.length - 1; i >= 0; i--) {
|
||||||
|
if (connections[i].age > connections[i].maxAge) {
|
||||||
|
connections.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new connections
|
||||||
|
if (connections.length < params.connections) {
|
||||||
|
const availablePairs = [];
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
for (let j = i + 1; j < nodes.length; j++) {
|
||||||
|
const distance = Math.hypot(nodes[i].x - nodes[j].x, nodes[i].y - nodes[j].y);
|
||||||
|
if (distance < 200) {
|
||||||
|
availablePairs.push({a: i, b: j, distance});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by distance (closer pairs first)
|
||||||
|
availablePairs.sort((a, b) => a.distance - b.distance);
|
||||||
|
|
||||||
|
// Add new connections
|
||||||
|
for (let i = 0; i < Math.min(5, availablePairs.length, params.connections - connections.length); i++) {
|
||||||
|
connections.push(new Connection(nodes[availablePairs[i].a], nodes[availablePairs[i].b]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
// Fade effect
|
||||||
|
ctx.fillStyle = 'rgba(10, 10, 26, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Draw connections first
|
||||||
|
connections.forEach(conn => conn.draw());
|
||||||
|
|
||||||
|
// Draw nodes
|
||||||
|
nodes.forEach(node => node.draw());
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
update();
|
||||||
|
draw();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue