184 lines
No EOL
6.4 KiB
HTML
184 lines
No EOL
6.4 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 · Motd.Social</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
color: #f0f0f0;
|
|
font-family: 'Courier New', monospace;
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100vh;
|
|
}
|
|
canvas {
|
|
flex: 1;
|
|
}
|
|
.attribution {
|
|
text-align: center;
|
|
padding: 10px;
|
|
font-size: 12px;
|
|
opacity: 0.5;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="canvas"></canvas>
|
|
<div class="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 influenced by the generative art builder
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.07, min: 1.0, max: 1.1 },
|
|
tone: { anger: 0.0, sadness: 0.0, curiosity: 0.1, dryness: 0.8, playfulness: 0.0, tension: 0.0 }
|
|
};
|
|
|
|
// Simulation variables
|
|
const particles = [];
|
|
const flowField = {
|
|
gridSize: Math.floor(30 + params.complexity * 30),
|
|
spacing: 30,
|
|
strength: params.motion * 0.02,
|
|
angleVariation: (params.connectedness * Math.PI / 2) + (params.complexity * Math.PI)
|
|
};
|
|
|
|
// Initialize particles based on density
|
|
function initParticles() {
|
|
const count = Math.floor(400 + params.density * 600);
|
|
for (let i = 0; i < count; i++) {
|
|
particles.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
size: 1 + params.density * 2,
|
|
speed: 0.2 + params.motion * 0.8,
|
|
trail: [],
|
|
maxTrailLength: 20 + Math.floor(params.lifespan * 20),
|
|
hue: params.tone.dryness > 0.7 ? 0 : (30 + Math.random() * 30),
|
|
saturation: params.tone.dryness > 0.7 ? 0 : (50 + Math.random() * 40),
|
|
lifetime: params.lifespan * 1000
|
|
});
|
|
}
|
|
}
|
|
|
|
function createFlowField() {
|
|
const { gridSize, spacing, angleVariation } = flowField;
|
|
for (let y = 0; y < gridSize; y++) {
|
|
for (let x = 0; x < gridSize; x++) {
|
|
const angle = (Math.random() * angleVariation) +
|
|
(x / gridSize) * Math.PI * 2 * params.connectedness +
|
|
(y / gridSize) * Math.PI * params.motion;
|
|
const length = spacing * (0.5 + params.motion * 0.5);
|
|
flowField[`${x},${y}`] = {
|
|
x: Math.cos(angle) * length,
|
|
y: Math.sin(angle) * length
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
function updateParticles() {
|
|
particles.forEach((p, i) => {
|
|
// Get flow field vector
|
|
const gridX = Math.floor(p.x / flowField.spacing) % flowField.gridSize;
|
|
const gridY = Math.floor(p.y / flowField.spacing) % flowField.gridSize;
|
|
const vector = flowField[`${gridX},${gridY}`] ||
|
|
{ x: (Math.random() - 0.5) * 2, y: (Math.random() - 0.5) * 2 };
|
|
|
|
// Apply motion
|
|
p.x += vector.x * p.speed * params.pulse.avg;
|
|
p.y += vector.y * p.speed * params.pulse.avg;
|
|
|
|
// Wrap around edges
|
|
if (p.x < 0) p.x = canvas.width;
|
|
if (p.x > canvas.width) p.x = 0;
|
|
if (p.y < 0) p.y = canvas.height;
|
|
if (p.y > canvas.height) p.y = 0;
|
|
|
|
// Update trail
|
|
p.trail.push({ x: p.x, y: p.y });
|
|
if (p.trail.length > p.maxTrailLength) {
|
|
p.trail.shift();
|
|
}
|
|
|
|
// Age particles
|
|
p.lifetime--;
|
|
if (p.lifetime <= 0) {
|
|
particles.splice(i, 1);
|
|
particles.push({
|
|
...p,
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
lifetime: params.lifespan * 1000 + Math.random() * 500
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function draw() {
|
|
// Fade background slightly
|
|
ctx.fillStyle = 'rgba(5, 5, 10, 0.05)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
// Draw particles with trails
|
|
particles.forEach(p => {
|
|
const gradient = ctx.createLinearGradient(
|
|
p.x - 5, p.y - 5,
|
|
p.x + 5, p.y + 5
|
|
);
|
|
gradient.addColorStop(0, `hsla(${p.hue}, ${p.saturation}%, 70%, 0.2)`);
|
|
gradient.addColorStop(1, `hsla(${p.hue}, ${p.saturation}%, 70%, 0)`);
|
|
|
|
ctx.strokeStyle = gradient;
|
|
ctx.lineWidth = p.size;
|
|
|
|
if (p.trail.length > 1) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(p.trail[0].x, p.trail[0].y);
|
|
for (let i = 1; i < p.trail.length; i++) {
|
|
ctx.lineTo(p.trail[i].x, p.trail[i].y);
|
|
}
|
|
ctx.stroke();
|
|
}
|
|
});
|
|
|
|
// Add some central glow based on motion
|
|
if (params.motion > 0.7) {
|
|
ctx.fillStyle = `hsla(210, 30%, 80%, ${(params.motion - 0.7) * 0.3})`;
|
|
ctx.beginPath();
|
|
ctx.arc(canvas.width/2, canvas.height/2, 20 + params.motion * 30, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
}
|
|
}
|
|
|
|
function animate() {
|
|
updateParticles();
|
|
draw();
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
// Initialize and start
|
|
initParticles();
|
|
createFlowField();
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |