birth: Flowing Electric Smoke
This commit is contained in:
parent
3350a7891d
commit
0520414b98
1 changed files with 160 additions and 0 deletions
160
index.html
Normal file
160
index.html
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Flow Field Organism</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: 10px;
|
||||
right: 10px;
|
||||
color: #555;
|
||||
font-family: monospace;
|
||||
font-size: 10px;
|
||||
text-shadow: 0 0 2px #000;
|
||||
}
|
||||
</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();
|
||||
|
||||
// Flow field parameters
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.25, min: 1.0, max: 1.55 },
|
||||
tone: {
|
||||
anger: 0.0,
|
||||
sadness: 0.0,
|
||||
curiosity: 0.1,
|
||||
dryness: 0.9,
|
||||
playfulness: 0.0,
|
||||
tension: 0.0
|
||||
}
|
||||
};
|
||||
|
||||
// Particle system
|
||||
const particles = [];
|
||||
const particleCount = Math.floor(100 + params.density * 200);
|
||||
const baseSize = 1 + params.complexity * 2;
|
||||
const maxLife = 200 + params.lifespan * 300;
|
||||
const speed = 0.2 + params.motion * 0.8;
|
||||
const turbulence = 0.05 + params.complexity * 0.1;
|
||||
const connectivity = params.connectedness;
|
||||
|
||||
class Particle {
|
||||
constructor() {
|
||||
this.reset();
|
||||
this.life = 0;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.x = Math.random() * canvas.width;
|
||||
this.y = Math.random() * canvas.height;
|
||||
this.size = baseSize * (0.5 + Math.random() * 0.5);
|
||||
this.angle = Math.random() * Math.PI * 2;
|
||||
this.velocity = {
|
||||
x: Math.cos(this.angle) * speed,
|
||||
y: Math.sin(this.angle) * speed
|
||||
};
|
||||
this.targetX = this.x;
|
||||
this.targetY = this.y;
|
||||
this.color = `rgba(200, 200, 200, ${0.1 + params.tone.dryness * 0.9})`;
|
||||
}
|
||||
|
||||
update() {
|
||||
// Flow field influence
|
||||
const noiseX = (this.x * 0.01 + Date.now() * 0.0003) % 1;
|
||||
const noiseY = (this.y * 0.01 + Date.now() * 0.0003) % 1;
|
||||
|
||||
const flowX = Math.sin(noiseX * Math.PI * 2) * turbulence;
|
||||
const flowY = Math.cos(noiseY * Math.PI * 2) * turbulence;
|
||||
|
||||
this.velocity.x += flowX;
|
||||
this.velocity.y += flowY;
|
||||
|
||||
// Pulse effect
|
||||
const pulseFactor = params.pulse.avg + Math.sin(Date.now() * 0.002) * 0.1;
|
||||
this.velocity.x *= pulseFactor;
|
||||
this.velocity.y *= pulseFactor;
|
||||
|
||||
// Movement
|
||||
this.x += this.velocity.x;
|
||||
this.y += this.velocity.y;
|
||||
|
||||
// Boundary conditions
|
||||
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;
|
||||
|
||||
// Lifespan
|
||||
this.life++;
|
||||
if (this.life > maxLife) {
|
||||
this.reset();
|
||||
this.life = 0;
|
||||
}
|
||||
|
||||
// Fade out when near death
|
||||
const alpha = 1 - (this.life / maxLife);
|
||||
this.color = `rgba(200, 200, 200, ${alpha * (0.1 + params.tone.dryness * 0.9)})`;
|
||||
}
|
||||
|
||||
draw() {
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
||||
ctx.fillStyle = this.color;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize particles
|
||||
for (let i = 0; i < particleCount; i++) {
|
||||
particles.push(new Particle());
|
||||
}
|
||||
|
||||
function animate() {
|
||||
// Dark background
|
||||
ctx.fillStyle = 'rgba(10, 10, 10, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Update and draw particles
|
||||
particles.forEach(p => {
|
||||
p.update();
|
||||
p.draw();
|
||||
});
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue