167 lines
No EOL
5.6 KiB
HTML
167 lines
No EOL
5.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Tessellated Pulse</title>
|
|
<style>
|
|
body { margin: 0; overflow: hidden; background: #0a0a0a; }
|
|
canvas { display: block; }
|
|
#attribution { position: fixed; bottom: 10px; right: 10px; color: #555; font-family: monospace; font-size: 10px; }
|
|
</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
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.08, min: 1.05, max: 1.10 },
|
|
tone: { dryness: 0.9, curiosity: 0.1 },
|
|
topology: {
|
|
survivingNodes: 0,
|
|
branchCount: 0,
|
|
loops: 0,
|
|
maxDepth: 0,
|
|
thicknessRatio: 0.0,
|
|
fractalDimension: 0.0,
|
|
finalEnergy: 0.0
|
|
}
|
|
};
|
|
|
|
// State
|
|
const state = {
|
|
time: 0,
|
|
nodes: [],
|
|
connections: [],
|
|
densityFactor: Math.pow(10, params.density * 3 - 1.5)
|
|
};
|
|
|
|
// Hex grid setup
|
|
const cellSize = 50;
|
|
const cols = Math.ceil(canvas.width / cellSize) + 1;
|
|
const rows = Math.ceil(canvas.height / cellSize) + 1;
|
|
|
|
// Initialize nodes
|
|
function initNodes() {
|
|
state.nodes = [];
|
|
for (let y = 0; y < rows; y++) {
|
|
for (let x = 0; x < cols; x++) {
|
|
if (Math.random() < params.density) {
|
|
state.nodes.push({
|
|
x: x * cellSize + cellSize/2,
|
|
y: y * cellSize + cellSize/2,
|
|
baseX: x * cellSize + cellSize/2,
|
|
baseY: y * cellSize + cellSize/2,
|
|
size: 2 + Math.random() * 3,
|
|
pulse: 1,
|
|
angle: Math.random() * Math.PI * 2,
|
|
speed: 0.01 + Math.random() * 0.05,
|
|
life: params.lifespan,
|
|
color: `hsl(${Math.random() * 360}, 100%, 80%)`
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Connect nodes
|
|
function createConnections() {
|
|
state.connections = [];
|
|
const minDist = 50 * params.connectedness;
|
|
const maxDist = 200 * params.connectedness;
|
|
|
|
for (let i = 0; i < state.nodes.length; i++) {
|
|
const node = state.nodes[i];
|
|
for (let j = i + 1; j < state.nodes.length; j++) {
|
|
const other = state.nodes[j];
|
|
const dist = Math.hypot(node.x - other.x, node.y - other.y);
|
|
|
|
if (dist < maxDist && dist > minDist * 0.7) {
|
|
state.connections.push({
|
|
a: i,
|
|
b: j,
|
|
strength: 1 - (dist - minDist) / (maxDist - minDist),
|
|
color: `rgba(255, 255, 255, ${0.3 + 0.7 * (1 - dist/maxDist)})`
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update nodes
|
|
function updateNodes() {
|
|
state.time += 0.01 * params.motion;
|
|
|
|
state.nodes.forEach(node => {
|
|
// Pulsing motion
|
|
const pulseScale = params.pulse.avg + (params.pulse.max - params.pulse.min) * 0.5 * Math.sin(state.time * node.speed * 10);
|
|
node.pulse = pulseScale;
|
|
|
|
// Gentle movement
|
|
node.angle += 0.01 * params.motion;
|
|
node.x = node.baseX + Math.cos(node.angle) * 5 * params.motion;
|
|
node.y = node.baseY + Math.sin(node.angle) * 5 * params.motion;
|
|
});
|
|
}
|
|
|
|
// Draw
|
|
function draw() {
|
|
// Clear with dark background
|
|
ctx.fillStyle = '#0a0a0a';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Draw connections
|
|
ctx.lineWidth = 0.5 + params.connectedness * 2;
|
|
state.connections.forEach(conn => {
|
|
const a = state.nodes[conn.a];
|
|
const b = state.nodes[conn.b];
|
|
ctx.strokeStyle = conn.color;
|
|
ctx.beginPath();
|
|
ctx.moveTo(a.x, a.y);
|
|
ctx.lineTo(b.x, b.y);
|
|
ctx.stroke();
|
|
});
|
|
|
|
// Draw nodes
|
|
state.nodes.forEach(node => {
|
|
const size = node.size * node.pulse;
|
|
const alpha = 0.7 + 0.3 * (node.life - params.lifespan);
|
|
|
|
// Use dryness/monochrome palette
|
|
ctx.fillStyle = `rgba(200, 200, 200, ${alpha})`;
|
|
ctx.beginPath();
|
|
ctx.arc(node.x, node.y, size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
});
|
|
}
|
|
|
|
// Animation loop
|
|
function animate() {
|
|
updateNodes();
|
|
draw();
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Initialize and start
|
|
initNodes();
|
|
createConnections();
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |