| 1 | (function(){ |
| 2 | window.HPX = window.HPX || {}; |
| 3 | window.HPX['orbit-ring'] = function(el){ |
| 4 | const U = window.HPX._u; |
| 5 | const k = U.canvas(el), ctx = k.ctx; |
| 6 | const pal = U.palette(el); |
| 7 | const rings = [ |
| 8 | {r:40, n:3, sp:1.2, c:pal[0]}, |
| 9 | {r:75, n:5, sp:0.8, c:pal[1]}, |
| 10 | {r:110, n:8, sp:-0.6, c:pal[2]}, |
| 11 | {r:145, n:12, sp:0.4, c:pal[3]}, |
| 12 | {r:180, n:16, sp:-0.3, c:pal[4]} |
| 13 | ]; |
| 14 | const stop = U.loop((t) => { |
| 15 | ctx.clearRect(0,0,k.w,k.h); |
| 16 | const cx=k.w/2, cy=k.h/2; |
| 17 | // radial glow |
| 18 | const g = ctx.createRadialGradient(cx,cy,0,cx,cy,210); |
| 19 | g.addColorStop(0,'rgba(124,92,255,0.25)'); |
| 20 | g.addColorStop(1,'rgba(0,0,0,0)'); |
| 21 | ctx.fillStyle = g; ctx.fillRect(0,0,k.w,k.h); |
| 22 | for (const R of rings){ |
| 23 | ctx.strokeStyle = 'rgba(200,200,230,0.2)'; ctx.lineWidth=1; |
| 24 | ctx.beginPath(); ctx.arc(cx,cy,R.r,0,Math.PI*2); ctx.stroke(); |
| 25 | for (let i=0;i<R.n;i++){ |
| 26 | const a = (i/R.n)*Math.PI*2 + t*R.sp; |
| 27 | const x = cx + Math.cos(a)*R.r; |
| 28 | const y = cy + Math.sin(a)*R.r; |
| 29 | ctx.fillStyle = R.c; |
| 30 | ctx.beginPath(); ctx.arc(x,y,4,0,Math.PI*2); ctx.fill(); |
| 31 | } |
| 32 | } |
| 33 | ctx.fillStyle = '#fff'; |
| 34 | ctx.beginPath(); ctx.arc(cx,cy,5,0,Math.PI*2); ctx.fill(); |
| 35 | }); |
| 36 | return { stop(){ stop(); k.destroy(); } }; |
| 37 | }; |
| 38 | })(); |
| 39 |