From 12a146129e5e79b51958abf47c49d62aa1c382b0 Mon Sep 17 00:00:00 2001 From: vaishnosingh Date: Wed, 14 Oct 2026 16:48:17 +0530 Subject: [PATCH] feat(orbit): add 3D orbital motion graphics canvas and vibrant hover highlights --- templates/index.html | 328 ++++++++++++++++++++++++++++++++++-- templates/orbitconsole.html | 233 +++++++++++++++++++++---- 2 files changed, 520 insertions(+), 41 deletions(-) diff --git a/templates/index.html b/templates/index.html index 37ad838..4932741 100644 --- a/templates/index.html +++ b/templates/index.html @@ -180,12 +180,14 @@ body.m-open .mmenu a:nth-child(3){transition-delay:.24s} background:linear-gradient(90deg,transparent,rgba(143,216,255,.8),transparent); animation:packet 8.5s linear infinite} .divider.d-ember::after{background:linear-gradient(90deg,transparent,rgba(255,171,77,.75),transparent)} +.divider.d-violet::after{background:linear-gradient(90deg,transparent,rgba(168,85,247,.85),transparent)} @keyframes packet{to{left:calc(100% + 130px)}} /* ─── MODULE SECTIONS ─── */ .module{position:relative;z-index:10;padding:clamp(90px,11vw,170px) var(--pad);scroll-margin-top:70px} .m-forge{--ac:255,171,77} .m-oort{--ac:143,216,255} +.m-orbit{--ac:168,85,247} .module-inner{max-width:1260px;margin:0 auto;display:grid;grid-template-columns:1.02fr 1fr; gap:clamp(48px,7vw,110px);align-items:center} .module-inner.flip .m-text{order:2} @@ -230,9 +232,9 @@ body.m-open .mmenu a:nth-child(3){transition-delay:.24s} @supports(-webkit-text-stroke:1px red){ .m-ghost{color:transparent;-webkit-text-stroke:1.3px rgba(var(--ac),.16)} } -.m-oort canvas{touch-action:pan-y} -body:not(.has-cur) .m-oort canvas{cursor:grab} -body:not(.has-cur).grabbing .m-oort canvas{cursor:grabbing} +.m-oort canvas,.m-orbit canvas{touch-action:pan-y} +body:not(.has-cur) .m-oort canvas,body:not(.has-cur) .m-orbit canvas{cursor:grab} +body:not(.has-cur).grabbing .m-oort canvas,body:not(.has-cur).grabbing .m-orbit canvas{cursor:grabbing} /* glass panels */ .glass{position:absolute;z-index:5;background:rgba(5,9,18,.72); @@ -254,13 +256,17 @@ body:not(.has-cur).grabbing .m-oort canvas{cursor:grabbing} @keyframes sweep{0%{top:0;opacity:0}8%{opacity:1}88%{opacity:1}100%{top:100%;opacity:0}} .stat{right:max(-3.5%,-26px);top:4%;padding:16px 18px 14px;min-width:214px} +.m-orbit .stat{left:max(-3.5%,-26px);bottom:5%;top:auto;right:auto;min-width:236px} .srow{display:flex;align-items:baseline;gap:10px;padding:5.5px 0} .srow span{font-family:var(--mono);font-size:9px;letter-spacing:.18em;text-transform:uppercase;color:rgba(226,234,242,.34)} .srow b{font-family:var(--mono);font-size:14px;font-weight:500;color:#cfeafc;margin-left:auto} .srow em{font-style:normal;font-family:var(--mono);font-size:9px;color:rgba(143,216,255,.55);letter-spacing:.08em} +.m-orbit .srow b{color:#f1f5f9} +.m-orbit .srow em{color:rgba(168,85,247,.85)} .bars{display:flex;gap:3px;height:22px;align-items:flex-end;margin-top:12px} .bars i{width:3px;border-radius:1px;background:rgba(143,216,255,.55); animation:bar 1s ease-in-out infinite alternate;transform-origin:bottom} +.m-orbit .bars i{background:linear-gradient(to top, rgba(168,85,247,.65), rgba(56,189,248,.85))} @keyframes bar{from{transform:scaleY(.12)}to{transform:scaleY(1)}} /* ─── FOOTER ─── */ @@ -470,7 +476,7 @@ footer{position:relative;z-index:10;border-top:1px solid var(--line); -
+
@@ -490,12 +496,14 @@ footer{position:relative;z-index:10;border-top:1px solid var(--line); -
+
-
+ +
container engineDockerv1.45
-
proxy gatewayActive:4100
-
orchestratorHealthy100%
+
active runtime:4100proxy
+
orchestratorHealthy100%
+
@@ -966,6 +974,283 @@ function oortFrame(t,dt){ drawParts(true); /* near particles */ } +/* ═══════════════ ORBIT — draggable 3D multi-ring reactor system ═══════════════ */ +const orbCv=$('#orbitCv'),orbCtx=orbCv?orbCv.getContext('2d'):null,orbBox=orbCv?orbCv.parentElement:null; +let orbW=0,orbH=0,orbR=0,orbCX=0,orbCY=0,orbVis=false,orbInit=false; +let orbYaw=.48,orbPitch=.42,orbPitchT=.42,orbYawV=.0028,orbDrag=false,orbLx=0,orbLy=0; +let orbRings=[],orbNodes=[],orbPulses=[],orbDust=[],nextOrbPulse=1800; + +function orbitResize(){ + if(!orbBox||!orbCv)return; + const s=orbBox.clientWidth;if(!s)return; + orbW=s;orbH=s; + orbCv.width=s*DPR;orbCv.height=s*DPR; + orbCv.style.width=s+'px';orbCv.style.height=s+'px'; + orbCtx.setTransform(DPR,0,0,DPR,0,0); + orbR=s*.175;orbCX=s*.5;orbCY=s*.5; +} + +function orbitBuild(){ + orbRings=[ + {r:1.18,incX:.35,incY:.25,rotSpeed:.55,a:0,color:'rgba(56,189,248,',segs:64}, + {r:1.62,incX:-.48,incY:.38,rotSpeed:-.42,a:1.2,color:'rgba(168,85,247,',segs:72}, + {r:2.08,incX:.22,incY:-.52,rotSpeed:.28,a:2.5,color:'rgba(14,165,233,',segs:80} + ]; + + orbNodes=[ + {ring:0,a:.2,w:.55,sz:5.5,label:'WEB',port:':4100',color:[56,189,248]}, + {ring:0,a:3.3,w:.55,sz:5.0,label:'API',port:':4101',color:[16,185,129]}, + {ring:1,a:1.5,w:-.42,sz:6.0,label:'SVC',port:':4102',color:[168,85,247]}, + {ring:1,a:4.7,w:-.42,sz:4.8,label:'AUTH',port:':4103',color:[245,158,11]}, + {ring:2,a:.8,w:.28,sz:5.2,label:'DATA',port:':4104',color:[14,165,233]}, + {ring:2,a:3.9,w:.28,sz:5.6,label:'CRON',port:':4105',color:[16,185,129]} + ]; + + orbDust=[]; + for(let i=0;i<180;i++){ + const rr=.75+Math.random()*1.55; + orbDust.push({ + rr, + a:Math.random()*TAU, + w:(.7/Math.pow(rr,1.4))*(.85+Math.random()*.3), + y:(Math.random()-0.5)*.35, + sz:Math.random()<.1?1.4+Math.random()*.8:.6+Math.random()*.6, + al:.25+Math.random()*.65, + isPurple:Math.random()>.5 + }); + } +} + +if(orbCv){ + orbCv.addEventListener('pointerdown',e=>{ + orbDrag=true;orbLx=e.clientX;orbLy=e.clientY; + try{orbCv.setPointerCapture(e.pointerId);}catch(_){} + document.body.classList.add('grabbing'); + }); + orbCv.addEventListener('pointermove',e=>{ + if(!orbDrag)return; + const dx=e.clientX-orbLx,dy=e.clientY-orbLy; + orbLx=e.clientX;orbLy=e.clientY; + orbYaw+=dx*.0056;orbYawV=dx*.0056; + orbPitchT=clamp(orbPitchT+dy*.0035,-.6,1.2); + }); + ['pointerup','pointercancel'].forEach(ev=>orbCv.addEventListener(ev,()=>{ + orbDrag=false;document.body.classList.remove('grabbing'); + })); +} + +function orbitFrame(t,dt){ + if(!orbInit){orbitBuild();orbInit=true;} + if(!orbDrag){ + if(!RM)orbYawV+=(.0028-orbYawV)*.02; + else orbYawV*=.9; + orbYaw+=orbYawV; + } + orbPitch+=(orbPitchT-orbPitch)*.09; + + const cyw=Math.cos(orbYaw),syw=Math.sin(orbYaw); + const cp=Math.cos(orbPitch),sp=Math.sin(orbPitch); + + const P=(x,y,z)=>{ + const x1=x*cyw+z*syw,z1=-x*syw+z*cyw; + const y2=y*cp-z1*sp,z2=y*sp+z1*cp; + const pr=900/(900+z2); + return{x:orbCX+x1*pr,y:orbCY+y2*pr,z:z2,pr}; + }; + + const ringPt=(ring,angle)=>{ + const rad=ring.r*orbR; + const rx=Math.cos(angle)*rad; + const ry=0; + const rz=Math.sin(angle)*rad; + const cx=Math.cos(ring.incX),sx=Math.sin(ring.incX); + const y1=ry*cx-rz*sx,z1=ry*sx+rz*cx; + const cy=Math.cos(ring.incY),sy=Math.sin(ring.incY); + const x2=rx*cy+z1*sy,z2=-rx*sy+z1*cy; + return P(x2,y1,z2); + }; + + orbCtx.clearRect(0,0,orbW,orbH); + + for(const r of orbRings)r.a+=r.rotSpeed*dt; + for(const n of orbNodes)n.a+=n.w*dt; + for(const d of orbDust)d.a+=d.w*dt; + + /* Far dust */ + for(const d of orbDust){ + const q=P(Math.cos(d.a)*d.rr*orbR,d.y*orbR,Math.sin(d.a)*d.rr*orbR); + if(q.z>0)continue; + const al=d.al*clamp((q.pr-.75)*1.8,.2,1); + orbCtx.fillStyle=d.isPurple?`rgba(168,85,247,${al.toFixed(3)})`:`rgba(56,189,248,${al.toFixed(3)})`; + orbCtx.beginPath();orbCtx.arc(q.x,q.y,d.sz*q.pr,0,TAU);orbCtx.fill(); + } + + /* Far ring segments */ + for(const ring of orbRings){ + orbCtx.lineWidth=1.1; + for(let k=0;knextOrbPulse){ + orbPulses.push({t0:t}); + nextOrbPulse=t+3200+Math.random()*2200; + } + for(let i=orbPulses.length-1;i>=0;i--){ + const f=(t-orbPulses[i].t0)/2200; + if(f>=1){orbPulses.splice(i,1);continue;} + const prp=(.85+f*1.4)*orbR; + const alp=((1-f)*.45).toFixed(3); + orbCtx.strokeStyle=`rgba(56,189,248,${alp})`; + orbCtx.lineWidth=1.5; + orbCtx.beginPath(); + orbCtx.arc(orbCX,orbCY,prp,0,TAU); + orbCtx.stroke(); + } + + /* Near Ring Segments */ + for(const ring of orbRings){ + orbCtx.lineWidth=1.3; + for(let k=0;k0&&q2.z>0){ + const alpha=clamp((q1.pr-.72)*2.2,.25,.95); + orbCtx.strokeStyle=ring.color+alpha.toFixed(3)+')'; + orbCtx.beginPath();orbCtx.moveTo(q1.x,q1.y);orbCtx.lineTo(q2.x,q2.y);orbCtx.stroke(); + } + } + } + + /* Container Nodes & Laser Beams */ + const renderedNodes=orbNodes.map(n=>{ + const ring=orbRings[n.ring]; + const pos=ringPt(ring,n.a); + return{...n,pos}; + }).sort((a,b)=>a.pos.z-b.pos.z); + + for(const node of renderedNodes){ + const q=node.pos; + const r=node.sz*q.pr; + const [cr,cg,cb]=node.color; + const cl=clamp((q.pr-.75)*1.9,.35,1); + + if(q.z>0||Math.abs(q.z)-orbR*.4){ + orbCtx.save(); + orbCtx.font=`600 ${Math.max(9,(10*q.pr)|0)}px var(--font-mono, monospace)`; + orbCtx.textAlign='left'; + orbCtx.textBaseline='middle'; + orbCtx.fillStyle=`rgba(241,245,249,${(.9*cl).toFixed(2)})`; + orbCtx.fillText(`${node.label} ${node.port}`,q.x+r+6,q.y); + orbCtx.restore(); + } + } + + /* Near dust */ + for(const d of orbDust){ + const q=P(Math.cos(d.a)*d.rr*orbR,d.y*orbR,Math.sin(d.a)*d.rr*orbR); + if(q.z<=0)continue; + const al=d.al*clamp((q.pr-.75)*2.2,.35,1); + orbCtx.fillStyle=d.isPurple?`rgba(192,132,252,${al.toFixed(3)})`:`rgba(125,211,252,${al.toFixed(3)})`; + orbCtx.beginPath();orbCtx.arc(q.x,q.y,d.sz*q.pr,0,TAU);orbCtx.fill(); + } +} + /* ═══════════════ UI — cursor · reveals · scramble · telemetry ═══════════════ */ let curDot=null,curRing=null,curShown=false,crx=innerWidth/2,cry=innerHeight/2; if(FINE&&!RM){curDot=$('#curDot');curRing=$('#curRing');document.body.classList.add('has-cur');} @@ -1022,8 +1307,9 @@ setTimeout(()=>scramble($('#tagScr')),350); const vio=new IntersectionObserver(es=>{for(const en of es){ if(en.target===fbox)fVis=en.isIntersecting; if(en.target===obox)oVis=en.isIntersecting; + if(orbBox&&en.target===orbBox)orbVis=en.isIntersecting; }},{rootMargin:'80px'}); -vio.observe(fbox);vio.observe(obox); +vio.observe(fbox);vio.observe(obox);if(orbBox)vio.observe(orbBox); /* magnetic buttons */ if(FINE&&!RM)$$('.mag').forEach(b=>{ @@ -1072,6 +1358,26 @@ for(let i=0;i<14;i++){ bars.appendChild(b); } +/* orbit stats — live jitter + telemetry bars */ +const orbPorts=$('#orbPorts'); +if(orbPorts){ + const portsList=[':4100',':4102',':4105',':4280',':4310',':4450']; + setInterval(()=>{ + if(RM)return; + orbPorts.textContent=portsList[(Math.random()*portsList.length)|0]; + },2200); +} +const orbitBars=$('#orbitBars'); +if(orbitBars){ + for(let i=0;i<14;i++){ + const b=document.createElement('i'); + b.style.height=(5+Math.random()*17)+'px'; + b.style.animationDuration=(.6+Math.random()*.8)+'s'; + b.style.animationDelay=(-Math.random()*2).toFixed(2)+'s'; + orbitBars.appendChild(b); + } +} + /* HUD telemetry — UTC clock, pointer RA/DEC, session uptime */ const hudRa=$('#hudRa'),hudDec=$('#hudDec'),hudUtc=$('#hudUtc'),ftUp=$('#ftUp'); const t0=Date.now(); @@ -1107,7 +1413,8 @@ skyResize();buildStars();nebTex=makeNebula(); addEventListener('resize',()=>{skyResize();buildStars();}); new ResizeObserver(forgeResize).observe(fbox); new ResizeObserver(oortResize).observe(obox); -forgeResize();oortResize(); +if(orbBox)new ResizeObserver(orbitResize).observe(orbBox); +forgeResize();oortResize();if(orbBox)orbitResize(); /* pre-bake forge textures during idle time so scrolling never hitches */ const warm=()=>{if(!fInit)forgeInit();}; @@ -1123,6 +1430,7 @@ function loop(t){ skyFrame(tt,dt); if(fVis)forgeFrame(tt,dt); if(oVis)oortFrame(tt,dt); + if(orbVis)orbitFrame(tt,dt); uiFrame(t); requestAnimationFrame(loop); } diff --git a/templates/orbitconsole.html b/templates/orbitconsole.html index 0988bdc..d768acd 100644 --- a/templates/orbitconsole.html +++ b/templates/orbitconsole.html @@ -82,33 +82,48 @@ body { font-weight: 600; text-decoration: none; cursor: pointer; - transition: all 0.2s ease; + transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); border: 1px solid transparent; + position: relative; } .nav-btn-ghost { background: rgba(255, 255, 255, 0.04); color: var(--text-dim); - border-color: rgba(255, 255, 255, 0.08); + border: 1px solid rgba(255, 255, 255, 0.09); + backdrop-filter: blur(8px); } .nav-btn-ghost:hover { - background: rgba(255, 255, 255, 0.08); - color: #fff; - border-color: rgba(255, 255, 255, 0.15); + background: rgba(56, 189, 248, 0.12); + color: #38bdf8; + border-color: rgba(56, 189, 248, 0.55); + transform: translateY(-2px); + box-shadow: 0 0 18px rgba(56, 189, 248, 0.35), 0 4px 12px rgba(0, 0, 0, 0.4); +} +.nav-btn-ghost:active { + transform: translateY(0); } .nav-btn-primary { - background: linear-gradient(135deg, #0284c7, #38bdf8); + background: linear-gradient(135deg, #0284c7 0%, #38bdf8 50%, #818cf8 100%); + background-size: 200% 200%; color: #fff; - box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25); + border: 1px solid rgba(255, 255, 255, 0.25); + box-shadow: 0 4px 16px rgba(56, 189, 248, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.4); } .nav-btn-primary:hover { - transform: translateY(-1px); - box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4); + transform: translateY(-2px) scale(1.02); + box-shadow: 0 0 28px rgba(56, 189, 248, 0.7), 0 8px 25px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.6); + background-position: 100% 100%; +} +.nav-btn-primary:active { + transform: translateY(0) scale(0.99); } /* Container & Layout */ .main-wrap { max-width: 1380px; margin: 0 auto; padding: 32px 32px 64px; + position: relative; + z-index: 10; } /* Stats Grid */ .stats-grid { @@ -127,6 +142,12 @@ body { flex-direction: column; gap: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); + transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); +} +.stat-card:hover { + border-color: rgba(56, 189, 248, 0.35); + transform: translateY(-3px); + box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), 0 0 24px rgba(56, 189, 248, 0.16); } .stat-label { font-size: 12.5px; @@ -163,14 +184,14 @@ body { display: flex; flex-direction: column; gap: 16px; - transition: all 0.25s ease; + transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); position: relative; overflow: hidden; } .app-card:hover { - border-color: rgba(56, 189, 248, 0.35); - box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35); - transform: translateY(-2px); + border-color: rgba(56, 189, 248, 0.45); + box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5), 0 0 32px rgba(56, 189, 248, 0.2); + transform: translateY(-4px); } .app-card-header { display: flex; @@ -280,21 +301,62 @@ body { display: inline-flex; align-items: center; gap: 6px; - border: 1px solid rgba(255, 255, 255, 0.08); + border: 1px solid rgba(255, 255, 255, 0.09); background: rgba(255, 255, 255, 0.03); color: var(--text-dim); cursor: pointer; - transition: all 0.2s ease; + transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1); + backdrop-filter: blur(4px); + text-decoration: none; } -.btn-sm-action:hover { - background: rgba(255, 255, 255, 0.08); +.btn-sm-action:hover, .btn-sm-action.act-logs:hover, .btn-sm-action.act-rebuild:hover { + background: rgba(56, 189, 248, 0.15); + color: #38bdf8; + border-color: rgba(56, 189, 248, 0.55); + transform: translateY(-2px); + box-shadow: 0 0 16px rgba(56, 189, 248, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3); +} +.btn-sm-action.act-restart:hover, .btn-sm-action.act-start:hover { + background: rgba(16, 185, 129, 0.18); + color: #34d399; + border-color: rgba(16, 185, 129, 0.6); + transform: translateY(-2px); + box-shadow: 0 0 18px rgba(16, 185, 129, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3); +} +.btn-sm-action.act-stop:hover { + background: rgba(245, 158, 11, 0.18); + color: #fbbf24; + border-color: rgba(245, 158, 11, 0.6); + transform: translateY(-2px); + box-shadow: 0 0 18px rgba(245, 158, 11, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3); +} +.btn-sm-action.act-backup:hover { + background: rgba(168, 85, 247, 0.2); + color: #c084fc; + border-color: rgba(168, 85, 247, 0.6); + transform: translateY(-2px); + box-shadow: 0 0 18px rgba(168, 85, 247, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3); +} +.btn-sm-action.act-open { + color: var(--accent-cyan); + border-color: rgba(56, 189, 248, 0.3); +} +.btn-sm-action.act-open:hover { + background: linear-gradient(135deg, rgba(2, 132, 199, 0.3), rgba(56, 189, 248, 0.25)); color: #fff; - border-color: rgba(255, 255, 255, 0.2); + border-color: #38bdf8; + transform: translateY(-2px); + box-shadow: 0 0 22px rgba(56, 189, 248, 0.6), 0 4px 14px rgba(0, 0, 0, 0.35); } .btn-sm-action.danger:hover { - background: rgba(239, 68, 68, 0.15); + background: rgba(239, 68, 68, 0.2); color: #f87171; - border-color: rgba(239, 68, 68, 0.35); + border-color: rgba(239, 68, 68, 0.6); + transform: translateY(-2px); + box-shadow: 0 0 18px rgba(239, 68, 68, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3); +} +.btn-sm-action:active { + transform: translateY(0); } /* Modal Styles */ .modal-overlay { @@ -343,18 +405,40 @@ body { } .tab-btn { background: transparent; - border: none; + border: 1px solid transparent; color: var(--text-muted); font-size: 13.5px; font-weight: 600; padding: 6px 14px; border-radius: 8px; cursor: pointer; - transition: all 0.2s; + transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); +} +.tab-btn:hover { + color: #fff; + background: rgba(255, 255, 255, 0.06); + border-color: rgba(255, 255, 255, 0.12); + transform: translateY(-1px); } .tab-btn.active { - background: rgba(56, 189, 248, 0.12); + background: rgba(56, 189, 248, 0.15); color: var(--accent-cyan); + border-color: rgba(56, 189, 248, 0.35); + box-shadow: 0 0 14px rgba(56, 189, 248, 0.25); +} +.template-card { + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(255, 255, 255, 0.08); + border-radius: 10px; + padding: 12px; + cursor: pointer; + transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); +} +.template-card:hover { + background: rgba(56, 189, 248, 0.08); + border-color: rgba(56, 189, 248, 0.4); + transform: translateY(-2px); + box-shadow: 0 0 16px rgba(56, 189, 248, 0.25); } .form-group { display: flex; @@ -420,6 +504,7 @@ body { +
@@ -665,24 +750,24 @@ async function loadApplications() {
- ${isRunning ? ` - - + + ` : ` - - + + `}
- - + Open App ↗ @@ -794,7 +879,7 @@ async function loadStarterTemplates() { const res = await api('/orbit/api/templates'); if (res && res.templates) { list.innerHTML = res.templates.map(t => ` -
${escapeHTML(t.name)}
${escapeHTML(t.description)}
@@ -907,6 +992,92 @@ async function refreshCurrentLogs() { loadApplications(); // Auto refresh fleet telemetry every 8 seconds setInterval(loadApplications, 8000); + +// Background ambient particle mesh animation +(function initOrbitSpaceCanvas() { + const cv = document.getElementById('orbitSpaceCanvas'); + if (!cv) return; + const ctx = cv.getContext('2d'); + let w = 0, h = 0, pts = []; + let mouse = { x: -1000, y: -1000, active: false }; + + function resize() { + w = cv.width = window.innerWidth; + h = cv.height = window.innerHeight; + } + window.addEventListener('resize', resize); + resize(); + + for (let i = 0; i < 70; i++) { + pts.push({ + x: Math.random() * w, + y: Math.random() * h, + vx: (Math.random() - 0.5) * 0.45, + vy: (Math.random() - 0.5) * 0.45, + r: Math.random() < 0.25 ? 2.2 : 1.2, + color: Math.random() > 0.45 ? 'rgba(56,189,248,' : 'rgba(168,85,247,', + alpha: 0.25 + Math.random() * 0.5 + }); + } + + window.addEventListener('mousemove', e => { + mouse.x = e.clientX; + mouse.y = e.clientY; + mouse.active = true; + }); + window.addEventListener('mouseleave', () => { mouse.active = false; }); + + function draw() { + ctx.clearRect(0, 0, w, h); + + // Dynamic constellation links + for (let i = 0; i < pts.length; i++) { + for (let j = i + 1; j < pts.length; j++) { + const dx = pts[i].x - pts[j].x; + const dy = pts[i].y - pts[j].y; + const d = Math.sqrt(dx * dx + dy * dy); + if (d < 125) { + const a = (1 - d / 125) * 0.16; + ctx.strokeStyle = `rgba(56, 189, 248, ${a})`; + ctx.lineWidth = 0.8; + ctx.beginPath(); + ctx.moveTo(pts[i].x, pts[i].y); + ctx.lineTo(pts[j].x, pts[j].y); + ctx.stroke(); + } + } + } + + // Drifting particles with mouse interaction + for (const p of pts) { + p.x += p.vx; + p.y += p.vy; + if (p.x < 0) p.x = w; + if (p.x > w) p.x = 0; + if (p.y < 0) p.y = h; + if (p.y > h) p.y = 0; + + if (mouse.active) { + const mdx = mouse.x - p.x; + const mdy = mouse.y - p.y; + const md = Math.sqrt(mdx * mdx + mdy * mdy); + if (md < 150) { + const force = (1 - md / 150) * 0.08; + p.x -= (mdx / md) * force * 15; + p.y -= (mdy / md) * force * 15; + } + } + + ctx.fillStyle = p.color + p.alpha + ')'; + ctx.beginPath(); + ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2); + ctx.fill(); + } + + requestAnimationFrame(draw); + } + draw(); +})();