birth: Suspended Curious Particle Drift
This commit is contained in:
parent
1563460fb3
commit
66899c4e38
1 changed files with 185 additions and 0 deletions
185
index.html
Normal file
185
index.html
Normal file
|
|
@ -0,0 +1,185 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Neurameba Particle Symphony</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 0.5;
|
||||||
|
z-index: 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();
|
||||||
|
|
||||||
|
// Palette based on tone
|
||||||
|
const palette = {
|
||||||
|
background: '#0a0a0a',
|
||||||
|
primary: '#40e0d0', // teal for curiosity
|
||||||
|
secondary: '#888888', // dryness monochrome
|
||||||
|
accent: '#ffaa33' // playfulness hint
|
||||||
|
};
|
||||||
|
|
||||||
|
// Particle system parameters
|
||||||
|
const particles = [];
|
||||||
|
const particleCount = 150 * Math.sqrt(Density);
|
||||||
|
const motionScale = 0.5 + Motion * 0.5;
|
||||||
|
const complexityScale = 0.3 + Complexity * 0.7;
|
||||||
|
|
||||||
|
// Initialize particles
|
||||||
|
class Particle {
|
||||||
|
constructor() {
|
||||||
|
this.reset();
|
||||||
|
this.size = (0.5 + Math.random() * 0.5) * (1 - Density) * 10;
|
||||||
|
this.lifespan = 100 + Math.random() * 1000 * Lifespan;
|
||||||
|
this.energy = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.x = Math.random() * canvas.width;
|
||||||
|
this.y = Math.random() * canvas.height;
|
||||||
|
this.vx = (Math.random() - 0.5) * 2 * motionScale;
|
||||||
|
this.vy = (Math.random() - 0.5) * 2 * motionScale;
|
||||||
|
this.targetX = this.x;
|
||||||
|
this.targetY = this.y;
|
||||||
|
this.connected = [];
|
||||||
|
this.connections = [];
|
||||||
|
this.age = 0;
|
||||||
|
this.alpha = 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.age++;
|
||||||
|
if (this.age > this.lifespan) {
|
||||||
|
this.reset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slight movement toward target
|
||||||
|
this.x += (this.targetX - this.x) * 0.01 * motionScale;
|
||||||
|
this.y += (this.targetY - this.y) * 0.01 * motionScale;
|
||||||
|
|
||||||
|
// Random small movements
|
||||||
|
this.x += (Math.random() - 0.5) * 0.5 * motionScale;
|
||||||
|
this.y += (Math.random() - 0.5) * 0.5 * motionScale;
|
||||||
|
|
||||||
|
// Boundary check
|
||||||
|
if (this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height) {
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.alpha = 1 - this.age / this.lifespan;
|
||||||
|
this.energy = 0.3 + (1 - this.alpha) * 0.7;
|
||||||
|
|
||||||
|
// Adjust color based on energy
|
||||||
|
const hue = 180 + (1 - this.energy) * 60;
|
||||||
|
this.color = `hsla(${hue}, 80%, 70%, ${this.alpha * (0.3 + Playfulness * 0.7)})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.fillStyle = this.color;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create particles
|
||||||
|
for (let i = 0; i < particleCount; i++) {
|
||||||
|
particles.push(new Particle());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connection logic
|
||||||
|
function updateConnections() {
|
||||||
|
particles.forEach(p1 => {
|
||||||
|
p1.connected = [];
|
||||||
|
const maxDist = 100 * (1 - Density) * (0.5 + Connectedness * 0.5);
|
||||||
|
|
||||||
|
particles.forEach(p2 => {
|
||||||
|
if (p1 === p2) return;
|
||||||
|
|
||||||
|
const dx = p1.x - p2.x;
|
||||||
|
const dy = p1.y - p2.y;
|
||||||
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (dist < maxDist) {
|
||||||
|
p1.connected.push(p2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Draw connections
|
||||||
|
ctx.strokeStyle = `rgba(64, 224, 208, ${0.2 + Curiosity * 0.1})`;
|
||||||
|
ctx.lineWidth = 1 * (1 - Density) * (0.2 + Complexity * 0.8);
|
||||||
|
|
||||||
|
particles.forEach(p1 => {
|
||||||
|
p1.connected.forEach(p2 => {
|
||||||
|
if (p1.x < p2.x || (p1.x === p2.x && p1.y < p2.y)) { // Draw each connection once
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(p1.x, p1.y);
|
||||||
|
ctx.lineTo(p2.x, p2.y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main animation loop
|
||||||
|
const Pulse = {
|
||||||
|
value: 1.07,
|
||||||
|
target: 1.07,
|
||||||
|
speed: 0.01
|
||||||
|
};
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
// Update pulse
|
||||||
|
Pulse.target = 1.0 + 0.1 * Math.sin(Date.now() * 0.001);
|
||||||
|
Pulse.value += (Pulse.target - Pulse.value) * Pulse.speed;
|
||||||
|
|
||||||
|
// Clear with slight blur for trails
|
||||||
|
ctx.fillStyle = palette.background;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Update and draw particles
|
||||||
|
particles.forEach(p => {
|
||||||
|
p.update();
|
||||||
|
p.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update connections
|
||||||
|
updateConnections();
|
||||||
|
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue