flowing-teal-tendrils-2a5u/index.html

157 lines
No EOL
4.9 KiB
HTML

<!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: #0a0a1a;
font-family: 'Courier New', monospace;
color: #44ffaa;
display: flex;
flex-direction: column;
height: 100vh;
}
canvas {
display: block;
width: 100%;
height: 100%;
}
#attribution {
position: absolute;
bottom: 10px;
right: 10px;
font-size: 10px;
opacity: 0.7;
text-shadow: 0 0 5px #44ffaa;
}
</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 motion = 0.5;
const density = 0.5;
const complexity = 0.5;
const connectedness = 0.5;
const lifespan = 0.5;
const pulse = 1.1;
const tone = {
curiosity: 0.3,
dryness: 0.8
};
// Color palette (dryness=monochrome, curiosity=teals)
const colors = [
'rgba(180, 180, 255, 0.9)',
'rgba(150, 150, 230, 0.8)',
'rgba(120, 120, 200, 0.7)'
];
// Flow field particles
const particles = [];
const particleCount = Math.floor(200 + density * 800);
class Particle {
constructor() {
this.reset();
this.lifespan = 0.5 + Math.random() * 0.5;
this.size = 0.5 + Math.random() * 2;
this.color = colors[Math.floor(Math.random() * colors.length)];
}
reset() {
this.pos = {
x: Math.random() * canvas.width,
y: Math.random() * canvas.height
};
this.vel = {
x: (Math.random() - 0.5) * 2,
y: (Math.random() - 0.5) * 2
};
this.prevPos = {...this.pos};
this.age = 0;
}
update() {
this.prevPos.x = this.pos.x;
this.prevPos.y = this.pos.y;
// Flow field influence
const fieldX = 0.01 * this.pos.y + Math.sin(Date.now() * 0.0005 * pulse) * 0.5;
const fieldY = 0.01 * this.pos.x + Math.cos(Date.now() * 0.0003 * pulse) * 0.5;
// Add complexity to motion
this.vel.x += (fieldX - 0.5) * motion * 0.05;
this.vel.y += (fieldY - 0.5) * motion * 0.05;
// Apply velocity with some noise
this.vel.x += (Math.random() - 0.5) * complexity * 0.2;
this.vel.y += (Math.random() - 0.5) * complexity * 0.2;
// Update position
this.pos.x += this.vel.x * motion;
this.pos.y += this.vel.y * motion;
// Boundary check
if (this.pos.x < 0 || this.pos.x > canvas.width) {
this.vel.x *= -0.5;
this.pos.x = Math.max(0, Math.min(canvas.width, this.pos.x));
}
if (this.pos.y < 0 || this.pos.y > canvas.height) {
this.vel.y *= -0.5;
this.pos.y = Math.max(0, Math.min(canvas.height, this.pos.y));
}
this.age += 0.005;
}
draw() {
const alpha = Math.min(1, this.age / this.lifespan);
ctx.strokeStyle = this.color.replace('0.9', (0.3 + alpha * 0.6).toFixed(1));
ctx.lineWidth = this.size * (0.5 + Math.sin(this.age * 0.1) * 0.5);
ctx.beginPath();
ctx.moveTo(this.prevPos.x, this.prevPos.y);
ctx.lineTo(this.pos.x, this.pos.y);
ctx.stroke();
}
}
// Initialize particles with varying complexity
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
function animate() {
// Fade effect based on lifespan
ctx.fillStyle = 'rgba(0, 0, 0, 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>