birth: Fractal Web Unfolds
This commit is contained in:
parent
f2bb694779
commit
1905989e6e
1 changed files with 226 additions and 0 deletions
226
index.html
Normal file
226
index.html
Normal file
|
|
@ -0,0 +1,226 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Fractal Web</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#info {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 20px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
text-shadow: 0 0 10px rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas"></canvas>
|
||||||
|
<div id="info">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();
|
||||||
|
|
||||||
|
// Parameters derived from the prompt
|
||||||
|
const params = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.06, min: 0.90, max: 1.20 },
|
||||||
|
tone: { dryness: 0.80, curiosity: 0.10 }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Node and edge classes
|
||||||
|
class Node {
|
||||||
|
constructor(x, y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.vx = (Math.random() - 0.5) * 0.5;
|
||||||
|
this.vy = (Math.random() - 0.5) * 0.5;
|
||||||
|
this.radius = 1.5 + Math.random() * 2;
|
||||||
|
this.life = 0;
|
||||||
|
this.maxLife = 100 + Math.random() * 100;
|
||||||
|
this.targets = new Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.life++;
|
||||||
|
if (this.life > this.maxLife) return false;
|
||||||
|
|
||||||
|
// Pulse influence
|
||||||
|
const pulse = params.pulse.avg + (Math.random() * (params.pulse.max - params.pulse.min) - (params.pulse.max - params.pulse.min)/2);
|
||||||
|
this.vx += (Math.random() - 0.5) * params.motion * 0.1 * pulse;
|
||||||
|
this.vy += (Math.random() - 0.5) * params.motion * 0.1 * pulse;
|
||||||
|
|
||||||
|
// Boundary check
|
||||||
|
const margin = 100;
|
||||||
|
if (this.x < margin || this.x > canvas.width - margin ||
|
||||||
|
this.y < margin || this.y > canvas.height - margin) {
|
||||||
|
this.vx = -this.vx * 0.5;
|
||||||
|
this.vy = -this.vy * 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.x += this.vx;
|
||||||
|
this.y += this.vy;
|
||||||
|
|
||||||
|
this.radius = 1.5 + Math.sin(this.life * 0.1) * 0.5;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = `rgba(200, 210, 220, ${0.7 + Math.sin(this.life * 0.05) * 0.3})`;
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Edge {
|
||||||
|
constructor(a, b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.life = 0;
|
||||||
|
this.maxLife = 50 + Math.random() * 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.life++;
|
||||||
|
return this.life < this.maxLife;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
const dist = Math.sqrt((this.a.x - this.b.x) ** 2 + (this.a.y - this.b.y) ** 2);
|
||||||
|
const opacity = 0.3 * (1 - this.life / this.maxLife) * (1 + Math.sin(this.life * 0.2) * 0.5);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.a.x, this.a.y);
|
||||||
|
ctx.lineTo(this.b.x, this.b.y);
|
||||||
|
ctx.strokeStyle = `rgba(200, 210, 220, ${opacity})`;
|
||||||
|
ctx.lineWidth = 0.5 * (1 - this.life / this.maxLife);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Network graph
|
||||||
|
const nodes = [];
|
||||||
|
const edges = [];
|
||||||
|
|
||||||
|
function initNodes() {
|
||||||
|
const count = 50 + Math.floor(params.density * 150);
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
nodes.push(new Node(
|
||||||
|
Math.random() * canvas.width,
|
||||||
|
Math.random() * canvas.height
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createConnections() {
|
||||||
|
const maxDist = 200 * (0.5 + params.connectedness * 0.5);
|
||||||
|
const targetEdges = 3 + Math.floor(params.connectedness * 5);
|
||||||
|
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
nodes[i].targets.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
const closest = [];
|
||||||
|
for (let j = 0; j < nodes.length; j++) {
|
||||||
|
if (i !== j) {
|
||||||
|
const dist = Math.sqrt((nodes[i].x - nodes[j].x) ** 2 + (nodes[i].y - nodes[j].y) ** 2);
|
||||||
|
if (dist < maxDist) {
|
||||||
|
closest.push({ node: nodes[j], dist });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closest.sort((a, b) => a.dist - b.dist);
|
||||||
|
const connections = Math.min(targetEdges, closest.length);
|
||||||
|
for (let c = 0; c < connections; c++) {
|
||||||
|
nodes[i].targets.add(closest[c].node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
edges.length = 0;
|
||||||
|
for (const node of nodes) {
|
||||||
|
for (const target of node.targets) {
|
||||||
|
if (edges.length >= 200) break;
|
||||||
|
edges.push(new Edge(node, target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Update nodes
|
||||||
|
const activeNodes = [];
|
||||||
|
for (let i = nodes.length - 1; i >= 0; i--) {
|
||||||
|
if (nodes[i].update()) {
|
||||||
|
activeNodes.push(nodes[i]);
|
||||||
|
} else {
|
||||||
|
nodes.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle empty nodes array
|
||||||
|
if (nodes.length === 0) {
|
||||||
|
initNodes();
|
||||||
|
createConnections();
|
||||||
|
for (const node of nodes) {
|
||||||
|
activeNodes.push(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update edges
|
||||||
|
for (let i = edges.length - 1; i >= 0; i--) {
|
||||||
|
if (!edges[i].update()) {
|
||||||
|
edges.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new connections occasionally
|
||||||
|
if (Math.random() < 0.01) {
|
||||||
|
createConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw edges first (behind nodes)
|
||||||
|
for (const edge of edges) {
|
||||||
|
edge.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw nodes
|
||||||
|
for (const node of activeNodes) {
|
||||||
|
node.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
initNodes();
|
||||||
|
createConnections();
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue