birth: Pulsing Organic Fragments
This commit is contained in:
parent
d4cca6fc34
commit
78f56e3e34
1 changed files with 146 additions and 0 deletions
146
index.html
Normal file
146
index.html
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Neurameba | Organic Particle System</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background-color: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
color: rgba(255, 255, 255, 0.3);
|
||||
font-size: 12px;
|
||||
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();
|
||||
|
||||
// Parameters derived from generative art builder
|
||||
const params = {
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulse: { avg: 1.11, min: 0.95, max: 1.30 },
|
||||
tone: { dryness: 0.9, curiosity: 0.1 },
|
||||
color: { dryness: 240, curiosity: 180 } // Monochrome with slight teal tint
|
||||
};
|
||||
|
||||
// Particle system configuration
|
||||
const particleCount = Math.floor(200 + params.density * 800);
|
||||
const baseSpeed = 0.5 + params.motion * 2;
|
||||
const connectionDistance = 100 + params.complexity * 150;
|
||||
const lifespanFactor = 0.5 + params.lifespan * 0.5;
|
||||
const complexityFactor = 0.3 + params.complexity * 0.7;
|
||||
|
||||
class Particle {
|
||||
constructor() {
|
||||
this.reset();
|
||||
this.size = 1 + Math.random() * 3 * (1 - params.complexity);
|
||||
this.color = `hsl(${params.tone.dryness ? params.tone.curiosity * 180 : 0}, ${params.tone.curiosity ? 50 : 0}%, ${params.tone.dryness ? 70 : 50}%)`;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.x = Math.random() * canvas.width;
|
||||
this.y = Math.random() * canvas.height;
|
||||
this.vx = (Math.random() - 0.5) * baseSpeed * 2;
|
||||
this.vy = (Math.random() - 0.5) * baseSpeed * 2;
|
||||
this.life = 0;
|
||||
this.maxLife = 100 + Math.random() * 100 * lifespanFactor;
|
||||
}
|
||||
|
||||
update(particles) {
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
|
||||
// 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;
|
||||
|
||||
this.life++;
|
||||
if (this.life > this.maxLife) {
|
||||
this.reset();
|
||||
this.life = 0;
|
||||
}
|
||||
|
||||
return particles;
|
||||
}
|
||||
}
|
||||
|
||||
const particles = [];
|
||||
for (let i = 0; i < particleCount; i++) {
|
||||
particles.push(new Particle());
|
||||
}
|
||||
|
||||
function drawConnection(p1, p2) {
|
||||
const dist = Math.sqrt((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2);
|
||||
if (dist < connectionDistance) {
|
||||
const alpha = 1 - (dist / connectionDistance);
|
||||
ctx.strokeStyle = `rgba(240, 240, 240, ${alpha * 0.1 * (0.5 + params.connectedness * 0.5)})`;
|
||||
ctx.lineWidth = 0.5 * (1 - params.complexity) + 0.5;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(p1.x, p1.y);
|
||||
ctx.lineTo(p2.x, p2.y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
function animate() {
|
||||
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(particles));
|
||||
|
||||
// Draw connections
|
||||
if (params.connectedness > 0.3) {
|
||||
for (let i = 0; i < particles.length; i++) {
|
||||
for (let j = i + 1; j < particles.length; j++) {
|
||||
drawConnection(particles[i], particles[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw particles
|
||||
particles.forEach(p => {
|
||||
const size = p.size * (0.7 + 0.3 * (p.life / p.maxLife));
|
||||
ctx.fillStyle = p.color;
|
||||
ctx.beginPath();
|
||||
ctx.arc(p.x, p.y, size, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
});
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue