173 lines
No EOL
5.2 KiB
HTML
173 lines
No EOL
5.2 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 Generative Art</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background-color: #0a0a0a;
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
color: #ffffff;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
}
|
|
#attribution {
|
|
position: fixed;
|
|
bottom: 20px;
|
|
right: 20px;
|
|
font-size: 10px;
|
|
color: #333333;
|
|
text-shadow: 0 0 5px rgba(255,255,255,0.3);
|
|
}
|
|
</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');
|
|
|
|
// Set canvas to full window size
|
|
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.11, min: 0.95, max: 1.30 },
|
|
tone: { anger: 0.00, sadness: 0.00, curiosity: 0.10, dryness: 0.90, playfulness: 0.00, tension: 0.00 }
|
|
};
|
|
|
|
// Voronoi system
|
|
const points = [];
|
|
const cells = [];
|
|
const DISTANCE_THRESHOLD = 50;
|
|
const MAX_POINTS = 1000;
|
|
|
|
// Initialize points
|
|
function initPoints() {
|
|
points.length = 0;
|
|
for (let i = 0; i < MAX_POINTS * params.density; i++) {
|
|
points.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
vx: (Math.random() - 0.5) * params.motion * 2,
|
|
vy: (Math.random() - 0.5) * params.motion * 2,
|
|
size: Math.random() * 5 + 1,
|
|
opacity: Math.random() * 0.5 + 0.5
|
|
});
|
|
}
|
|
}
|
|
|
|
// Update points with motion
|
|
function updatePoints() {
|
|
points.forEach(p => {
|
|
p.x += p.vx;
|
|
p.y += p.vy;
|
|
|
|
// Bounce at edges
|
|
if (p.x < 0 || p.x > canvas.width) p.vx *= -1;
|
|
if (p.y < 0 || p.y > canvas.height) p.vy *= -1;
|
|
});
|
|
}
|
|
|
|
// Build Voronoi cells
|
|
function buildVoronoi() {
|
|
cells.length = 0;
|
|
|
|
for (let i = 0; i < points.length; i++) {
|
|
const cell = {
|
|
point: points[i],
|
|
neighbors: [],
|
|
edges: []
|
|
};
|
|
|
|
// Find neighbors within distance threshold
|
|
for (let j = 0; j < points.length; j++) {
|
|
if (i !== j) {
|
|
const dx = points[j].x - points[i].x;
|
|
const dy = points[j].y - points[i].y;
|
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
if (dist < DISTANCE_THRESHOLD) {
|
|
cell.neighbors.push(points[j]);
|
|
}
|
|
}
|
|
}
|
|
|
|
cells.push(cell);
|
|
}
|
|
}
|
|
|
|
// Draw Voronoi cells
|
|
function drawVoronoi() {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
ctx.globalAlpha = 0.8;
|
|
|
|
cells.forEach(cell => {
|
|
if (cell.neighbors.length > 0) {
|
|
// Draw cell outline
|
|
ctx.strokeStyle = `rgba(255, 255, 255, ${cell.point.opacity * 0.3})`;
|
|
ctx.lineWidth = 1;
|
|
|
|
cell.neighbors.forEach(neighbor => {
|
|
ctx.beginPath();
|
|
ctx.moveTo(cell.point.x, cell.point.y);
|
|
ctx.lineTo(neighbor.x, neighbor.y);
|
|
ctx.stroke();
|
|
});
|
|
|
|
// Draw points
|
|
ctx.fillStyle = `rgba(255, 255, 255, ${cell.point.opacity})`;
|
|
ctx.beginPath();
|
|
ctx.arc(cell.point.x, cell.point.y, cell.point.size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
}
|
|
});
|
|
}
|
|
|
|
// Animation loop
|
|
let lastTime = 0;
|
|
function animate(time) {
|
|
const deltaTime = (time - lastTime) / 1000;
|
|
lastTime = time;
|
|
|
|
// Pulse adaptation
|
|
const pulseFactor = params.pulse.avg + Math.sin(time * 0.001) * 0.1;
|
|
|
|
// Update points
|
|
updatePoints();
|
|
|
|
// Occasionally rebuild Voronoi
|
|
if (Math.random() < 0.02 * pulseFactor) {
|
|
buildVoronoi();
|
|
}
|
|
|
|
// Draw
|
|
drawVoronoi();
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Initialize and start
|
|
initPoints();
|
|
buildVoronoi();
|
|
requestAnimationFrame(animate);
|
|
</script>
|
|
</body>
|
|
</html> |