birth: Fractal Shadow Protocol
This commit is contained in:
parent
60f14e3b25
commit
3d41430538
1 changed files with 112 additions and 0 deletions
112
index.html
Normal file
112
index.html
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Strange Attractor Dance</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0a0a0a;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
#attribution {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 20px;
|
||||||
|
font-size: 10px;
|
||||||
|
opacity: 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 resizeCanvas() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', resizeCanvas);
|
||||||
|
resizeCanvas();
|
||||||
|
|
||||||
|
// Strange attractor parameters derived from transformation
|
||||||
|
const attractors = [
|
||||||
|
{
|
||||||
|
a: 1.4, b: -1.6, c: 1.0, d: -0.3,
|
||||||
|
scale: 20, speed: 0.02,
|
||||||
|
color: '#ffffff'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
a: 2.01, b: -2.53, c: 1.58, d: -1.5,
|
||||||
|
scale: 15, speed: 0.015,
|
||||||
|
color: '#cccccc'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
a: -1.24, b: -1.25, c: 2.69, d: -1.03,
|
||||||
|
scale: 25, speed: 0.018,
|
||||||
|
color: '#aaaaaa'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const points = Array(3).fill().map(() => ({
|
||||||
|
x: 0, y: 0,
|
||||||
|
trail: [],
|
||||||
|
maxTrail: 200
|
||||||
|
}));
|
||||||
|
|
||||||
|
let time = 0;
|
||||||
|
|
||||||
|
function drawStrangeAttractor() {
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
attractors.forEach((attr, i) => {
|
||||||
|
const p = points[i];
|
||||||
|
|
||||||
|
// Update point position
|
||||||
|
const x = Math.sin(p.y * attr.b) - Math.cos(p.x * attr.a);
|
||||||
|
const y = Math.sin(p.x * attr.c) - Math.cos(p.y * attr.d);
|
||||||
|
p.x = x;
|
||||||
|
p.y = y;
|
||||||
|
|
||||||
|
// Add to trail
|
||||||
|
p.trail.push({x: p.x, y: p.y});
|
||||||
|
if (p.trail.length > p.maxTrail) p.trail.shift();
|
||||||
|
|
||||||
|
// Draw trail
|
||||||
|
ctx.strokeStyle = attr.color;
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let j = 0; j < p.trail.length; j++) {
|
||||||
|
const segment = p.trail[j];
|
||||||
|
const px = (segment.x * attr.scale) + canvas.width/2;
|
||||||
|
const py = (segment.y * attr.scale) + canvas.height/2;
|
||||||
|
|
||||||
|
if (j === 0) {
|
||||||
|
ctx.moveTo(px, py);
|
||||||
|
} else {
|
||||||
|
ctx.lineTo(px, py);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
time += 0.01;
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
drawStrangeAttractor();
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue