122 lines
No EOL
4.1 KiB
HTML
122 lines
No EOL
4.1 KiB
HTML
```html
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Charged Particulate</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a0a;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
#attribution {
|
|
position: absolute;
|
|
bottom: 20px;
|
|
color: #444;
|
|
font-family: monospace;
|
|
font-size: 10px;
|
|
text-align: center;
|
|
width: 100%;
|
|
}
|
|
</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();
|
|
|
|
const particles = [];
|
|
const density = 1500;
|
|
const motion = 0.5;
|
|
const complexity = 0.5;
|
|
const connectedness = 0.5;
|
|
const lifespan = 0.5;
|
|
const pulse = 1.08;
|
|
|
|
// Initialize particles with variation based on parameters
|
|
for (let i = 0; i < density * 3000; i++) {
|
|
particles.push({
|
|
x: Math.random() * canvas.width,
|
|
y: Math.random() * canvas.height,
|
|
size: Math.random() * 2 + 1,
|
|
speed: motion * (Math.random() * 0.5 + 0.1),
|
|
angle: Math.random() * Math.PI * 2,
|
|
life: Math.random() * 100 + 50,
|
|
color: `hsl(0, 0%, ${lifespan > 0.5 ? 80 + lifespan * 20 : 70}%)`,
|
|
trail: []
|
|
});
|
|
}
|
|
|
|
function draw() {
|
|
// Fade background slightly for motion trails
|
|
ctx.fillStyle = `rgba(10, 10, 10, ${0.9 + motion * 0.05})`;
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
particles.forEach((p, i) => {
|
|
// Simple physics with pulse influence
|
|
const pulseEffect = 1 + Math.sin(Date.now() * 0.002 * pulse) * 0.1 * motion;
|
|
p.angle += (Math.random() - 0.5) * 0.05 * (1 - connectedness);
|
|
p.x += Math.cos(p.angle) * p.speed * pulseEffect;
|
|
p.y += Math.sin(p.angle) * p.speed * pulseEffect;
|
|
|
|
// Boundary bounce with some randomness
|
|
if (p.x < 0 || p.x > canvas.width) p.angle = Math.PI - p.angle;
|
|
if (p.y < 0 || p.y > canvas.height) p.angle = -p.angle;
|
|
|
|
// Size variation based on complexity
|
|
p.size = 1 + (Math.sin(Date.now() * 0.001 * complexity) * 0.5 + 0.5) * 2;
|
|
|
|
// Particle life decay
|
|
p.life -= 0.1 + (1 - lifespan) * 0.2;
|
|
if (p.life <= 0) {
|
|
p.x = Math.random() * canvas.width;
|
|
p.y = Math.random() * canvas.height;
|
|
p.life = Math.random() * 100 + 50;
|
|
}
|
|
|
|
// Draw with dry/monochrome palette
|
|
ctx.strokeStyle = `rgba(255, 255, 255, ${p.life / 100})`;
|
|
ctx.lineWidth = p.size * 0.5;
|
|
|
|
// Draw trail if connectedness is high
|
|
if (connectedness > 0.7 && p.trail.length > 0) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(p.trail[0][0], p.trail[0][1]);
|
|
for (let j = 1; j < p.trail.length; j++) {
|
|
ctx.lineTo(p.trail[j][0], p.trail[j][1]);
|
|
}
|
|
ctx.stroke();
|
|
}
|
|
|
|
// Add current position to trail (with limited length)
|
|
p.trail.push([p.x, p.y]);
|
|
if (p.trail.length > 20) p.trail.shift();
|
|
});
|
|
|
|
requestAnimationFrame(draw);
|
|
}
|
|
|
|
draw();
|
|
</script>
|
|
</body>
|
|
</html>
|
|
``` |