151 lines
No EOL
4.7 KiB
HTML
151 lines
No EOL
4.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Particle Nebula</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background-color: #0a0a0a;
|
|
color: #cccccc;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
#container {
|
|
position: relative;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
}
|
|
#canvas {
|
|
display: block;
|
|
}
|
|
#attribution {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
font-size: 10px;
|
|
opacity: 0.5;
|
|
pointer-events: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="container">
|
|
<canvas id="canvas"></canvas>
|
|
<div id="attribution">neurameba · motd.social</div>
|
|
</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 based on provided values
|
|
const params = {
|
|
motion: 0.5,
|
|
density: 0.5,
|
|
complexity: 0.5,
|
|
connectedness: 0.5,
|
|
lifespan: 0.5,
|
|
pulse: { avg: 1.1, min: 0.9, max: 1.2 },
|
|
tone: { dryness: 0.8 }
|
|
};
|
|
|
|
const particles = [];
|
|
const particleCount = Math.floor(200 + params.density * 300);
|
|
const baseSize = 1.5 + params.complexity * 1.5;
|
|
const maxSpeed = 0.5 + params.motion * 1.5;
|
|
const pulseRange = params.pulse.max - params.pulse.min;
|
|
|
|
class Particle {
|
|
constructor() {
|
|
this.reset();
|
|
this.size = baseSize * (0.7 + Math.random() * 0.6);
|
|
this.lifespan = 100 + Math.random() * 200;
|
|
this.energy = 0.3 + Math.random() * 0.7;
|
|
this.color = {
|
|
r: 200 + Math.random() * 55,
|
|
g: 200 + Math.random() * 55,
|
|
b: 200 + Math.random() * 55
|
|
};
|
|
}
|
|
|
|
reset() {
|
|
this.x = Math.random() * canvas.width;
|
|
this.y = Math.random() * canvas.height;
|
|
this.vx = (Math.random() - 0.5) * maxSpeed * 2;
|
|
this.vy = (Math.random() - 0.5) * maxSpeed * 2;
|
|
this.ax = 0;
|
|
this.ay = 0;
|
|
this.life = 0;
|
|
}
|
|
|
|
update() {
|
|
// Apply slight curve to movement
|
|
this.ax = Math.sin(this.y * 0.001 + this.life * 0.01) * 0.1;
|
|
this.ay = Math.cos(this.x * 0.001 + this.life * 0.01) * 0.1;
|
|
|
|
this.vx += this.ax;
|
|
this.vy += this.ay;
|
|
this.vx *= 0.95;
|
|
this.vy *= 0.95;
|
|
|
|
this.x += this.vx;
|
|
this.y += this.vy;
|
|
|
|
// Boundary collision with bounce
|
|
if (this.x < 0) { this.x = 0; this.vx *= -0.5; }
|
|
if (this.x > canvas.width) { this.x = canvas.width; this.vx *= -0.5; }
|
|
if (this.y < 0) { this.y = 0; this.vy *= -0.5; }
|
|
if (this.y > canvas.height) { this.y = canvas.height; this.vy *= -0.5; }
|
|
|
|
this.life++;
|
|
this.energy *= 0.995; // Fade over time
|
|
|
|
// Reset if too old or too small
|
|
if (this.life > this.lifespan || this.size < 0.3) {
|
|
this.reset();
|
|
}
|
|
}
|
|
|
|
draw() {
|
|
const pulse = params.pulse.avg + Math.sin(Date.now() * 0.001) * pulseRange * 0.1;
|
|
const alpha = Math.min(1, this.energy * (1 - this.life / this.lifespan) * pulse);
|
|
ctx.fillStyle = `rgba(${this.color.r}, ${this.color.g}, ${this.color.b}, ${alpha})`;
|
|
ctx.beginPath();
|
|
ctx.arc(this.x, this.y, this.size * alpha, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
}
|
|
}
|
|
|
|
function initParticles() {
|
|
particles.length = 0;
|
|
for (let i = 0; i < particleCount; i++) {
|
|
particles.push(new Particle());
|
|
}
|
|
}
|
|
|
|
function animate() {
|
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
particles.forEach(p => {
|
|
p.update();
|
|
p.draw();
|
|
});
|
|
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
initParticles();
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |