-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (41 loc) · 1.54 KB
/
script.js
File metadata and controls
50 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const canvas = document.getElementById('orbitCanvas');
const ctx = canvas.getContext('2d');
function resizeCanvas() {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
}
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
// 5 glowing rings settings
const orbits = [
{ radius: 100, angle: 0, speed: 0.01, color: 'rgba(219, 156, 20, 0.2)', width: 2 },
{ radius: 140, angle: Math.PI / 2, speed: 0.008, color: 'rgba(28, 28, 28, 0.92)', width: 2 },
{ radius: 180, angle: Math.PI, speed: 0.006, color: 'rgba(26, 26, 25, 0.99)', width: 2 },
{ radius: 220, angle: Math.PI / 4, speed: 0.004, color: 'rgba(35, 35, 33, 0.7)', width: 2 },
{ radius: 260, angle: Math.PI / 3, speed: 0.003, color: 'rgba(23, 23, 22, 0.9)', width: 2 },
];
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
orbits.forEach(orbit => {
orbit.angle += orbit.speed;
// draw orbit ring
ctx.beginPath();
ctx.arc(centerX, centerY, orbit.radius, 0, Math.PI * 2);
ctx.strokeStyle = orbit.color;
ctx.lineWidth = orbit.width;
ctx.shadowBlur = 15;
ctx.shadowColor = orbit.color;
ctx.stroke();
// optional: small moving dot along the ring
const dotX = centerX + orbit.radius * Math.cos(orbit.angle);
const dotY = centerY + orbit.radius * Math.sin(orbit.angle);
ctx.beginPath();
ctx.arc(dotX, dotY, 6, 0, Math.PI * 2);
ctx.fillStyle = orbit.color;
ctx.fill();
});
requestAnimationFrame(animate);
}
animate();