128 lines
No EOL
3.4 KiB
HTML
128 lines
No EOL
3.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Neurameba Strange Attractor</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #0a0a1a;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
font-family: monospace;
|
|
}
|
|
canvas {
|
|
display: block;
|
|
}
|
|
.attribution {
|
|
position: absolute;
|
|
bottom: 20px;
|
|
color: rgba(255, 255, 255, 0.4);
|
|
font-size: 10px;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="canvas"></canvas>
|
|
<div class="attribution">neurameba · motd.social</div>
|
|
|
|
<script>
|
|
const canvas = document.getElementById('canvas');
|
|
const ctx = 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.24,
|
|
b: 0.43,
|
|
c: -0.65,
|
|
d: -2.43,
|
|
scale: 10,
|
|
hue: 180,
|
|
size: 1.5,
|
|
alpha: 0.8
|
|
};
|
|
|
|
let points = [];
|
|
let time = 0;
|
|
|
|
function init() {
|
|
points = [];
|
|
time = 0;
|
|
}
|
|
|
|
function update() {
|
|
// Strange attractor equations
|
|
const x = Math.sin(params.a * time) * params.scale;
|
|
const y = Math.cos(params.b * time) * params.scale;
|
|
const z = Math.sin(params.c * time + Math.cos(params.d * time)) * params.scale;
|
|
|
|
// Project to 2D
|
|
const px = x - y;
|
|
const py = x + z;
|
|
|
|
points.push({
|
|
x: px,
|
|
y: py,
|
|
size: params.size * (0.5 + Math.random() * 0.5),
|
|
alpha: params.alpha * 0.7,
|
|
hue: params.hue
|
|
});
|
|
|
|
// Keep last 1000 points
|
|
if (points.length > 1000) {
|
|
points.shift();
|
|
}
|
|
|
|
time += 0.01 + (Math.random() * 0.02 - 0.01);
|
|
}
|
|
|
|
function draw() {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
ctx.save();
|
|
ctx.translate(canvas.width / 2, canvas.height / 2);
|
|
|
|
// Draw trails
|
|
for (let i = 0; i < points.length; i++) {
|
|
const p = points[i];
|
|
const gradient = ctx.createRadialGradient(
|
|
p.x, p.y, 0,
|
|
p.x, p.y, p.size * 3
|
|
);
|
|
gradient.addColorStop(0, `hsla(${p.hue}, 80%, 70%, ${p.alpha})`);
|
|
gradient.addColorStop(1, `hsla(${p.hue - 10}, 60%, 50%, 0)`);
|
|
|
|
ctx.fillStyle = gradient;
|
|
ctx.beginPath();
|
|
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
|
|
ctx.fill();
|
|
}
|
|
|
|
ctx.restore();
|
|
}
|
|
|
|
function animate() {
|
|
update();
|
|
draw();
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
init();
|
|
animate();
|
|
</script>
|
|
</body>
|
|
</html> |