196 lines
No EOL
6.9 KiB
HTML
196 lines
No EOL
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Neurameba Cellular Voronoi</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
#info {
|
|
position: absolute;
|
|
bottom: 20px;
|
|
left: 0;
|
|
right: 0;
|
|
color: #666;
|
|
font-size: 10px;
|
|
text-align: center;
|
|
pointer-events: none;
|
|
}
|
|
</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 resizeCanvas() {
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
}
|
|
window.addEventListener('resize', resizeCanvas);
|
|
resizeCanvas();
|
|
|
|
// Voronoi parameters derived from abstract parameters
|
|
const params = {
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
motion: 0.5,
|
|
lifespan: 0.5,
|
|
tone: { dryness: 0.8, playfulness: 0.1, curiosity: 0.3 }
|
|
};
|
|
|
|
// Generate Voronoi cells with dynamic properties
|
|
function generateCells() {
|
|
const cellCount = 200 + Math.floor(params.density * 300);
|
|
const cells = [];
|
|
|
|
for (let i = 0; i < cellCount; i++) {
|
|
cells.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
vx: (Math.random() - 0.5) * 2 * params.motion,
|
|
vy: (Math.random() - 0.5) * 2 * params.motion,
|
|
life: params.lifespan * 100 + Math.random() * 100,
|
|
color: getCellColor(),
|
|
size: 2 + Math.random() * 6 * params.complexity,
|
|
neighborConnections: [],
|
|
edgeAlpha: 0.3 + Math.random() * 0.7 * (1 - params.connectedness)
|
|
});
|
|
}
|
|
|
|
// Find neighboring cells (for connections)
|
|
for (let i = 0; i < cells.length; i++) {
|
|
const cell = cells[i];
|
|
const maxDist = 100 + 150 * params.connectedness;
|
|
|
|
for (let j = i + 1; j < cells.length; j++) {
|
|
const other = cells[j];
|
|
const dx = other.x - cell.x;
|
|
const dy = other.y - cell.y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
if (dist < maxDist) {
|
|
cell.neighborConnections.push({
|
|
to: j,
|
|
distance: dist,
|
|
strength: 1 - params.motion + Math.random() * params.motion * 2
|
|
});
|
|
if (params.connectedness > 0.7) {
|
|
other.neighborConnections.push({
|
|
to: i,
|
|
distance: dist,
|
|
strength: 1 - params.motion + Math.random() * params.motion * 2
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return cells;
|
|
}
|
|
|
|
function getCellColor() {
|
|
const hue = 180 + Math.random() * 30; // Teals for curiosity
|
|
const saturation = 30 + Math.random() * 20 * (1 - params.tone.dryness);
|
|
const lightness = 60 + Math.random() * 10;
|
|
const alpha = 0.7 + Math.random() * 0.3;
|
|
|
|
return `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
|
|
}
|
|
|
|
let cells = generateCells();
|
|
|
|
function updateCells() {
|
|
cells.forEach(cell => {
|
|
// Move cells
|
|
cell.x += cell.vx;
|
|
cell.y += cell.vy;
|
|
|
|
// Boundary collision
|
|
if (cell.x < 0 || cell.x > canvas.width) cell.vx *= -1;
|
|
if (cell.y < 0 || cell.y > canvas.height) cell.vy *= -1;
|
|
|
|
// Age cells
|
|
cell.life -= 0.5 + Math.random() * 0.5;
|
|
|
|
// Occasionally add new cells
|
|
if (Math.random() < 0.02 * (1 - params.lifespan)) {
|
|
cells.push({
|
|
x: cell.x + (Math.random() - 0.5) * 50,
|
|
y: cell.y + (Math.random() - 0.5) * 50,
|
|
vx: (Math.random() - 0.5) * 2 * params.motion,
|
|
vy: (Math.random() - 0.5) * 2 * params.motion,
|
|
life: params.lifespan * 100,
|
|
color: getCellColor(),
|
|
size: 2 + Math.random() * 6 * params.complexity,
|
|
neighborConnections: [],
|
|
edgeAlpha: 0.3 + Math.random() * 0.7 * (1 - params.connectedness)
|
|
});
|
|
}
|
|
});
|
|
|
|
// Remove dead cells
|
|
cells = cells.filter(cell => cell.life > 0);
|
|
}
|
|
|
|
function drawCells() {
|
|
// Clear with slight fade for trail effect
|
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Draw connections between cells
|
|
if (params.connectedness > 0.3) {
|
|
cells.forEach(cell => {
|
|
cell.neighborConnections.forEach(conn => {
|
|
const other = cells[conn.to];
|
|
if (other && other.life > 0) {
|
|
const strength = conn.strength * (1 - params.tone.dryness);
|
|
ctx.strokeStyle = `rgba(200, 230, 255, ${strength * cell.edgeAlpha * 0.5})`;
|
|
ctx.lineWidth = 0.5 + strength * 2;
|
|
|
|
ctx.beginPath();
|
|
ctx.moveTo(cell.x, cell.y);
|
|
ctx.lineTo(other.x, other.y);
|
|
ctx.stroke();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// Draw cells
|
|
cells.forEach(cell => {
|
|
// Pulse effect
|
|
const pulse = 1 + Math.sin(Date.now() * 0.005) * 0.1;
|
|
const size = cell.size * pulse;
|
|
|
|
// Age affects opacity
|
|
const opacity = Math.min(1, cell.life / 50) * (1 - params.tone.dryness) * 0.9;
|
|
|
|
ctx.fillStyle = cell.color.replace(')', `, ${opacity})`);
|
|
ctx.beginPath();
|
|
ctx.arc(cell.x, cell.y, size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
});
|
|
}
|
|
|
|
function animate() {
|
|
updateCells();
|
|
drawCells();
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |