birth: Whispering Teal Particles
This commit is contained in:
parent
bddbcdd5fe
commit
1002789082
1 changed files with 144 additions and 0 deletions
144
index.html
Normal file
144
index.html
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Particle Dance</title>
|
||||||
|
<style>
|
||||||
|
body { margin: 0; overflow: hidden; background: #0a0a0a; font-family: monospace; }
|
||||||
|
canvas { display: block; }
|
||||||
|
#attribution { position: fixed; bottom: 10px; right: 10px; color: #555; font-size: 10px; }
|
||||||
|
</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();
|
||||||
|
|
||||||
|
// Configuration derived from parameters
|
||||||
|
const config = {
|
||||||
|
motion: 0.5,
|
||||||
|
density: 0.5,
|
||||||
|
complexity: 0.5,
|
||||||
|
connectedness: 0.5,
|
||||||
|
lifespan: 0.5,
|
||||||
|
pulse: { avg: 1.1, min: 1.0, max: 1.2 },
|
||||||
|
tone: {
|
||||||
|
anger: 0.0,
|
||||||
|
sadness: 0.0,
|
||||||
|
curiosity: 0.7,
|
||||||
|
dryness: 0.9,
|
||||||
|
playfulness: 0.1,
|
||||||
|
tension: 0.0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Palette based on tone
|
||||||
|
const palette = [
|
||||||
|
{ r: 200, g: 255, b: 220 }, // curiosity (teal)
|
||||||
|
{ r: 220, g: 220, b: 220 }, // dryness (white)
|
||||||
|
{ r: 180, g: 220, b: 200 } // muted curiosity
|
||||||
|
];
|
||||||
|
|
||||||
|
// Particle system parameters
|
||||||
|
const particleCount = Math.floor(config.density * 300) + 100;
|
||||||
|
const maxSpeed = 1 + config.motion * 3;
|
||||||
|
const connectionDistance = 100 + config.connectedness * 150;
|
||||||
|
const particleSize = 1 + config.complexity * 2;
|
||||||
|
const trailLength = Math.floor(config.lifespan * 10) + 5;
|
||||||
|
|
||||||
|
class Particle {
|
||||||
|
constructor() {
|
||||||
|
this.x = Math.random() * canvas.width;
|
||||||
|
this.y = Math.random() * canvas.height;
|
||||||
|
this.vx = (Math.random() - 0.5) * maxSpeed;
|
||||||
|
this.vy = (Math.random() - 0.5) * maxSpeed;
|
||||||
|
this.color = palette[Math.floor(Math.random() * palette.length)];
|
||||||
|
this.trail = [];
|
||||||
|
this.life = 0;
|
||||||
|
this.pulse = config.pulse.avg * (0.9 + Math.random() * 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.x += this.vx * config.pulse.avg;
|
||||||
|
this.y += this.vy * config.pulse.avg;
|
||||||
|
|
||||||
|
// Wrap around edges
|
||||||
|
if (this.x < 0) this.x = canvas.width;
|
||||||
|
if (this.x > canvas.width) this.x = 0;
|
||||||
|
if (this.y < 0) this.y = canvas.height;
|
||||||
|
if (this.y > canvas.height) this.y = 0;
|
||||||
|
|
||||||
|
// Add to trail
|
||||||
|
this.trail.push({ x: this.x, y: this.y });
|
||||||
|
if (this.trail.length > trailLength) {
|
||||||
|
this.trail.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.life++;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
// Draw trail
|
||||||
|
for (let i = 0; i < this.trail.length; i++) {
|
||||||
|
const point = this.trail[i];
|
||||||
|
const size = particleSize * (0.3 + (i / this.trail.length) * 0.7);
|
||||||
|
const alpha = i / this.trail.length * 0.8;
|
||||||
|
ctx.fillStyle = `rgba(${this.color.r}, ${this.color.g}, ${this.color.b}, ${alpha})`;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(point.x, point.y, size, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const particles = Array(particleCount).fill().map(() => new Particle());
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
// Dim background
|
||||||
|
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Update and draw particles
|
||||||
|
particles.forEach(p => p.update());
|
||||||
|
particles.forEach(p => p.draw());
|
||||||
|
|
||||||
|
// Draw connections
|
||||||
|
ctx.strokeStyle = `rgba(180, 220, 200, 0.1)`;
|
||||||
|
ctx.lineWidth = 0.5;
|
||||||
|
|
||||||
|
for (let i = 0; i < particles.length; i++) {
|
||||||
|
for (let j = i + 1; j < particles.length; j++) {
|
||||||
|
const p1 = particles[i];
|
||||||
|
const p2 = particles[j];
|
||||||
|
const dx = p1.x - p2.x;
|
||||||
|
const dy = p1.y - p2.y;
|
||||||
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (distance < connectionDistance) {
|
||||||
|
ctx.globalAlpha = 1 - (distance / connectionDistance);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(p1.x, p1.y);
|
||||||
|
ctx.lineTo(p2.x, p2.y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.globalAlpha = 1;
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue