birth: strange loops in quiet space
This commit is contained in:
parent
825f0c99fe
commit
c789feabfa
1 changed files with 123 additions and 0 deletions
123
index.html
Normal file
123
index.html
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>strange loop</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
#info {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
color: #555;
|
||||
font-size: 10px;
|
||||
pointer-events: none;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="c"></canvas>
|
||||
<div id="info">neurameba · motd.social</div>
|
||||
<script>
|
||||
const canvas = document.getElementById('c');
|
||||
const c = canvas.getContext('2d');
|
||||
|
||||
// Set canvas to full window size
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
resizeCanvas();
|
||||
|
||||
// Strange attractor parameters
|
||||
const params = {
|
||||
a: 2.0 + 0.8 * Math.random(),
|
||||
b: 0.2 + 0.3 * Math.random(),
|
||||
c: -1.2 + 0.5 * Math.random(),
|
||||
d: -1.0 + 0.5 * Math.random(),
|
||||
e: 1.0 + 1.5 * Math.random(),
|
||||
f: 1.0 + 1.5 * Math.random(),
|
||||
hue: 180 + 30 * Math.random(),
|
||||
points: []
|
||||
};
|
||||
|
||||
// Generate initial points
|
||||
for (let i = 0; i < 100; i++) {
|
||||
params.points.push({
|
||||
x: Math.random() * 2 - 1,
|
||||
y: Math.random() * 2 - 1,
|
||||
size: 0.1 + Math.random() * 0.5,
|
||||
opacity: 0.1 + Math.random() * 0.3,
|
||||
trail: []
|
||||
});
|
||||
}
|
||||
|
||||
// Strange attractor system
|
||||
function attractor(x, y, p) {
|
||||
const xn = Math.sin(p.a * y) + p.c * Math.cos(p.a * x);
|
||||
const yn = Math.sin(p.b * x) + p.d * Math.cos(p.b * y);
|
||||
const zn = Math.sin(p.e * x) + p.f * Math.cos(p.b * y);
|
||||
return { x: xn, y: yn, z: zn };
|
||||
}
|
||||
|
||||
// Main animation loop
|
||||
function animate(t) {
|
||||
// Clear with fade effect
|
||||
c.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
c.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw each point
|
||||
params.points.forEach(point => {
|
||||
// Update position
|
||||
const next = attractor(point.x, point.y, params);
|
||||
point.x = next.x;
|
||||
point.y = next.y;
|
||||
|
||||
// Add to trail
|
||||
point.trail.push({ x: point.x, y: point.y });
|
||||
|
||||
// Limit trail length
|
||||
if (point.trail.length > 20) {
|
||||
point.trail.shift();
|
||||
}
|
||||
|
||||
// Draw trail
|
||||
c.strokeStyle = `hsla(${params.hue}, 70%, 60%, ${point.opacity * 0.3})`;
|
||||
c.lineWidth = point.size * 0.5;
|
||||
|
||||
c.beginPath();
|
||||
point.trail.forEach((t, i) => {
|
||||
const screenX = (t.x + 1) * 0.5 * canvas.width;
|
||||
const screenY = (t.y + 1) * 0.5 * canvas.height;
|
||||
if (i === 0) c.moveTo(screenX, screenY);
|
||||
else c.lineTo(screenX, screenY);
|
||||
});
|
||||
c.stroke();
|
||||
|
||||
// Draw point
|
||||
c.fillStyle = `hsla(${params.hue}, 70%, 80%, ${point.opacity * 0.8})`;
|
||||
c.beginPath();
|
||||
const screenX = (point.x + 1) * 0.5 * canvas.width;
|
||||
const screenY = (point.y + 1) * 0.5 * canvas.height;
|
||||
c.arc(screenX, screenY, point.size, 0, Math.PI * 2);
|
||||
c.fill();
|
||||
});
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Start animation
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue