birth: Fractured Light in Silence
This commit is contained in:
parent
65bd8e0832
commit
95f27ddbf1
1 changed files with 124 additions and 0 deletions
124
index.html
Normal file
124
index.html
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Strange Attractor</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #0a0a0a;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
#attribution {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
color: #555;
|
||||
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');
|
||||
|
||||
function resize() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
window.addEventListener('resize', resize);
|
||||
resize();
|
||||
|
||||
// Strange attractor parameters
|
||||
const params = {
|
||||
a: 2.24,
|
||||
b: 0.43,
|
||||
c: -0.65,
|
||||
d: -2.43,
|
||||
e: 1.0,
|
||||
scale: 10,
|
||||
points: []
|
||||
};
|
||||
|
||||
// Initialize points
|
||||
for (let i = 0; i < 5000 * (0.5 + Math.random() * 0.5); i++) {
|
||||
params.points.push({
|
||||
x: Math.random() * 2 - 1,
|
||||
y: Math.random() * 2 - 1,
|
||||
vx: 0,
|
||||
vy: 0,
|
||||
life: 0
|
||||
});
|
||||
}
|
||||
|
||||
// Color palette (dryness/monochrome)
|
||||
const colors = [
|
||||
'#f0f0f0', '#d8d8d8', '#b8b8b8',
|
||||
'#909090', '#686868', '#383838'
|
||||
];
|
||||
|
||||
function updatePoints() {
|
||||
for (let p of params.points) {
|
||||
const x = p.x, y = p.y;
|
||||
p.vx += params.a * Math.sin(params.b * y) + params.c * Math.cos(params.d * x);
|
||||
p.vy += params.e * Math.sin(x);
|
||||
p.x += p.vx * 0.01;
|
||||
p.y += p.vy * 0.01;
|
||||
|
||||
p.life += 0.01;
|
||||
|
||||
// Constrain to attractor basin
|
||||
p.x = Math.max(-3, Math.min(3, p.x));
|
||||
p.y = Math.max(-3, Math.min(3, p.y));
|
||||
|
||||
// Fade old points
|
||||
if (p.life > 5) {
|
||||
params.points.splice(params.points.indexOf(p), 1);
|
||||
params.points.push({
|
||||
x: Math.random() * 2 - 1,
|
||||
y: Math.random() * 2 - 1,
|
||||
vx: 0,
|
||||
vy: 0,
|
||||
life: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
ctx.strokeStyle = colors[Math.floor(Math.random() * colors.length)];
|
||||
ctx.lineWidth = 0.5 + Math.random() * 0.5;
|
||||
|
||||
ctx.beginPath();
|
||||
for (let p of params.points) {
|
||||
const px = canvas.width/2 + p.x * params.scale * canvas.width/500;
|
||||
const py = canvas.height/2 + p.y * params.scale * canvas.width/500;
|
||||
ctx.moveTo(px, py);
|
||||
ctx.lineTo(px + p.vx * 5, py + p.vy * 5);
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
function animate() {
|
||||
updatePoints();
|
||||
draw();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue