167 lines
No EOL
5.5 KiB
HTML
167 lines
No EOL
5.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Curious Particles</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
font-family: 'Courier New', monospace;
|
|
color: #00ffff;
|
|
}
|
|
#attribution {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
left: 0;
|
|
right: 0;
|
|
text-align: center;
|
|
font-size: 10px;
|
|
opacity: 0.5;
|
|
}
|
|
</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();
|
|
|
|
// Particle system parameters
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: {
|
|
avg: 1.07,
|
|
min: 0.9,
|
|
max: 1.2
|
|
},
|
|
tone: {
|
|
anger: 0,
|
|
sadness: 0,
|
|
curiosity: 0.8,
|
|
dryness: 0.9,
|
|
playfulness: 0.1,
|
|
tension: 0
|
|
}
|
|
};
|
|
|
|
// Generate particles based on density
|
|
const particleCount = Math.floor(1000 + params.density * 5000);
|
|
const particles = [];
|
|
const connections = [];
|
|
|
|
// Palette based on tone
|
|
const palette = {
|
|
r: Math.floor(255 * (0.1 + params.tone.curiosity * 0.5)),
|
|
g: Math.floor(255 * (0.2 + params.tone.curiosity * 0.7)),
|
|
b: Math.floor(255 * (0.3 + params.tone.curiosity * 0.9))
|
|
};
|
|
|
|
// Initialize particles
|
|
for (let i = 0; i < particleCount; i++) {
|
|
particles.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,
|
|
size: Math.random() * 2 + 1,
|
|
alpha: Math.random() * 0.8 + 0.2,
|
|
pulse: params.pulse.avg,
|
|
jitter: Math.random() * 0.1,
|
|
age: 0,
|
|
maxAge: 1000 + Math.random() * 2000 * params.lifespan
|
|
});
|
|
}
|
|
|
|
// Create some connections based on connectedness
|
|
const connectionCount = Math.floor(params.connectedness * 500);
|
|
for (let i = 0; i < connectionCount; i++) {
|
|
const a = Math.floor(Math.random() * particles.length);
|
|
const b = Math.floor(Math.random() * particles.length);
|
|
connections.push({
|
|
a, b,
|
|
strength: Math.random() * 0.5 + 0.5
|
|
});
|
|
}
|
|
|
|
function update() {
|
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
const time = Date.now() * 0.001;
|
|
const pulseFactor = params.pulse.avg + Math.sin(time * 2) * (params.pulse.max - params.pulse.min) * 0.5;
|
|
|
|
particles.forEach(p => {
|
|
// Update position with jitter
|
|
p.vx += (Math.random() - 0.5) * p.jitter * params.motion;
|
|
p.vy += (Math.random() - 0.5) * p.jitter * params.motion;
|
|
|
|
// Apply boundary constraints
|
|
if (p.x < 0 || p.x > canvas.width) p.vx *= -1;
|
|
if (p.y < 0 || p.y > canvas.height) p.vy *= -1;
|
|
|
|
p.x += p.vx * pulseFactor;
|
|
p.y += p.vy * pulseFactor;
|
|
|
|
// Age the particle
|
|
p.age++;
|
|
if (p.age > p.maxAge && params.lifespan < 0.5) {
|
|
// Respawn if lifespan is low
|
|
p.x = Math.random() * canvas.width;
|
|
p.y = Math.random() * canvas.height;
|
|
p.age = 0;
|
|
}
|
|
|
|
// Update pulse
|
|
p.pulse = params.pulse.avg + Math.sin(time * p.jitter * 2) * (params.pulse.max - params.pulse.min) * 0.3;
|
|
});
|
|
|
|
// Draw connections
|
|
ctx.strokeStyle = `rgba(${palette.r}, ${palette.g}, ${palette.b}, 0.2)`;
|
|
ctx.lineWidth = 1 * params.dryness;
|
|
connections.forEach(conn => {
|
|
const a = particles[conn.a];
|
|
const b = particles[conn.b];
|
|
const dist = Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
|
|
if (dist < 100) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(a.x, a.y);
|
|
ctx.lineTo(b.x, b.y);
|
|
ctx.stroke();
|
|
}
|
|
});
|
|
|
|
// Draw particles
|
|
particles.forEach(p => {
|
|
const size = p.size * p.pulse * (0.7 + 0.3 * params.complexity);
|
|
ctx.beginPath();
|
|
ctx.arc(p.x, p.y, size, 0, Math.PI * 2);
|
|
ctx.fillStyle = `rgba(${palette.r}, ${palette.g}, ${palette.b}, ${p.alpha * p.pulse * 0.7})`;
|
|
ctx.fill();
|
|
});
|
|
}
|
|
|
|
function animate() {
|
|
update();
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |