birth: Fractal Echoes of Motion
This commit is contained in:
parent
4eecba3926
commit
1bf0796c82
1 changed files with 178 additions and 0 deletions
178
index.html
Normal file
178
index.html
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Strange Attractor | neurameba</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
color: #444;
|
||||
font-size: 10px;
|
||||
font-family: monospace;
|
||||
text-shadow: 0 0 5px rgba(0,0,0,0.5);
|
||||
}
|
||||
</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 resize() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resize);
|
||||
resize();
|
||||
|
||||
// Strange attractor parameters
|
||||
const params = {
|
||||
a: 1.5,
|
||||
b: 0.3,
|
||||
c: 1.0,
|
||||
d: 0.3,
|
||||
e: 0.1,
|
||||
f: 0.0,
|
||||
scale: 0.5,
|
||||
motion: 0.5,
|
||||
density: 0.5,
|
||||
complexity: 0.5,
|
||||
connectedness: 0.5,
|
||||
lifespan: 0.5,
|
||||
pulseFactor: 1.03
|
||||
};
|
||||
|
||||
// Color palette (dryness/monochrome)
|
||||
const colors = [
|
||||
{r: 255, g: 255, b: 255, a: 0.1},
|
||||
{r: 200, g: 200, b: 200, a: 0.2},
|
||||
{r: 150, g: 150, b: 150, a: 0.3},
|
||||
{r: 100, g: 100, b: 100, a: 0.4}
|
||||
];
|
||||
|
||||
// Particle system
|
||||
const particles = [];
|
||||
const maxPoints = Math.floor(200 + 200 * params.complexity);
|
||||
const trailLength = Math.floor(5 + 15 * params.connectedness);
|
||||
|
||||
class Particle {
|
||||
constructor() {
|
||||
this.reset();
|
||||
this.trail = [];
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.x = Math.random() * canvas.width;
|
||||
this.y = Math.random() * canvas.height;
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
this.size = 0.5 + Math.random() * 1.5;
|
||||
this.life = 0;
|
||||
this.maxLife = 50 + Math.random() * 100;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
|
||||
// Strange attractor equations (modified Rössler attractor)
|
||||
const x = this.x - canvas.width/2;
|
||||
const y = this.y - canvas.height/2;
|
||||
|
||||
const a = params.a * 0.5;
|
||||
const b = params.b;
|
||||
const c = params.c;
|
||||
const d = params.d * (0.5 + params.connectedness * 0.5);
|
||||
const e = params.e;
|
||||
const pulse = params.pulseFactor;
|
||||
|
||||
const dt = 0.01 * (0.5 + params.motion * 0.5);
|
||||
|
||||
const dx = (-y - z) * dt * pulse;
|
||||
const dy = (x + a*y) * dt * pulse;
|
||||
const dz = (b + z*(x - c)) * dt * pulse;
|
||||
z = z + dz;
|
||||
|
||||
this.x += dx * params.scale * (0.8 + params.density * 0.4);
|
||||
this.y += dy * params.scale * (0.8 + params.density * 0.4);
|
||||
|
||||
this.life++;
|
||||
|
||||
// Trail
|
||||
this.trail.push({x: this.x, y: this.y});
|
||||
if (this.trail.length > trailLength) {
|
||||
this.trail.shift();
|
||||
}
|
||||
|
||||
// Reset if too old or out of bounds
|
||||
if (this.life > this.maxLife ||
|
||||
this.x < -100 || this.x > canvas.width + 100 ||
|
||||
this.y < -100 || this.y > canvas.height + 100) {
|
||||
this.reset();
|
||||
}
|
||||
}
|
||||
|
||||
draw() {
|
||||
ctx.strokeStyle = `rgba(${colors[Math.floor(Math.random() * colors.length)].r},
|
||||
${colors[Math.floor(Math.random() * colors.length)].g},
|
||||
${colors[Math.floor(Math.random() * colors.length)].b},
|
||||
${colors[Math.floor(Math.random() * colors.length)].a})`;
|
||||
ctx.lineWidth = this.size;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.prevX, this.prevY);
|
||||
|
||||
for (let i = 0; i < this.trail.length; i++) {
|
||||
const point = this.trail[i];
|
||||
const alpha = i / this.trail.length;
|
||||
ctx.globalAlpha = alpha * colors[0].a;
|
||||
ctx.lineTo(point.x, point.y);
|
||||
}
|
||||
|
||||
ctx.stroke();
|
||||
ctx.globalAlpha = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize particles
|
||||
for (let i = 0; i < maxPoints; i++) {
|
||||
particles.push(new Particle());
|
||||
}
|
||||
|
||||
let z = 0;
|
||||
let frameCount = 0;
|
||||
|
||||
function animate() {
|
||||
frameCount++;
|
||||
|
||||
// Clear with fade effect
|
||||
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