birth: Chaotic Tendrils Writhe
This commit is contained in:
parent
c2b78a6c53
commit
3ed6224847
1 changed files with 118 additions and 0 deletions
118
index.html
Normal file
118
index.html
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Chaotic Tendrils</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a10;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: #4a4a4a;
|
||||
font-size: 10px;
|
||||
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');
|
||||
|
||||
// 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 attractors = [
|
||||
{ a: 2.0, b: -2.0, c: -1.2, d: 2.0 },
|
||||
{ a: 3.4, b: -3.4, c: -2.0, d: 2.0 },
|
||||
{ a: 2.5, b: -3.0, c: -0.5, d: 1.5 }
|
||||
];
|
||||
|
||||
let points = [];
|
||||
const maxPoints = 5000;
|
||||
const step = 0.005;
|
||||
|
||||
function init() {
|
||||
points = Array(maxPoints).fill().map(() => ({
|
||||
x: Math.random() * 2 - 1,
|
||||
y: Math.random() * 2 - 1,
|
||||
hue: Math.random() * 360,
|
||||
age: 0,
|
||||
trail: []
|
||||
}));
|
||||
}
|
||||
|
||||
function draw() {
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
attractors.forEach((params, i) => {
|
||||
points.forEach(point => {
|
||||
const x = point.x;
|
||||
const y = point.y;
|
||||
|
||||
// Strange attractor iteration
|
||||
point.x = Math.sin(params.a * y) - Math.cos(params.b * x);
|
||||
point.y = Math.sin(params.c * x) - Math.cos(params.d * y);
|
||||
|
||||
// Scale to canvas
|
||||
const scale = Math.min(canvas.width, canvas.height) * 0.4;
|
||||
const px = (point.x + 1) * canvas.width / 2;
|
||||
const py = (point.y + 1) * canvas.height / 2;
|
||||
|
||||
// Store trail points
|
||||
point.trail.push({x: px, y: py, time: Date.now()});
|
||||
if (point.trail.length > 30) point.trail.shift();
|
||||
|
||||
// Draw with age-based fading
|
||||
const ageFactor = 1 - (point.age / maxPoints);
|
||||
const alpha = 0.3 * ageFactor;
|
||||
const hue = (point.hue + i * 120) % 360;
|
||||
|
||||
// Draw trail
|
||||
ctx.strokeStyle = `hsla(${hue}, 80%, 70%, ${alpha * 0.5})`;
|
||||
ctx.lineWidth = 1 * ageFactor;
|
||||
|
||||
ctx.beginPath();
|
||||
point.trail.forEach((p, j) => {
|
||||
if (j === 0) ctx.moveTo(p.x, p.y);
|
||||
else ctx.lineTo(p.x, p.y);
|
||||
});
|
||||
ctx.stroke();
|
||||
});
|
||||
});
|
||||
|
||||
// Occasionally reset points
|
||||
if (Math.random() < 0.01) {
|
||||
points.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
function animate() {
|
||||
draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
init();
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue