Spaces:
Running
Running
Download index.html from Tonic/drone-detection: direct link, hf CLI and curl.
- Browser
- Download file 62.6 kB
-
https://huggingface.co/spaces/Tonic/drone-detection/resolve/main/index.html
- Command line
-
hf download hf://spaces/Tonic/drone-detection/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Tonic/drone-detection/resolve/main/index.html
62.6 kB
| <html><head><meta charset=utf8><meta name=viewport content="width=device-width,initial-scale=1,viewport-fit=cover"><style>:root{color-scheme:light;box-sizing:border-box;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}html{scroll-padding-top:env(safe-area-inset-top,0px)}body{margin:0;padding:0;font:14px -apple-system,BlinkMacSystemFont,sans-serif;background:#fff;color:#000}img{max-width:100%}[hidden]:not([hidden=until-found i]){display:none}</style></head><body> | |
| <title>Detectonic System Walkthrough</title> | |
| <meta name="claude:viewport-fit-sides" content="cover"> | |
| <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@700;800&family=IBM+Plex+Mono:wght@500;600&display=swap"> | |
| <style> | |
| /* Layout: one full-width canvas, a thin control row underneath. Deliberately dark night view. */ | |
| :root{--navy:#0D1B2A;--off:#EEF0EA;--green:#7F9A6A;--amber:#F2A93B;--steel:#8D9AA8;--rule:#2E3B4A;--ink:#08111B;color-scheme:dark} | |
| [hidden]{display:none} | |
| body{background:var(--ink);color:var(--off);font-family:system-ui,sans-serif; | |
| padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));padding-block:20px 28px} | |
| .wrap{max-width:1400px;margin:0 auto;display:flex;flex-direction:column;gap:10px} | |
| .view{position:relative;border:1px solid var(--rule);background:var(--navy);overflow:hidden} | |
| canvas{display:block;width:100%} | |
| .end{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(8,17,27,.85);transition:opacity .6s} | |
| .end img{width:min(60%,620px);height:auto;max-width:100%} | |
| .spec{position:relative;border:1px solid var(--rule);background:var(--navy);transition:border-color .3s} | |
| .spec.hit{border-color:var(--amber)} | |
| .spec canvas{display:block;width:100%;height:96px} | |
| .spec .win{position:absolute;right:0;top:0;bottom:0;width:30%;border-left:1px dashed var(--steel);background:rgba(127,154,106,.05)} | |
| .spec .who{position:absolute;left:8px;top:6px;font:600 12px ui-monospace,monospace;color:var(--green)} | |
| .controls{display:flex;gap:8px;align-items:center} | |
| button{cursor:pointer;width:40px;height:34px;display:grid;place-items:center;background:transparent;border:1px solid var(--rule);color:var(--off)} | |
| button:focus-visible,.bar:focus-visible{outline:2px solid var(--amber);outline-offset:2px} | |
| button svg{width:16px;height:16px;fill:currentColor} | |
| .bar{flex:1;height:6px;background:var(--rule);position:relative;cursor:pointer} | |
| .bar i{position:absolute;left:0;top:0;bottom:0;background:var(--green)} | |
| </style> | |
| <div class="wrap"> | |
| <div class="view"> | |
| <canvas id="field" role="img" aria-label="Animated night map of the Detectonic network: sentinels hear a truck, an explosion and a drone; nodes wake, turn their dishes, locate and track the drone, and alert a village."></canvas> | |
| <div class="end" id="end" hidden><img src="detectonic-logo.png" alt="Detectonic" width="1759" height="542"></div> | |
| </div> | |
| <div class="spec" id="specBox"> | |
| <canvas id="spec" width="480" height="96" aria-label="Live spectrogram of the listening sentinel"></canvas> | |
| <span class="win"></span> | |
| <span class="who" id="who">S1</span> | |
| </div> | |
| <div class="controls"> | |
| <button id="play" aria-label="Pause"><svg viewBox="0 0 16 16" id="playIcon"><rect x="3" y="2" width="3.5" height="12"/><rect x="9.5" y="2" width="3.5" height="12"/></svg></button> | |
| <button id="restart" aria-label="Restart"><svg viewBox="0 0 16 16"><path d="M8 2a6 6 0 1 1-5.6 3.9l1.9.7A4 4 0 1 0 8 4v2.5L4 3.5 8 .5z"/></svg></button> | |
| <div class="bar" id="bar" tabindex="0" role="slider" aria-label="Timeline" aria-valuemin="0" aria-valuemax="100"><i id="fill"></i></div> | |
| </div> | |
| </div> | |
| <script> | |
| (function(){ | |
| const cv=document.getElementById('field'),ctx=cv.getContext('2d'); | |
| const W=1000,H=600,C={navy:'#0D1B2A',off:'#EEF0EA',green:'#7F9A6A',amber:'#F2A93B',steel:'#8D9AA8',rule:'#2E3B4A'}; | |
| const S=[{id:'S1',x:300,y:250},{id:'S2',x:700,y:190},{id:'S3',x:545,y:468}]; | |
| const D=[{id:'D1',x:150,y:140,a0:200},{id:'D2',x:440,y:105,a0:-40},{id:'D3',x:160,y:405,a0:120}, | |
| {id:'D4',x:420,y:345,a0:60},{id:'D5',x:640,y:330,a0:10},{id:'D6',x:860,y:405,a0:250}]; | |
| const VILLAGE={x:875,y:525},CP={x:70,y:500},BOOM={x:845,y:115}; | |
| const T={truck:12,boom:20,drone:25,detect:30,wake:31,turn:35,tdoa:40,track:47,s2:51.5,alert:58,sens:60,fly2:66,fire:73,end:82}; | |
| // real time skips the old text-only scene (4–12) and ends with the owl | |
| const REAL_END=T.end-8+3.5; | |
| const toModel=r=>r<4?r:r<50?r+8:r<66?58+(r-50)*0.8:T.end; // targeting tail slow, then cut straight to the end once the precision circle closes | |
| const reduce=matchMedia('(prefers-reduced-motion: reduce)').matches; | |
| // real-time budget: 2 s logo intro → part 1 = 39 s (data 9 s + model build) → 13 s on-device perf clock | |
| // → 8 s cost segue (factory → grandma's garage) → part 2 = 34 s field sim → 2 s logo outro = 98 s, loops seamlessly | |
| const DATA_S=9,P1R=39,P2R=34,INTRO=2,SEG_R=8,PERF_R=13,LOGO=2,TOTAL=INTRO+P1R+PERF_R+SEG_R+P2R+LOGO,P1MODEL=42,P2MODEL=66; | |
| let RT=reduce?INTRO+P1R+PERF_R+SEG_R+11:0,rt=0,playing=!reduce,last=null,k=1,cw=0,chh=0,t=0,PART1=true,U1=0,SEG=0,PERF=0,MODE='intro',DPR=1; | |
| function mapTime(){const r2=RT-INTRO; | |
| if(r2<0){MODE='intro';PART1=true;SEG=0;U1=0;rt=0;t=4;return} | |
| if(r2<P1R){MODE='p1';PART1=true;SEG=0;U1=r2<DATA_S?r2:DATA_S+(r2-DATA_S)*((P1MODEL-DATA_S)/(P1R-DATA_S));rt=0;t=U1;return} | |
| if(r2<P1R+PERF_R){MODE='perf';PART1=true;SEG=0;U1=P1MODEL;rt=P2MODEL;t=T.end;PERF=(r2-P1R)/PERF_R;return} | |
| if(r2<P1R+PERF_R+SEG_R){MODE='seg';PART1=true;SEG=(r2-P1R-PERF_R)/SEG_R;U1=P1MODEL;rt=0;t=4;return} | |
| if(r2<P1R+PERF_R+SEG_R+P2R){MODE='p2';PART1=false;SEG=1;U1=P1MODEL;rt=Math.min(P2MODEL,(r2-P1R-PERF_R-SEG_R)*(P2MODEL/P2R));t=toModel(rt);return} | |
| MODE='outro';PART1=true;SEG=1;U1=P1MODEL;rt=P2MODEL;t=T.end} | |
| mapTime(); | |
| const clamp=(v,a,b)=>Math.max(a,Math.min(b,v)); | |
| const ease=x=>x<.5?2*x*x:1-Math.pow(-2*x+2,2)/2; | |
| const sm=(a,b,x)=>ease(clamp((x-a)/(b-a),0,1)); | |
| const dist=(a,b)=>Math.hypot(a.x-b.x,a.y-b.y); | |
| const ang=(a,b)=>Math.atan2(b.y-a.y,b.x-a.x)*180/Math.PI; | |
| const KF=[[25,40,40],[31,255,150],[40,290,172],[47,305,180],[58,690,300],[64,830,345]]; | |
| function droneAt(tt){if(tt<KF[0][0])return null;for(let i=1;i<KF.length;i++){if(tt<=KF[i][0]){const a=KF[i-1],b=KF[i],u=(tt-a[0])/(b[0]-a[0]);return{x:a[1]+(b[1]-a[1])*u,y:a[2]+(b[2]-a[2])*u}}}const z=KF[KF.length-1];return{x:z[1],y:z[2]}} | |
| function drone2At(tt){const KF2=[[66,80,470],[68,300,360],[70,520,255],[72,700,195],[74,920,150]]; | |
| if(tt<KF2[0][0]||tt>KF2[KF2.length-1][0])return null; | |
| for(let i=1;i<KF2.length;i++){if(tt<=KF2[i][0]){const a=KF2[i-1],b=KF2[i],u=(tt-a[0])/(b[0]-a[0]);return{x:a[1]+(b[1]-a[1])*u,y:a[2]+(b[2]-a[2])*u}}} | |
| return{x:KF2[KF2.length-1][1],y:KF2[KF2.length-1][2]}} | |
| function vehAt(tt){if(tt<T.truck||tt>T.truck+8.8)return null;return{x:-60+(tt-T.truck)*(1120/8.8),y:548}} | |
| const BOOM_T=20.6; | |
| D.forEach((d,i)=>{if(i<5){d.wake=32.9+0.12*i;d.pk=[32+0.12*i,32.9+0.12*i,S[0]]}else{d.wake=53;d.pk=[52.1,53,S[1]]}}); | |
| D.forEach((d,i)=>{const segs=[];let from=d.a0;const first=i<5?T.turn:53.2,firstDur=i<5?2.0:1.4; | |
| const starts=[first];for(let s=T.track;s<T.end;s+=1.6){if(s>first+firstDur)starts.push(s)} | |
| starts.forEach((ts,j)=>{const dur=j===0?firstDur:0.6;const tgt=droneAt(ts+(ts<T.tdoa?0:0.9));let to=ang(d,tgt);to=from+((((to-from)%360)+540)%360-180);segs.push({ts,dur,from,to});from=to}); | |
| d.segs=segs}); | |
| function dish(d,tt){const s=d.segs;if(tt<s[0].ts)return{a:d.a0,turning:false,listen:false};let cur=s[0];for(const g of s){if(g.ts<=tt)cur=g} | |
| const u=clamp((tt-cur.ts)/cur.dur,0,1);return{a:cur.from+(cur.to-cur.from)*ease(u),turning:u<1,listen:u>=1}} | |
| const P=droneAt(T.tdoa),TN=[S[0],D[0],D[1],D[3]],VS=110; | |
| const tArr=TN.map(n=>T.tdoa+dist(n,P)/VS); | |
| const ref=TN.reduce((m,n)=>dist(n,P)<dist(m,P)?n:m,TN[0]); | |
| function contour(f){const st=6,nx=Math.ceil(W/st),ny=Math.ceil(H/st),v=[],seg=[]; | |
| for(let j=0;j<=ny;j++){v[j]=[];for(let i=0;i<=nx;i++)v[j][i]=f(i*st,j*st)} | |
| for(let j=0;j<ny;j++)for(let i=0;i<nx;i++){const a=v[j][i],b=v[j][i+1],c=v[j+1][i+1],d=v[j+1][i],x=i*st,y=j*st,p=[]; | |
| if((a<0)!==(b<0))p.push([x+st*a/(a-b),y]);if((b<0)!==(c<0))p.push([x+st,y+st*b/(b-c)]); | |
| if((c<0)!==(d<0))p.push([x+st-st*c/(c-d),y+st]);if((d<0)!==(a<0))p.push([x,y+st-st*d/(d-a)]); | |
| if(p.length>=2)seg.push(p[0],p[1]);if(p.length===4)seg.push(p[2],p[3])}return seg} | |
| const curves=TN.filter(n=>n!==ref).map((n,j)=>{const k0=dist(P,n)-dist(P,ref);return{t0:43.2+j*0.8,seg:contour((x,y)=>Math.hypot(x-n.x,y-n.y)-Math.hypot(x-ref.x,y-ref.y)-k0)}}); | |
| let seed=7;const rnd=()=>{seed=(seed*16807)%2147483647;return(seed-1)/2147483646}; | |
| const gauss=()=>Math.sqrt(-2*Math.log(1-rnd()))*Math.cos(2*Math.PI*rnd()); | |
| const FIX=[];(function(){let est=null,vel={x:0,y:0};const dt=0.6;let n=0;for(let tt=T.track;tt<=T.end;tt+=dt){n++;const p=droneAt(tt),z={x:p.x+gauss()*7,y:p.y+gauss()*7}; | |
| if(!est)est={...z};else{const px=est.x+vel.x*dt,py=est.y+vel.y*dt,rx=z.x-px,ry=z.y-py;est={x:px+.5*rx,y:py+.5*ry};vel={x:vel.x+.22*rx/dt,y:vel.y+.22*ry/dt}} | |
| FIX.push({t:tt,z,est:{...est},vel:{...vel},unc:6+32/Math.sqrt(n)})}})(); | |
| function resize(){const r=cv.parentElement.getBoundingClientRect();cw=r.width;k=cw/W;chh=H*k;DPR=window.devicePixelRatio||1;const dpr=DPR; | |
| cv.width=Math.round(cw*dpr);cv.height=Math.round(chh*dpr);cv.style.height=chh+'px';ctx.setTransform(dpr,0,0,dpr,0,0)} | |
| const X=x=>x*k,Y=y=>y*k,M=()=>Math.max(.75,k); | |
| const scr=fn=>{ctx.save();ctx.setTransform(DPR,0,0,DPR,0,0);fn();ctx.restore()}; | |
| function txt(s,x,y,col,size){ctx.font=`600 ${size*M()}px ui-monospace, monospace`;ctx.textAlign='left';ctx.lineWidth=3;ctx.strokeStyle='rgba(0,0,0,.65)';ctx.strokeText(s,X(x),Y(y));ctx.fillStyle=col;ctx.fillText(s,X(x),Y(y))} | |
| // ---------- realistic night terrain (generated once) | |
| function makeTerrain(){ | |
| const SC=2,TW=W*SC,TH=H*SC,c=document.createElement('canvas');c.width=TW;c.height=TH;const g=c.getContext('2d'); | |
| let s=12345;const R=()=>{s=(s*16807)%2147483647;return(s-1)/2147483646}; | |
| const Pm=new Uint8Array(512);for(let i=0;i<256;i++)Pm[i]=i;for(let i=255;i>0;i--){const j=Math.floor(R()*(i+1));const tmp=Pm[i];Pm[i]=Pm[j];Pm[j]=tmp}for(let i=0;i<256;i++)Pm[i+256]=Pm[i]; | |
| const fd=q=>q*q*(3-2*q); | |
| const vn=(x,y)=>{const xi=Math.floor(x)&255,yi=Math.floor(y)&255,xf=x-Math.floor(x),yf=y-Math.floor(y);const a=Pm[Pm[xi]+yi]/255,b=Pm[Pm[xi+1]+yi]/255,c2=Pm[Pm[xi]+yi+1]/255,d=Pm[Pm[xi+1]+yi+1]/255,u=fd(xf),v=fd(yf);return a+(b-a)*u+(c2-a)*v+(a-b-c2+d)*u*v}; | |
| const fbm=(x,y)=>{let v=0,a=.5,f=1;for(let o=0;o<5;o++){v+=a*vn(x*f,y*f);a*=.5;f*=2}return v}; | |
| const LW=250,LH=150,lc=document.createElement('canvas');lc.width=LW;lc.height=LH;const lg=lc.getContext('2d'),id=lg.createImageData(LW,LH); | |
| for(let y=0;y<LH;y++)for(let x=0;x<LW;x++){const n=fbm(x/26,y/26),i=(y*LW+x)*4;id.data[i]=22+n*26;id.data[i+1]=28+n*26;id.data[i+2]=18+n*14;id.data[i+3]=255} | |
| lg.putImageData(id,0,0);g.imageSmoothingEnabled=true;g.drawImage(lc,0,0,TW,TH); | |
| g.save();g.scale(SC,SC); | |
| // field system with furrows, slightly rotated like real parcels | |
| g.save();g.translate(W/2,H/2);g.rotate(-0.17); | |
| const cols=['#2b241c','#30281e','#1f2b1b','#25321f','#3a3420','#342f21','#272b1c','#2d2a1f'],edges=[]; | |
| for(let y=-560;y<560;){const hh=55+R()*50;for(let x=-800;x<800;){const ww=90+R()*100;g.globalAlpha=.9;g.fillStyle=cols[Math.floor(R()*cols.length)];g.fillRect(x+1.5,y+1.5,ww-3,hh-3); | |
| g.globalAlpha=.16;g.strokeStyle='#000';g.lineWidth=.55;g.beginPath(); | |
| if(R()<.5){for(let fx=x+3;fx<x+ww-3;fx+=2.6){g.moveTo(fx,y+2);g.lineTo(fx,y+hh-2)}}else{for(let fy=y+3;fy<y+hh-3;fy+=2.6){g.moveTo(x+2,fy);g.lineTo(x+ww-2,fy)}}g.stroke(); | |
| g.globalAlpha=.07;g.fillStyle=R()<.5?'#fff':'#000';g.fillRect(x+ww*R()*.5,y+hh*R()*.5,ww*.5,hh*.5); | |
| if(R()<.55)edges.push([x,y,x+ww,y]);if(R()<.3)edges.push([x,y,x,y+hh]);x+=ww}y+=hh} | |
| g.globalAlpha=1; | |
| for(const[x1,y1,x2,y2]of edges){const L=Math.hypot(x2-x1,y2-y1);for(let d=0;d<L;d+=2.4){const u=d/L,px=x1+(x2-x1)*u+(R()-.5)*1.8,py=y1+(y2-y1)*u+(R()-.5)*1.8,r=1.4+R()*1.7; | |
| g.fillStyle='#0d170f';g.beginPath();g.arc(px,py,r,0,7);g.fill();g.fillStyle='rgba(44,66,38,.5)';g.beginPath();g.arc(px-.4,py-.5,r*.5,0,7);g.fill()}} | |
| g.restore(); | |
| // forests | |
| for(let i=0;i<14000;i++){const x=R()*W,y=R()*H,n=fbm(x/95+7,y/95+3);if(n<0.6||y>520)continue;if(Math.hypot(x-875,y-510)<110)continue; | |
| const r=2+R()*3.6;g.fillStyle='rgba(0,0,0,.35)';g.beginPath();g.arc(x+1.2,y+1.4,r,0,7);g.fill();g.fillStyle='#0c160e';g.beginPath();g.arc(x,y,r,0,7);g.fill(); | |
| g.fillStyle='rgba(40,62,36,.6)';g.beginPath();g.arc(x-r*.3,y-r*.3,r*.55,0,7);g.fill()} | |
| // river with banks | |
| const river=()=>{g.beginPath();g.moveTo(-20,60);g.bezierCurveTo(120,110,70,250,190,325);g.bezierCurveTo(300,395,250,470,335,620)}; | |
| g.lineCap='round';river();g.strokeStyle='#2a2e22';g.lineWidth=18;g.stroke();river();g.strokeStyle='#14222e';g.lineWidth=11;g.stroke(); | |
| river();g.strokeStyle='#0b1722';g.lineWidth=7;g.stroke();river();g.strokeStyle='rgba(140,170,190,.14)';g.lineWidth=1.2;g.stroke(); | |
| // dirt tracks | |
| g.strokeStyle='#3b3327';g.lineWidth=2.6;g.beginPath();g.moveTo(560,548);g.bezierCurveTo(600,420,520,330,610,200);g.bezierCurveTo(650,140,760,120,1010,90);g.stroke(); | |
| g.beginPath();g.moveTo(870,548);g.bezierCurveTo(880,500,860,470,900,430);g.stroke();g.beginPath();g.moveTo(100,548);g.bezierCurveTo(120,470,200,440,240,380);g.stroke(); | |
| // asphalt road + bridge | |
| g.fillStyle='#202428';g.fillRect(0,537,W,22);g.fillStyle='#2c3136';g.fillRect(0,537,W,1.5);g.fillRect(0,557.5,W,1.5); | |
| g.strokeStyle='rgba(210,205,180,.35)';g.lineWidth=1;g.setLineDash([9,9]);g.beginPath();g.moveTo(0,548);g.lineTo(W,548);g.stroke();g.setLineDash([]); | |
| g.fillStyle='#3a3f45';g.fillRect(300,533,46,30);g.fillStyle='#202428';g.fillRect(300,537,46,22); | |
| // village: houses with gardens and outbuildings | |
| const houses=[];for(let i=0;i<40;i++){const hx=800+R()*170,hy=455+R()*140;if(hy>530&&hy<566)continue; | |
| g.save();g.translate(hx,hy);g.rotate((R()-.5)*.35); | |
| g.fillStyle='rgba(50,70,40,.55)';g.fillRect(-8,-6,24,18); | |
| const rc=['#4a3a32','#3e434a','#56483a','#3a3d34','#5a3e34'][Math.floor(R()*5)];g.fillStyle='rgba(0,0,0,.4)';g.fillRect(1,1,12,9);g.fillStyle=rc;g.fillRect(0,0,12,9); | |
| g.strokeStyle='rgba(255,255,255,.12)';g.lineWidth=.6;g.beginPath();g.moveTo(0,4.5);g.lineTo(12,4.5);g.stroke(); | |
| if(R()<.5){g.fillStyle='#33352f';g.fillRect(14,2,5,4)}g.restore();houses.push({x:hx+6,y:hy+4,lit:R()<.4,ph:R()*6})} | |
| // command post compound | |
| g.restore(); | |
| g.fillStyle='rgba(8,18,40,.40)';g.fillRect(0,0,TW,TH); | |
| const vg=g.createRadialGradient(TW/2,TH/2,TH*.3,TW/2,TH/2,TH*1.0);vg.addColorStop(0,'rgba(0,0,0,0)');vg.addColorStop(1,'rgba(0,0,0,.55)');g.fillStyle=vg;g.fillRect(0,0,TW,TH); | |
| return{c,houses}; | |
| } | |
| const TER=makeTerrain(); | |
| // ---------- explosion particles (deterministic, so seeking works) | |
| let es=99;const ER=()=>{es=(es*16807)%2147483647;return(es-1)/2147483646}; | |
| const SPARKS=[...Array(46)].map(()=>({a:ER()*Math.PI*2,v:90+ER()*210,l:0.5+ER()*0.7,w:1+ER()*1.5})); | |
| const SMOKE=[...Array(38)].map(()=>({d:ER()*1.2,ox:(ER()-.5)*30,oy:(ER()-.5)*30,dx:(ER()-.5)*8,dy:-2-ER()*5,g:2.5+ER()*4.5,w:14+ER()*16,sh:ER()})); | |
| function drawBoom(since){ | |
| if(since<0)return;const bx=X(BOOM.x),by=Y(BOOM.y); | |
| // crater and embers | |
| if(since>0.25){ctx.fillStyle='rgba(6,5,4,.75)';ctx.beginPath();ctx.ellipse(bx,by,24*k,19*k,0.3,0,Math.PI*2);ctx.fill(); | |
| ctx.fillStyle='rgba(20,14,10,.6)';ctx.beginPath();ctx.ellipse(bx,by,40*k,32*k,0.3,0,Math.PI*2);ctx.fill(); | |
| if(since<14){for(let i=0;i<10;i++){const a=i*2.4,r=(6+i*1.6)*k,fl=.5+.5*Math.sin(t*9+i*1.7);ctx.fillStyle=`rgba(255,${110+i*8},40,${(0.65*fl)*Math.max(0,1-since/14)})`;ctx.beginPath();ctx.arc(bx+Math.cos(a)*r,by+Math.sin(a)*r,1.8*M(),0,Math.PI*2);ctx.fill()}}} | |
| // ground light | |
| if(since<3){const gl=ctx.createRadialGradient(bx,by,0,bx,by,(140+since*60)*k);gl.addColorStop(0,`rgba(255,150,60,${0.45*Math.exp(-since*1.6)})`);gl.addColorStop(1,'rgba(255,120,40,0)');ctx.fillStyle=gl;ctx.fillRect(bx-400*k,by-400*k,800*k,800*k)} | |
| // shock / dust ring | |
| if(since<1.3){const r=since*280*k;ctx.strokeStyle=`rgba(210,190,160,${0.5*(1-since/1.3)})`;ctx.lineWidth=(10*(1-since/1.3)+1)*k;ctx.beginPath();ctx.arc(bx,by,r,0,Math.PI*2);ctx.stroke()} | |
| // smoke plume drifting with the wind | |
| for(const p of SMOKE){const a=since-p.d;if(a<0||a>22)continue;const x=bx+(p.ox+p.dx*a+p.g*a+a*a*0.04)*k,y=by+(p.oy+p.dy*a*0.6)*k,r=(p.w*0.45+a*4.2)*k,al=Math.min(1,a*3)*0.55*Math.exp(-a/8); | |
| const sg=ctx.createRadialGradient(x-r*.3,y-r*.3,r*.1,x,y,r);const sh=55+p.sh*30;sg.addColorStop(0,`rgba(${sh+25},${sh+22},${sh+18},${al})`);sg.addColorStop(.7,`rgba(${sh},${sh-2},${sh-6},${al*.7})`);sg.addColorStop(1,`rgba(${sh-10},${sh-12},${sh-14},0)`); | |
| ctx.fillStyle=sg;ctx.beginPath();ctx.arc(x,y,r,0,Math.PI*2);ctx.fill()} | |
| // sparks | |
| for(const s of SPARKS){if(since>s.l)continue;const d=s.v*since*(1-since/(s.l*2.2)),x=bx+Math.cos(s.a)*d*k,y=by+Math.sin(s.a)*d*k,tl=Math.min(d,14)*k,al=1-since/s.l; | |
| ctx.strokeStyle=`rgba(255,${190-since*120|0},90,${al})`;ctx.lineWidth=s.w*M();ctx.beginPath();ctx.moveTo(x,y);ctx.lineTo(x-Math.cos(s.a)*tl,y-Math.sin(s.a)*tl);ctx.stroke()} | |
| // fireball | |
| if(since<1.8){const r=(8+46*(1-Math.exp(-since*5)))*k*(since>1?1-(since-1)*.5:1),al=since<.7?1:Math.max(0,1-(since-.7)/1.1); | |
| const fg=ctx.createRadialGradient(bx,by,0,bx,by,r);fg.addColorStop(0,`rgba(255,250,225,${al})`);fg.addColorStop(.25,`rgba(255,215,120,${al})`);fg.addColorStop(.55,`rgba(255,130,40,${al*.9})`);fg.addColorStop(.85,`rgba(170,50,20,${al*.6})`);fg.addColorStop(1,'rgba(60,20,10,0)'); | |
| ctx.fillStyle=fg;ctx.beginPath();ctx.arc(bx,by,r,0,Math.PI*2);ctx.fill()} | |
| // flash over the whole view | |
| if(since<0.3){const fl=ctx.createRadialGradient(bx,by,0,bx,by,700*k);fl.addColorStop(0,`rgba(255,220,170,${0.6*(1-since/0.3)})`);fl.addColorStop(1,'rgba(255,200,150,0)');ctx.fillStyle=fl;ctx.fillRect(0,0,cw,chh)} | |
| } | |
| function rings(src,t0,t1,col,maxR,every){if(t<t0)return;const until=Math.min(t,t1);for(let te=t0;te<=until;te+=every){const r=(t-te)*150;if(r>maxR||r<0)continue;const p=src(te);if(!p)continue; | |
| ctx.globalAlpha=(1-r/maxR)*.55;ctx.strokeStyle=col;ctx.lineWidth=1.4;ctx.beginPath();ctx.arc(X(p.x),Y(p.y),r*k,0,Math.PI*2);ctx.stroke()}ctx.globalAlpha=1} | |
| function diamond(x,y,r,fill){ctx.beginPath();ctx.moveTo(x,y-r);ctx.lineTo(x+r,y);ctx.lineTo(x,y+r);ctx.lineTo(x-r,y);ctx.closePath();if(fill)ctx.fill();else ctx.stroke()} | |
| function droneIcon(p){const x=X(p.x),y=Y(p.y),r=8*M();ctx.strokeStyle=C.off;ctx.lineWidth=2.2; | |
| ctx.beginPath();ctx.moveTo(x-r,y-r);ctx.lineTo(x+r,y+r);ctx.moveTo(x-r,y+r);ctx.lineTo(x+r,y-r);ctx.stroke();ctx.lineWidth=1.3; | |
| for(const[dx,dy]of[[-r,-r],[r,r],[-r,r],[r,-r]]){ctx.beginPath();ctx.arc(x+dx,y+dy,4*M(),t*20,t*20+4.2);ctx.stroke()}} | |
| function truck(p){const x=X(p.x),y=Y(p.y); | |
| const hl=ctx.createLinearGradient(x+18*k,y,x+150*k,y);hl.addColorStop(0,'rgba(255,236,180,.45)');hl.addColorStop(1,'rgba(255,236,180,0)');ctx.fillStyle=hl; | |
| ctx.beginPath();ctx.moveTo(x+17*k,y-4*k);ctx.lineTo(x+150*k,y-26*k);ctx.lineTo(x+150*k,y+26*k);ctx.lineTo(x+17*k,y+4*k);ctx.closePath();ctx.fill(); | |
| ctx.fillStyle='rgba(0,0,0,.45)';ctx.fillRect(x-16*k,y-5*k,36*k,14*k); | |
| ctx.fillStyle='#5b636b';ctx.fillRect(x-18*k,y-7*k,26*k,14*k);ctx.fillStyle='#7a838c';ctx.fillRect(x+9*k,y-6*k,9*k,12*k); | |
| ctx.fillStyle='rgba(255,240,200,.95)';ctx.fillRect(x+17*k,y-5*k,2*k,2.5*k);ctx.fillRect(x+17*k,y+2.5*k,2*k,2.5*k); | |
| ctx.fillStyle='rgba(255,40,30,.9)';ctx.fillRect(x-19*k,y-6*k,1.6*k,2.4*k);ctx.fillRect(x-19*k,y+3.6*k,1.6*k,2.4*k)} | |
| function draw(){ | |
| ctx.save();const bs=t-BOOM_T;if(bs>=0&&bs<0.5){const a=8*(1-bs/0.5)*k;ctx.translate((Math.sin(t*90)*a),(Math.cos(t*77)*a))} | |
| if(t>=T.fly2){const p2=drone2At(t)||{x:CP.x,y:CP.y+8};const z=1+2.2*sm(T.fly2,T.fly2+2.5,t);ctx.translate(cw/2,chh/2);ctx.scale(z,z);ctx.translate(-X(p2.x),-Y(p2.y))} | |
| ctx.drawImage(TER.c,0,0,cw,chh); | |
| ctx.strokeStyle='rgba(150,180,210,.07)';ctx.lineWidth=1;ctx.beginPath();for(let x=0;x<=W;x+=100){ctx.moveTo(X(x),0);ctx.lineTo(X(x),chh)}for(let y=0;y<=H;y+=100){ctx.moveTo(0,Y(y));ctx.lineTo(cw,Y(y))}ctx.stroke(); | |
| // village windows: some lit at night, all lit after the alert | |
| TER.houses.forEach((h,i)=>{const on=h.lit||(t>=T.alert&&t-T.alert>i*0.08);if(!on)return;const fl=.75+.25*Math.sin(t*1.3+h.ph); | |
| const wg=ctx.createRadialGradient(X(h.x),Y(h.y),0,X(h.x),Y(h.y),9*k);wg.addColorStop(0,`rgba(255,200,110,${0.55*fl})`);wg.addColorStop(1,'rgba(255,180,90,0)');ctx.fillStyle=wg;ctx.fillRect(X(h.x)-9*k,Y(h.y)-9*k,18*k,18*k); | |
| ctx.fillStyle=`rgba(255,214,140,${fl})`;ctx.fillRect(X(h.x)-1*k,Y(h.y)-1*k,2.2*k,2.2*k)}); | |
| if(t<4.5){ctx.globalAlpha=.5*(1-sm(3.5,4.5,t));ctx.setLineDash([4*k,6*k]);ctx.strokeStyle=C.green;S.forEach(s=>{ctx.beginPath();ctx.arc(X(s.x),Y(s.y),240*k,0,Math.PI*2);ctx.stroke()});ctx.setLineDash([]);ctx.globalAlpha=1} | |
| D.forEach(d=>{if(t<d.wake)return;const s=dish(d,t);if(!s.listen)return;const a=s.a*Math.PI/180,h=16*Math.PI/180,L=430; | |
| ctx.fillStyle='rgba(127,154,106,0.07)';ctx.strokeStyle='rgba(127,154,106,0.28)';ctx.lineWidth=1;ctx.beginPath();ctx.moveTo(X(d.x),Y(d.y)); | |
| ctx.arc(X(d.x),Y(d.y),L*k,a-h,a+h);ctx.closePath();ctx.fill();ctx.stroke()}); | |
| rings(vehAt,T.truck,T.truck+8.8,C.steel,300,0.5); | |
| if(t>=BOOM_T){const since=t-BOOM_T;drawBoom(since); | |
| for(let j=0;j<2;j++){const r=(since-j*0.15)*300;if(r>60&&r<620){ctx.globalAlpha=(1-r/620)*.45;ctx.strokeStyle=C.off;ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(X(BOOM.x),Y(BOOM.y),r*k,0,Math.PI*2);ctx.stroke();ctx.globalAlpha=1}}} | |
| rings(droneAt,T.drone,T.end,C.green,330,0.45); | |
| S.forEach((s,i)=>{const ph=((t+i*0.4)%1.4)/1.4;ctx.globalAlpha=(1-ph)*.6;ctx.strokeStyle=C.green;ctx.lineWidth=1.2;ctx.beginPath();ctx.arc(X(s.x),Y(s.y),(10+ph*30)*k,0,Math.PI*2);ctx.stroke();ctx.globalAlpha=1}); | |
| if(t>=T.wake&&t<39){const p=droneAt(t),s=S[0],a=sm(T.wake,T.wake+.6,t)*(1-sm(38,39,t));ctx.globalAlpha=a; | |
| const b=ang(s,p)*Math.PI/180;ctx.fillStyle='rgba(242,169,59,.10)';ctx.beginPath();ctx.moveTo(X(s.x),Y(s.y));ctx.arc(X(s.x),Y(s.y),dist(s,p)*1.15*k,b-0.12,b+0.12);ctx.closePath();ctx.fill(); | |
| ctx.strokeStyle=C.amber;ctx.setLineDash([6*k,5*k]);ctx.lineWidth=1.6;ctx.beginPath();ctx.moveTo(X(s.x),Y(s.y));ctx.lineTo(X(p.x),Y(p.y));ctx.stroke();ctx.setLineDash([]); | |
| for(let m=0;m<4;m++){const ma=m*Math.PI/2+Math.PI/4;ctx.fillStyle=C.amber;ctx.beginPath();ctx.arc(X(s.x+Math.cos(ma)*16),Y(s.y+Math.sin(ma)*16),2.5*M(),0,Math.PI*2);ctx.fill()}ctx.globalAlpha=1} | |
| D.forEach(d=>{const[a,b,src]=d.pk;if(t>=a&&t<=b+0.3){const u=clamp((t-a)/(b-a),0,1);ctx.strokeStyle='rgba(242,169,59,.35)';ctx.setLineDash([3*k,4*k]);ctx.beginPath();ctx.moveTo(X(src.x),Y(src.y));ctx.lineTo(X(d.x),Y(d.y));ctx.stroke();ctx.setLineDash([]); | |
| if(u<1){ctx.fillStyle=C.amber;diamond(X(src.x+(d.x-src.x)*u),Y(src.y+(d.y-src.y)*u),5*k,true)}}}); | |
| if(t>=T.tdoa&&t<48){const r=(t-T.tdoa)*VS,a=1-sm(47,48,t);if(r<700){ctx.globalAlpha=.8*a;ctx.strokeStyle=C.off;ctx.lineWidth=2;ctx.beginPath();ctx.arc(X(P.x),Y(P.y),r*k,0,Math.PI*2);ctx.stroke();ctx.globalAlpha=1} | |
| TN.forEach((n,i)=>{if(t>=tArr[i]){const since=t-tArr[i];if(since<0.6){ctx.globalAlpha=1-since/0.6;ctx.strokeStyle=C.off;ctx.beginPath();ctx.arc(X(n.x),Y(n.y),(8+since*40)*k,0,Math.PI*2);ctx.stroke();ctx.globalAlpha=1}}}); | |
| const cols=['#C9D6BE','#9FB38E','#D8DCD3'];curves.forEach((c,j)=>{const al=clamp((t-c.t0)/0.7,0,1)*a;if(al<=0)return;ctx.globalAlpha=al;ctx.strokeStyle=cols[j];ctx.lineWidth=1.8;ctx.beginPath(); | |
| for(let i=0;i<c.seg.length;i+=2){ctx.moveTo(X(c.seg[i][0]),Y(c.seg[i][1]));ctx.lineTo(X(c.seg[i+1][0]),Y(c.seg[i+1][1]))}ctx.stroke();ctx.globalAlpha=1}); | |
| if(t>=45.6){ctx.globalAlpha=a;ctx.strokeStyle=C.amber;ctx.lineWidth=2.2;ctx.beginPath();ctx.arc(X(P.x),Y(P.y),(14+4*Math.sin(t*6))*k,0,Math.PI*2);ctx.stroke();ctx.globalAlpha=1}} | |
| if(t>=T.track){const shown=FIX.filter(f=>f.t<=t);ctx.fillStyle=C.off;shown.forEach(f=>{ctx.globalAlpha=.65;diamond(X(f.z.x),Y(f.z.y),3*k,true)});ctx.globalAlpha=1; | |
| if(shown.length>1){ctx.strokeStyle=C.green;ctx.lineWidth=2.4;ctx.beginPath();shown.forEach((f,i)=>i?ctx.lineTo(X(f.est.x),Y(f.est.y)):ctx.moveTo(X(f.est.x),Y(f.est.y)));ctx.stroke()} | |
| const lf=shown[shown.length-1];if(lf){const na=D.filter(d=>t>=d.wake).length; | |
| const uncR=Math.max(4,lf.unc*(0.35+0.65*Math.min(1,na/6))); | |
| ctx.strokeStyle='rgba(238,240,234,.55)';ctx.setLineDash([3*k,4*k]);ctx.lineWidth=1.2;ctx.beginPath();ctx.arc(X(lf.est.x),Y(lf.est.y),uncR*k,0,Math.PI*2);ctx.stroke();ctx.setLineDash([]); | |
| if(shown.length>3){const ex=X(lf.est.x),ey=Y(lf.est.y),hx=ex+lf.vel.x*2.2*k,hy=ey+lf.vel.y*2.2*k,an=Math.atan2(hy-ey,hx-ex); | |
| ctx.strokeStyle=C.green;ctx.fillStyle=C.green;ctx.lineWidth=2.6;ctx.beginPath();ctx.moveTo(ex,ey);ctx.lineTo(hx,hy);ctx.stroke();ctx.beginPath();ctx.moveTo(hx,hy);ctx.lineTo(hx-11*Math.cos(an-.45),hy-11*Math.sin(an-.45));ctx.lineTo(hx-11*Math.cos(an+.45),hy-11*Math.sin(an+.45));ctx.fill(); | |
| ctx.strokeStyle=C.off;ctx.lineWidth=1.3;diamond(X(lf.est.x+lf.vel.x*0.6),Y(lf.est.y+lf.vel.y*0.6),5*k,false)}}} | |
| if(t>=T.alert){const ph=((t-T.alert)%1.2)/1.2;ctx.globalAlpha=(1-ph)*.8;ctx.strokeStyle=C.amber;ctx.lineWidth=2;ctx.beginPath();ctx.arc(X(VILLAGE.x+12),Y(VILLAGE.y+5),(18+ph*50)*k,0,Math.PI*2);ctx.stroke();ctx.globalAlpha=1; | |
| ctx.strokeStyle='rgba(242,169,59,.5)';ctx.setLineDash([5*k,5*k]);ctx.beginPath();ctx.moveTo(X(S[1].x),Y(S[1].y));ctx.lineTo(X(VILLAGE.x+12),Y(VILLAGE.y));ctx.moveTo(X(S[0].x),Y(S[0].y));ctx.lineTo(X(CP.x),Y(CP.y));ctx.stroke();ctx.setLineDash([]); | |
| const blink=Math.floor(t*3)%2===0;[[835,470],[905,470],[930,535]].forEach(([px,py])=>{ctx.fillStyle=C.off;ctx.fillRect(X(px),Y(py),9*k,15*k);ctx.fillStyle=blink?C.amber:'#5A4520';ctx.fillRect(X(px+1.5),Y(py+2),6*k,10*k)}); | |
| } | |
| if(t>=T.sens){ // end sequence: 12 -> 24 sensors deploy (live budget), camera zooms onto the inbound drone, precision circle shrinks with sensor count | |
| const dim2=sm(T.sens,T.sens+.6,t)*(1-sm(70.8,71.8,t)); | |
| scr(()=>{ctx.fillStyle=`rgba(8,17,27,${.45*dim2})`;ctx.fillRect(0,0,cw,chh)}); | |
| const lab1=sm(T.sens,T.sens+.5,t)*(1-sm(T.fly2,T.fly2+.6,t)); | |
| if(lab1>0)scr(()=>{ctx.globalAlpha=lab1;T1('1 · MORE SENSORS, MORE PRECISION — 12 → 24 PER ha · $40 each',500,96,16,C.off,'center',FD,800);ctx.globalAlpha=1}); | |
| let sd2=555;const sr2=()=>{sd2=(sd2*16807)%2147483647;return(sd2-1)/2147483646}; | |
| const nd=24;let shown=0; | |
| for(let i=0;i<nd;i++){const px=70+sr2()*860, py=120+sr2()*380; | |
| const a=i<12?sm(T.sens+0.4+i*0.15,T.sens+0.65+i*0.15,t):sm(T.fly2+0.5+(i-12)*0.42,T.fly2+0.8+(i-12)*0.42,t); | |
| if(a<=0)continue;shown=i+1; | |
| ctx.globalAlpha=a*dim2;ctx.fillStyle=C.green;ctx.beginPath();ctx.arc(X(px),Y(py),4*k,0,7);ctx.fill(); | |
| ctx.globalAlpha=a*dim2*(1-a);ctx.strokeStyle=C.green;ctx.lineWidth=1.4;ctx.beginPath();ctx.arc(X(px),Y(py),(4+10*(1-a))*k,0,7);ctx.stroke();ctx.globalAlpha=1} | |
| const nS=Math.min(nd,shown); | |
| scr(()=>{if(dim2>0){ctx.globalAlpha=dim2;T1('sensors '+nS+'/24 · $'+(nS*40)+' of $1,000 budget',500,582,13,C.green,'center',FM,700);ctx.globalAlpha=1}}); | |
| if(t>=T.fly2){ | |
| const lab2=sm(T.fly2,T.fly2+.6,t)*(1-sm(T.fire,T.fire+.4,t)); | |
| if(lab2>0)scr(()=>{ctx.globalAlpha=lab2;T1('2 · DRONE INBOUND — ZOOMING IN · AIR-DEFENCE TRACKS IT',500,96,16,C.amber,'center',FD,800);ctx.globalAlpha=1}); | |
| const p2=drone2At(t); | |
| const tp={x:CP.x,y:CP.y+8}; | |
| if(p2){const an=Math.atan2(p2.y-tp.y,p2.x-tp.x); | |
| ctx.save();ctx.translate(X(tp.x),Y(tp.y));ctx.rotate(an);ctx.fillStyle=C.amber;ctx.fillRect(0,-3*k,36*k,6*k);ctx.restore(); | |
| ctx.fillStyle='rgba(0,0,0,.45)';ctx.beginPath();ctx.ellipse(X(p2.x+9),Y(p2.y+12),11*M(),8*M(),0,0,Math.PI*2);ctx.fill(); | |
| droneIcon(p2); | |
| // precision circle shrinks as sensors grow 12 -> 24: > 1 m -> < 1 cm (projected) | |
| const pp=clamp((nS-12)/12,0,1),R=Math.max(5,90-85*pp); | |
| ctx.globalAlpha=dim2;ctx.strokeStyle=C.amber;ctx.lineWidth=2.2;ctx.beginPath();ctx.arc(X(p2.x),Y(p2.y),R*k,0,7);ctx.stroke(); | |
| [[0,-1],[0,1],[-1,0],[1,0]].forEach(([dx,dy])=>{ctx.beginPath();ctx.moveTo(X(p2.x+dx*R),Y(p2.y+dy*R));ctx.lineTo(X(p2.x+dx*(R+10)),Y(p2.y+dy*(R+10)));ctx.stroke()}); | |
| const m=Math.pow(0.01,pp);const lab=m>=1?'> 1 m':(m>=0.05?m.toFixed(2)+' m':'< 1 cm (projected)'); | |
| scr(()=>{ctx.globalAlpha=dim2;T1('targeting precision: '+lab+' · '+nS+' sensors',500,556,15,C.amber,'center',FM,700);ctx.globalAlpha=1});ctx.globalAlpha=1; | |
| } | |
| } | |
| } | |
| S.forEach(s=>{const hearing=(s===S[0]&&t>=27.5)||(s===S[2]&&t>=13&&t<19.5)||(s===S[1]&&((t>=21.2&&t<24)||t>=T.s2)); | |
| ctx.fillStyle=C.green;ctx.beginPath();ctx.arc(X(s.x),Y(s.y),8*M(),0,Math.PI*2);ctx.fill(); | |
| if(hearing){const dr=(s===S[0])||(s===S[1]&&t>=T.s2);ctx.strokeStyle=dr?C.amber:C.steel;ctx.lineWidth=2;ctx.beginPath();ctx.arc(X(s.x),Y(s.y),13*M(),0,Math.PI*2);ctx.stroke()} | |
| txt(s.id,s.x+14,s.y-10,C.green,11)}); | |
| D.forEach(d=>{const awake=t>=d.wake,s=dish(d,t),a=s.a*Math.PI/180,x=X(d.x),y=Y(d.y),r=6*M(),R=15*M(); | |
| ctx.globalAlpha=awake?1:.45;ctx.fillStyle='#22313F';ctx.fillRect(x-6*k,y+5*k,12*k,5*k); | |
| ctx.fillStyle=awake?C.off:C.steel;ctx.beginPath();ctx.arc(x,y,r,0,Math.PI*2);ctx.fill(); | |
| ctx.strokeStyle=awake?(s.turning?C.amber:C.off):C.steel;ctx.lineWidth=3;ctx.beginPath();ctx.arc(x-Math.cos(a)*4*k,y-Math.sin(a)*4*k,R,a-1.05,a+1.05);ctx.stroke(); | |
| ctx.lineWidth=1.5;ctx.beginPath();ctx.moveTo(x,y);ctx.lineTo(x+Math.cos(a)*R*.9,y+Math.sin(a)*R*.9);ctx.stroke(); | |
| txt(d.id,d.x+16,d.y+20,awake?C.off:C.steel,10);ctx.globalAlpha=1}); | |
| const v=vehAt(t);if(v)truck(v); | |
| const p=droneAt(t);if(p){ctx.fillStyle='rgba(0,0,0,.45)';ctx.beginPath();ctx.ellipse(X(p.x+9),Y(p.y+12),11*M(),8*M(),0,0,Math.PI*2);ctx.fill();droneIcon(p)} | |
| ctx.restore(); | |
| } | |
| // =================== PART 1 · how the model was built =================== | |
| const P1=44; | |
| const FD='"Archivo", system-ui, sans-serif',FM='"IBM Plex Mono", ui-monospace, monospace'; | |
| function T1(s,x,y,size,col,align,font,weight){ctx.font=`${weight||700} ${size*M()}px ${font||FM}`;ctx.textAlign=align||'left';ctx.fillStyle=col;ctx.fillText(s,X(x),Y(y))} | |
| function rrect(x,y,w,h,r){ctx.beginPath();ctx.roundRect?ctx.roundRect(X(x),Y(y),w*k,h*k,r*k):ctx.rect(X(x),Y(y),w*k,h*k)} | |
| const CLS=[['EXPLOSION','#F2A93B'],['DRONE_BUZZ','#7F9A6A'],['VEHICLE_MECH','#8D9AA8'],['AMBIENT','#9DB4C8']]; | |
| let ps=31;const PR=()=>{ps=(ps*16807)%2147483647;return(ps-1)/2147483646}; | |
| // class thumbnails (procedural spectrograms) | |
| const THUMB=CLS.map((c,ci)=>{const tc=document.createElement('canvas');tc.width=64;tc.height=32;const g=tc.getContext('2d'),im=g.createImageData(64,32); | |
| for(let x=0;x<64;x++)for(let y=0;y<32;y++){const b=31-y;let v=PR()*.15; | |
| if(ci===0)v+=(x>18&&x<28)?Math.exp(-(x-20)/4)*0.95:0; // EXPLOSION: sharp transient | |
| if(ci===1)for(let h=1;h<8;h++)v+=Math.exp(-((b-h*4)**2)/1.2)*(1-h*.08); // DRONE_BUZZ: harmonic comb | |
| if(ci===2)v+=Math.exp(-((b-5)**2)/9)*.8; // VEHICLE_MECH: low rumble band | |
| if(ci===3)v+=Math.exp(-((b-16)**2)/30)*.35*(0.6+0.4*PR()); // AMBIENT: broadband noise floor | |
| v=Math.min(1,v);const i=(y*64+x)*4;im.data[i]=13+v*225;im.data[i+1]=27+v*213;im.data[i+2]=42+v*192;im.data[i+3]=255} | |
| g.putImageData(im,0,0);return tc}); | |
| // 6 real architectures benchmarked on the unified dataset (leaderboard Tonic/challenge5-acoustic-results, 31 runs) | |
| // fields: FP32 size MB, params, CPU latency ms, challenge-valid wake F1, utility (best run per arch) | |
| const ARCH=[ | |
| {name:'GHOSTNET-0.5', mb:15.69, params:3907913, lat:10.38, f1:0.50, util:0.4625}, | |
| {name:'EFFNET-LITE0', mb:13.55, params:3377413, lat:4.92, f1:0.00, util:0.0000}, | |
| {name:'CNN6-CUSTOM', mb:10.37, params:2593413, lat:15.23, f1:0.00, util:0.0000}, | |
| {name:'MNV3-SMALL', mb:3.73, params:929893, lat:2.54, f1:0.50, util:0.4625}, | |
| {name:'SQUEEZENET1_1', mb:2.92, params:725061, lat:4.13, f1:0.80, util:0.7438}, | |
| {name:'SHUFFLENET-X0.5',mb:1.45, params:346917, lat:2.61, f1:0.67, util:0.6479}, | |
| ].map((a,i)=>{const n=4+(i*7)%5;a.L=[...Array(n)].map((_,j)=>.3+.6*Math.abs(Math.sin(i*2.1+j*.9)));a.score=a.util;return a}); | |
| const BEST=[4,4]; // squeezenet1_1 seed 7 — the actual wave-3 winner (wake F1 0.80, acc 0.875, camera off 62.5%) | |
| const ARCCOL=['#C8B98F','#9DB4C8','#8D9AA8','#F2A93B','#7F9A6A','#A88DD9']; // per ARCH index | |
| // all 31 leaderboard runs, sorted by utility desc: [archIdx, seed, validF1, utility] | |
| const RUNS=[[4,7,.80,.7438],[5,42,.6667,.6479],[5,42,.6667,.6479],[0,42,.5,.4625],[4,42,.5,.4625],[3,7,.5,.4625],[4,7,.5,.4625],[4,42,.5,.4625],[3,42,.5,.4625],[2,0,0,0],[2,42,0,0],[1,42,0,0],[1,7,0,0],[3,42,0,0],[5,7,0,0],[5,7,0,0],[5,42,0,0],[3,42,0,0],[4,7,.5,0],[4,42,.5,0],[3,7,0,0],[3,42,.5,0],[5,7,0,0],[5,7,0,0],[5,42,.6667,0],[0,7,0,-.0187],[3,7,0,-.0187],[4,42,0,-.0187],[2,7,0,-.0375],[4,7,0,-.0375],[3,7,0,-.0375]]; | |
| function globe(x,y,r){ctx.strokeStyle=C.off;ctx.lineWidth=1.6;ctx.beginPath();ctx.arc(X(x),Y(y),r*k,0,7);ctx.stroke();ctx.beginPath();ctx.ellipse(X(x),Y(y),r*.45*k,r*k,0,0,7);ctx.stroke(); | |
| ctx.beginPath();ctx.moveTo(X(x-r),Y(y));ctx.lineTo(X(x+r),Y(y));ctx.moveTo(X(x-r*.85),Y(y-r*.5));ctx.lineTo(X(x+r*.85),Y(y-r*.5));ctx.moveTo(X(x-r*.85),Y(y+r*.5));ctx.lineTo(X(x+r*.85),Y(y+r*.5));ctx.stroke()} | |
| function gen(x,y,r,u){ctx.strokeStyle=C.off;ctx.lineWidth=1.6;rrect(x-r,y-r,2*r,2*r,6);ctx.stroke();ctx.beginPath();for(let i=0;i<=20;i++){const px=x-r*.75+i*(r*1.5/20),py=y+Math.sin(i*.9+u*8)*r*.45*Math.sin(i/20*Math.PI);i?ctx.lineTo(X(px),Y(py)):ctx.moveTo(X(px),Y(py))}ctx.strokeStyle=C.green;ctx.stroke()} | |
| const fmtMB=mb=>mb<1000?Math.round(mb)+' MB':(mb/1000).toFixed(mb<10000?1:0)+' GB'; | |
| function sceneData(u){ | |
| const cx=520,cy=300,R=170,g=sm(4.5,8.6,u),mb=Math.exp(Math.log(18)+(Math.log(22000)-Math.log(18))*g),r=Math.max(5,R*Math.sqrt(mb/22000)); | |
| // typical dataset ring | |
| const ra=sm(2,3,u);if(ra>0){ctx.globalAlpha=ra;ctx.setLineDash([6*k,6*k]);ctx.strokeStyle=C.steel;ctx.lineWidth=1.5;ctx.beginPath();ctx.arc(X(cx),Y(cy),R*Math.sqrt(2.2/22)*k,0,7);ctx.stroke();ctx.setLineDash([]); | |
| T1('2.2 GB',cx+R*Math.sqrt(2.2/22)+10,cy-R*Math.sqrt(2.2/22)+4,15,C.steel);T1('TYPICAL',cx+R*Math.sqrt(2.2/22)+10,cy-R*Math.sqrt(2.2/22)+22,10,C.steel,'left',FM,500);ctx.globalAlpha=1} | |
| // streams | |
| if(u>4.2&&u<9){const src=[[150,180],[150,430]];for(let i=0;i<70;i++){const ph=((u*0.9+i*0.137)%1),s=src[i%2],c=CLS[i%CLS.length][1]; | |
| const x=s[0]+(cx-s[0])*ph+Math.sin(ph*Math.PI)*(i%2?-40:40)*0,y=s[1]+(cy-s[1])*ph-Math.sin(ph*Math.PI)*(i%2?-60:60); | |
| if(u>8.6&&ph>.9)continue;ctx.globalAlpha=Math.sin(ph*Math.PI)*sm(4.2,5,u)*(1-sm(8.6,9,u));ctx.fillStyle=c;ctx.fillRect(X(x)-3*k,Y(y)-2*k,6*k,4*k)}ctx.globalAlpha=1; | |
| const ia=sm(4,4.8,u);ctx.globalAlpha=ia;globe(150,180,26);gen(150,430,26,u);T1('INTERNET',150,228,11,C.off,'center',FM,600);T1('GENERATED',150,478,11,C.off,'center',FM,600);ctx.globalAlpha=1} | |
| // data sphere | |
| const gr=ctx.createRadialGradient(X(cx-r*.3),Y(cy-r*.3),r*.1*k,X(cx),Y(cy),r*k);gr.addColorStop(0,'#a9c294');gr.addColorStop(1,'#3e5233'); | |
| ctx.fillStyle=gr;ctx.beginPath();ctx.arc(X(cx),Y(cy),r*k,0,7);ctx.fill(); | |
| if(r>40){ctx.save();ctx.beginPath();ctx.arc(X(cx),Y(cy),r*k,0,7);ctx.clip();ctx.globalAlpha=.18;for(let i=0;i<40;i++){const a=i*2.39,d=Math.sqrt(i/40)*r;ctx.drawImage(THUMB[i%THUMB.length],X(cx+Math.cos(a)*d)-16*k,Y(cy+Math.sin(a)*d)-8*k,32*k,16*k)}ctx.restore();ctx.globalAlpha=1} | |
| // numbers | |
| T1(fmtMB(mb),780,cy-6,58,C.off,'left',FD,800); | |
| T1(g<0.02?'CHALLENGE DATA':g<.98?'COLLECTING + GENERATING':'OUR DATASET',782,cy+22,12,g>.98?C.green:C.steel,'left',FM,600); | |
| if(g>.98){ctx.globalAlpha=sm(8.6,9,u);T1('×1,200',782,cy+70,30,C.amber,'left',FD,800);ctx.globalAlpha=1} | |
| } | |
| function sceneMix(v){ | |
| CLS.forEach(([name,col],ci)=>{const x=200+ci*200; | |
| for(let j=0;j<8;j++){const st=0.15*(ci*8+j)/8+j*0.12,p=sm(st,st+1.2,v),tx=x-34+(j%2)*36,ty=150+Math.floor(j/2)*42,sx0=520,sy0=300; | |
| const xx=sx0+(tx-sx0)*p,yy=sy0+(ty-sy0)*p;ctx.globalAlpha=Math.min(1,p*1.5);ctx.drawImage(THUMB[ci],X(xx),Y(yy),32*k,32*k*0.5*1.8);ctx.strokeStyle=col;ctx.lineWidth=1;ctx.strokeRect(X(xx),Y(yy),32*k,32*k*0.9)} | |
| ctx.globalAlpha=sm(1,2,v);ctx.fillStyle=col;ctx.fillRect(X(x-34),Y(330),68*k,3*k);T1(name,x,358,13,col,'center',FM,600);ctx.globalAlpha=1}); | |
| ctx.globalAlpha=sm(2.5,3.5,v);T1('4 SOUND CLASSES',520,436,14,C.off,'center',FM,600);T1('WAKE F1 0.80 · CLASS ACC 0.875 · CAMERA OFF 62.5% · 4.13 ms CPU',520,462,11,C.green,'center',FM,600);T1('22 GB',520,505,40,C.off,'center',FD,800);ctx.globalAlpha=1; | |
| } | |
| function sceneModels(v){ | |
| T1('6',56,46,34,C.off,'left',FD,800);T1('ARCHITECTURES · 31 RUNS BENCHMARKED',118,46,12,C.steel,'left',FM,600); | |
| const cwd=290,chg=170,gapx=24,gapy=14,x0=40,y0=84; | |
| const pSel=sm(4.4,5.0,v), pInfo=sm(7.0,8.0,v); | |
| ARCH.forEach((a,i)=>{const col=i%3,row=Math.floor(i/3),x=x0+col*(cwd+gapx),y=y0+row*(chg+gapy),win=BEST.includes(i); | |
| const appear=sm(i*0.12,i*0.12+.7,v), hl=win?pSel:0; | |
| ctx.globalAlpha=Math.min(1,appear); | |
| ctx.fillStyle='#10202F';rrect(x,y,cwd,chg,6);ctx.fill(); | |
| ctx.strokeStyle=win?C.green:ARCCOL[i];ctx.lineWidth=win?1+2.4*hl:1.4;rrect(x,y,cwd,chg,6);ctx.stroke(); | |
| if(win&&hl>0){ctx.save();ctx.shadowColor=C.green;ctx.shadowBlur=24*hl*k;ctx.strokeStyle=C.green;ctx.lineWidth=2.5;rrect(x-4*hl,y-4*hl,cwd+8*hl,chg+8*hl,8);ctx.stroke();ctx.restore();} | |
| // visual element: per-arch network diagram (layers x nodes, node size = layer width) | |
| const nl=a.L.length,ny=5,nx0=x+34,nx1=x+cwd-34,ny0=y+24,ny1=y+chg-46; | |
| ctx.strokeStyle='rgba(141,154,168,.30)';ctx.lineWidth=1; | |
| for(let j=0;j<nl;j++){const px=nx0+(nx1-nx0)*(nl===1?0:j/(nl-1)); | |
| for(let q=0;q<ny;q++){const py=ny0+(ny1-ny0)*q/(ny-1); | |
| if(j<nl-1){const px2=nx0+(nx1-nx0)*(j+1)/(nl-1); | |
| for(let q2=0;q2<ny;q2++){const py2=ny0+(ny1-ny0)*q2/(ny-1); | |
| ctx.beginPath();ctx.moveTo(X(px),Y(py));ctx.lineTo(X(px2),Y(py2));ctx.stroke();}}}} | |
| for(let j=0;j<nl;j++){const px=nx0+(nx1-nx0)*(nl===1?0:j/(nl-1)); | |
| for(let q=0;q<ny;q++){const py=ny0+(ny1-ny0)*q/(ny-1); | |
| ctx.fillStyle=win&&hl>0?C.green:ARCCOL[i]; | |
| ctx.beginPath();ctx.arc(X(px),Y(py),Math.max(1.6,(2+a.L[j]*3.2))*k,0,7);ctx.fill();}} | |
| // minimal text: just the architecture name | |
| T1(a.name,x+12,y+chg-14,12,win&&hl>0?C.green:C.off,'left',FM,700); | |
| if(win&&hl>0){ctx.fillStyle=C.green;rrect(x+cwd-96,y+10,88,24,5);ctx.fill();T1('SELECTED',x+cwd-52,y+27,11,C.navy,'center',FM,700);} | |
| ctx.globalAlpha=1}); | |
| // after the pick: info panel slides in below; all six cards remain visible | |
| if(pInfo>0){const a=ARCH[BEST[0]],py=452+(1-pInfo)*30; | |
| ctx.globalAlpha=pInfo; | |
| ctx.fillStyle='#10202F';rrect(30,py,940,128,8);ctx.fill();ctx.strokeStyle=C.green;ctx.lineWidth=2;rrect(30,py,940,128,8);ctx.stroke(); | |
| ctx.fillStyle=C.green;rrect(46,py+16,104,26,5);ctx.fill();T1('SELECTED',98,py+34,12,C.navy,'center',FM,700); | |
| T1(a.name+' · SEED 7',170,py+40,20,C.green,'left',FD,800); | |
| T1(a.mb.toFixed(2)+' MB FP32 · '+(a.params/1000).toFixed(0)+'K PARAMS · '+a.lat.toFixed(2)+' ms CPU',170,py+70,13,C.off,'left',FM,600); | |
| T1('WAKE F1 0.80 · ACC 0.875 · CAMERA OFF 62.5% · UTILITY 0.744',170,py+98,13,C.off,'left',FM,600); | |
| T1('BEST OF 31 RUNS · 6 ARCHITECTURES',952,py+40,12,C.steel,'right',FM,600); | |
| ctx.globalAlpha=1;} | |
| } | |
| function sceneEdge(v){ | |
| // left: microchip; one model icon flies in from the left; right: size-shrink spheres | |
| const cx=240,cy=290,s=180;ctx.fillStyle='#13212E';rrect(cx-s/2,cy-s/2,s,s,10);ctx.fill();ctx.strokeStyle=C.steel;ctx.lineWidth=2;rrect(cx-s/2,cy-s/2,s,s,10);ctx.stroke(); | |
| ctx.strokeStyle=C.steel;ctx.lineWidth=2;for(let i=0;i<9;i++){const o=-s/2+20+i*20;[[cx+o,cy-s/2,cx+o,cy-s/2-14],[cx+o,cy+s/2,cx+o,cy+s/2+14],[cx-s/2,cy+o,cx-s/2-14,cy+o],[cx+s/2,cy+o,cx+s/2+14,cy+o]].forEach(([a,b,c2,d])=>{ctx.beginPath();ctx.moveTo(X(a),Y(b));ctx.lineTo(X(c2),Y(d));ctx.stroke()})} | |
| {const p=sm(0.3,2.4,v),mx0=-80,tx=cx,x=mx0+(tx-mx0)*p,y=cy-10; | |
| const enter=sm(2.0,2.4,v); | |
| ctx.globalAlpha=1-enter; | |
| ctx.fillStyle=C.green;rrect(x-36,y-40,72,80,6);ctx.fill();ARCH[BEST[0]].L.forEach((h,i,L)=>{ctx.fillStyle=C.navy;ctx.fillRect(X(x-28+i*(56/L.length)),Y(y+20-h*40),Math.max(1,56/L.length-3)*k,h*40*k)}); | |
| ctx.globalAlpha=1; | |
| T1('MODEL',60,cy+70,10,C.steel,'center',FM,500); | |
| if(enter>0){ctx.globalAlpha=enter*.55;ctx.fillStyle=C.green;rrect(cx-s/2+10,cy-s/2+10,s-20,s-20,8);ctx.fill();ctx.globalAlpha=1;}} | |
| T1('EDGE AI',cx,cy+s/2-18,12,C.steel,'center',FM,600); | |
| ctx.strokeStyle=C.rule;ctx.setLineDash([4*k,6*k]);ctx.lineWidth=1.4;ctx.beginPath();ctx.moveTo(X(cx+s/2+14),Y(cy));ctx.lineTo(X(648),Y(cy));ctx.stroke();ctx.setLineDash([]); | |
| // model-size shrink shown as spheres (area ~ size): largest trained FP32 -> selected arch -> INT8 (real sizes, MB) | |
| const SIZES=[[15.69,'GHOSTNET FP32'],[13.55,'EFFNET-LITE0'],[10.37,'CNN6'],[3.73,'MNV3-SMALL'],[2.92,'SQUEEZENET FP32 · SELECTED'],[1.45,'SHUFFLENET FP32'],[0.81,'INT8 ONNX · POST-TRAINING QUANT · 725K PARAMS']]; | |
| const g=sm(1.0,8.8,v),n=SIZES.length,u=clamp(g*(n-1),0,n-1),si=Math.floor(u),sf=u-si; | |
| const mb=SIZES[si][0]+(SIZES[Math.min(si+1,n-1)][0]-SIZES[si][0])*sf, lab=SIZES[si][1]; | |
| const R0=78, r=Math.max(5,R0*Math.sqrt(mb/SIZES[0][0])), sx=740, sy=285; | |
| ctx.globalAlpha=sm(.6,1.2,v)*.9;ctx.strokeStyle=C.steel;ctx.setLineDash([6*k,6*k]);ctx.lineWidth=1.6;ctx.beginPath();ctx.arc(X(sx),Y(sy),R0*k,0,7);ctx.stroke();ctx.setLineDash([]); | |
| T1('ORIGINAL 15.7 MB',sx,sy-R0-12,11,C.steel,'center',FM,500);ctx.globalAlpha=1; | |
| const gr2=ctx.createRadialGradient(X(sx-r*.3),Y(sy-r*.3),r*.1*k,X(sx),Y(sy),r*k);gr2.addColorStop(0,'#a9c294');gr2.addColorStop(1,'#3e5233'); | |
| ctx.fillStyle=gr2;ctx.beginPath();ctx.arc(X(sx),Y(sy),r*k,0,7);ctx.fill(); | |
| ctx.strokeStyle=C.amber;ctx.lineWidth=2;ctx.beginPath();ctx.arc(X(sx),Y(sy),r*k,0,7);ctx.stroke(); | |
| T1(mb.toFixed(2)+' MB',560,430,24,si===n-1?C.amber:C.off,'left',FD,800); | |
| T1(lab,560,456,12,si===n-1?C.amber:C.green,'left',FM,600); | |
| T1('MODEL SIZE',950,456,11,C.steel,'right',FM,600); | |
| if(si===n-1){ctx.globalAlpha=sm(8.2,9.0,v);T1('−95% VS ORIGINAL · INT8 ONNX 0.81 MB < INT8 TFLITE 2.97 MB',560,482,11,C.amber,'left',FM,700);ctx.globalAlpha=1} | |
| } | |
| const OUTS=[['Altitude','alt'],['Yaw','yaw'],['Speed','spd'],['Distance','dst'],['Position','pos']]; | |
| function sceneOutputs(v){ | |
| ctx.globalAlpha=sm(0,.6,v);ctx.drawImage(THUMB[1],X(40),Y(250),150*k,100*k);ctx.strokeStyle=C.green;ctx.lineWidth=1.5;ctx.strokeRect(X(40),Y(250),150*k,100*k);T1('AUDIO',115,375,11,C.steel,'center',FM,600); | |
| ctx.strokeStyle=C.off;ctx.lineWidth=2;ctx.beginPath();ctx.moveTo(X(200),Y(300));ctx.lineTo(X(250),Y(300));ctx.stroke(); | |
| ctx.fillStyle=C.green;rrect(255,215,110,170,8);ctx.fill();ARCH[BEST[0]].L.forEach((h,i,L)=>{ctx.fillStyle=C.navy;ctx.fillRect(X(268+i*(84/L.length)),Y(340-h*90),Math.max(1,84/L.length-4)*k,h*90*k)});ctx.globalAlpha=1; | |
| T1('Detectonic MODEL',310,405,11,C.green,'center',FM,600); | |
| const probs=[.02,.94,.03,.01]; | |
| CLS.forEach(([name,col],i)=>{const y=70+i*100,p=sm(1+i*.3,1.6+i*.3,v);ctx.globalAlpha=p; | |
| ctx.strokeStyle='rgba(238,240,234,.25)';ctx.lineWidth=1;ctx.beginPath();ctx.moveTo(X(365),Y(300));ctx.bezierCurveTo(X(420),Y(300),X(420),Y(y),X(470),Y(y));ctx.stroke(); | |
| T1(name,480,y-6,12,col,'left',FM,600);ctx.fillStyle=C.rule;ctx.fillRect(X(480),Y(y+4),190*k,8*k);ctx.fillStyle=col;ctx.fillRect(X(480),Y(y+4),190*k*probs[i]*sm(1.3+i*.3,2.4+i*.3,v),8*k); | |
| T1((probs[i]*sm(1.3+i*.3,2.4+i*.3,v)).toFixed(2),680,y+13,11,C.off,'left',FM,500);ctx.globalAlpha=1}); | |
| OUTS.forEach(([name,kind],i)=>{const y=70+i*100,x=800,p=sm(2.6+i*.3,3.1+i*.3,v),q=sm(2.9+i*.3,4.3+i*.3,v);if(p<=0)return;ctx.globalAlpha=p; | |
| ctx.strokeStyle='rgba(238,240,234,.25)';ctx.lineWidth=1;ctx.beginPath();ctx.moveTo(X(365),Y(300));ctx.bezierCurveTo(X(600),Y(300),X(650),Y(y),X(752),Y(y));ctx.stroke(); | |
| ctx.strokeStyle=C.off;ctx.fillStyle=C.off;ctx.lineWidth=1.6;let val=''; | |
| if(kind==='alt'){ctx.strokeRect(X(x-36),Y(y-30),8*k,56*k);const hh=56*0.62*q;ctx.fillStyle=C.green;ctx.fillRect(X(x-36),Y(y+26-hh),8*k,hh*k);val=Math.round(120*q)+' m'} | |
| if(kind==='yaw'){ctx.beginPath();ctx.arc(X(x-32),Y(y),24*k,0,7);ctx.stroke();const a=(-90+214*q)*Math.PI/180;ctx.strokeStyle=C.amber;ctx.beginPath();ctx.moveTo(X(x-32),Y(y));ctx.lineTo(X(x-32+Math.cos(a)*20),Y(y+Math.sin(a)*20));ctx.stroke();val=Math.round(214*q)+'°'} | |
| if(kind==='spd'){ctx.beginPath();ctx.arc(X(x-32),Y(y+10),24*k,Math.PI,2*Math.PI);ctx.stroke();const a=Math.PI+Math.PI*0.45*q+Math.sin(t*3)*.03;ctx.strokeStyle=C.amber;ctx.beginPath();ctx.moveTo(X(x-32),Y(y+10));ctx.lineTo(X(x-32+Math.cos(a)*20),Y(y+10+Math.sin(a)*20));ctx.stroke();val=Math.round(18*q)+' m/s'} | |
| if(kind==='dst'){for(const r of[8,16,24]){ctx.beginPath();ctx.arc(X(x-32),Y(y),r*k,0,7);ctx.stroke()}ctx.fillStyle=C.amber;ctx.beginPath();ctx.arc(X(x-32+17*q),Y(y-12*q),3.5*M(),0,7);ctx.fill();val=Math.round(350*q)+' m'} | |
| if(kind==='pos'){ctx.strokeRect(X(x-56),Y(y-24),48*k,48*k);ctx.beginPath();ctx.moveTo(X(x-32),Y(y-24));ctx.lineTo(X(x-32),Y(y+24));ctx.moveTo(X(x-56),Y(y));ctx.lineTo(X(x-8),Y(y));ctx.stroke();ctx.fillStyle=C.amber;ctx.beginPath();ctx.arc(X(x-32+10*q),Y(y-8*q),4*M(),0,7);ctx.fill();val='x '+Math.round(412*q)+' · y '+Math.round(268*q)} | |
| T1(name.toUpperCase(),x+8,y-6,12,C.steel,'left',FM,600);T1(val,x+8,y+18,18,C.off,'left',FD,800);ctx.globalAlpha=1}); | |
| } | |
| function sceneCost(v){ | |
| T1('COST PER UNIT',500,120,22,C.off,'center',FD,800); | |
| const p=sm(.4,2.2,v); | |
| ctx.fillStyle=C.rule;ctx.fillRect(X(200),Y(190),600*k,36*k);ctx.fillStyle=C.amber;ctx.fillRect(X(200),Y(190),600*k*p,36*k); | |
| T1('EXISTING C-UAS SOLUTIONS (theirs)',200,178,12,C.steel,'left',FM,600);T1('$600+',812,216,17,C.amber,'left',FM,700); | |
| const q=sm(2.2,3.8,v); | |
| ctx.fillStyle=C.rule;ctx.fillRect(X(200),Y(270),600*k,36*k);ctx.fillStyle=C.green;ctx.fillRect(X(200),Y(270),600*k*(40/600)*q,36*k); | |
| T1('Detectonic BOM (ours)',200,258,12,C.steel,'left',FM,600);T1('$40',252,296,17,C.green,'left',FM,700); | |
| const b=sm(4.0,5.2,v); | |
| if(b>0){ctx.globalAlpha=b;ctx.fillStyle=C.green;rrect(690,330,200,32,6);ctx.fill();T1('15× CHEAPER',790,352,14,'#08111B','center',FM,700);ctx.globalAlpha=1} | |
| T1('complements existing systems — no rip-and-replace',500,430,13,C.green,'center',FM,600); | |
| } | |
| function sceneSota(v){ | |
| // headline on its own line, subtitle below | |
| const ha=sm(0,.7,v); | |
| ctx.globalAlpha=ha;T1('SOTA',500,138,96,C.off,'center',FD,800);ctx.globalAlpha=1; | |
| ctx.globalAlpha=sm(.5,1.1,v);T1('31 RUNS · 6 ARCHITECTURES · 22 GB UNIFIED ACOUSTIC BENCHMARK',500,182,14,C.green,'center',FM,600);ctx.globalAlpha=1; | |
| // per-arch best bars from the real leaderboard, ordered by utility desc | |
| const order=[...ARCH.keys()].sort((a,b)=>ARCH[b].util-ARCH[a].util); | |
| const x0=330,bw=470,umax=ARCH[4].util,y0=224,rh=50; | |
| order.forEach((ai,i)=>{const a=ARCH[ai],win=BEST.includes(ai); | |
| const g=sm(1.2+i*.45,2.0+i*.45,v),bwv=bw*(a.util/umax)*g; | |
| const y=y0+i*rh; | |
| ctx.globalAlpha=sm(1.2+i*.45,1.6+i*.45,v); | |
| T1(a.name,60,y+22,13,win?C.green:C.steel,'left',FM,700); | |
| ctx.fillStyle='#1A2836';ctx.fillRect(X(x0),Y(y),bw*k,30*k); | |
| if(bwv>0){ctx.fillStyle=win?C.green:ARCCOL[ai]; | |
| if(win){ctx.save();ctx.shadowColor=C.green;ctx.shadowBlur=16*g*k;ctx.fillRect(X(x0),Y(y),bwv*k,30*k);ctx.restore();} | |
| else ctx.fillRect(X(x0),Y(y),bwv*k,30*k);} | |
| T1(a.util.toFixed(3)+' · F1 '+a.f1.toFixed(2),x0+bw+14,y+22,12,win?C.green:C.off,'left',FM,600); | |
| if(win&&g>.9){ctx.fillStyle=C.green;rrect(x0-92,y+4,80,22,5);ctx.fill();T1('OURS',x0-52,y+20,11,C.navy,'center',FM,700);} | |
| ctx.globalAlpha=1}); | |
| // runs count-up | |
| ctx.globalAlpha=sm(1.2,4.5,v);T1(Math.round(sm(1.2,4.5,v)*31)+' runs benchmarked',940,60,12,C.steel,'right',FM,600);ctx.globalAlpha=1; | |
| if(v>6.8){ctx.fillStyle=`rgba(8,17,27,${sm(6.8,7.8,v)})`;ctx.fillRect(0,0,cw,chh)} | |
| } | |
| const LOGOIMG=new Image();LOGOIMG.src='detectonic-logo.png'; | |
| function drawLogo(a){ctx.fillStyle='#08111B';ctx.fillRect(0,0,cw,chh); | |
| if(a<=0)return; | |
| // title screen: icon (logo is image-only now) + DETECTONIC wordmark drawn as text | |
| if(LOGOIMG.complete&&LOGOIMG.naturalWidth){ctx.globalAlpha=clamp(a,0,1);const w=Math.min(300,cw*.3),h=w*LOGOIMG.naturalHeight/LOGOIMG.naturalWidth;ctx.drawImage(LOGOIMG,(cw-w)/2,chh/2-h/2-86*k,w,h);ctx.globalAlpha=1} | |
| ctx.globalAlpha=clamp(a,0,1); | |
| T1('DETECTONIC',W/2,H/2+78,64,C.off,'center',FD,800); | |
| T1('acoustic drone detection · edge-first',W/2,H/2+118,15,C.steel,'center',FM,600); | |
| ctx.globalAlpha=1} | |
| function drawSegue(v){ // cost segue over the quiet map: theirs $600+ vs our $40 BOM, volunteers build them, ours/theirs meaning | |
| draw(); | |
| const a=sm(0,.35,v);if(a<=0)return; | |
| scr(()=>{ctx.fillStyle=`rgba(8,17,27,${.84*a})`;ctx.fillRect(0,0,cw,chh)}); | |
| ctx.globalAlpha=a; | |
| T1('SAME BUDGET · MORE SENSORS',500,84,22,C.off,'center',FD,800); | |
| const p=sm(.05,.28,v); | |
| ctx.fillStyle=C.rule;ctx.fillRect(X(220),Y(140),560*k,34*k);ctx.fillStyle=C.amber;ctx.fillRect(X(220),Y(140),560*k*p,34*k); | |
| T1('EXISTING C-UAS · theirs',220,128,12,C.steel,'left',FM,600);T1('$600+ / unit',792,166,16,C.amber,'left',FM,700); | |
| const q=sm(.28,.48,v); | |
| ctx.fillStyle=C.rule;ctx.fillRect(X(220),Y(214),560*k,34*k);ctx.fillStyle=C.green;ctx.fillRect(X(220),Y(214),560*k*(40/600)*q,34*k); | |
| T1('Detectonic BOM · ours',220,202,12,C.steel,'left',FM,600);T1('$40 / unit',232,240,16,C.green,'left',FM,700); | |
| const b=sm(.48,.6,v); | |
| if(b>0){ctx.globalAlpha=a*b;ctx.fillStyle=C.green;rrect(648,282,222,32,6);ctx.fill();T1('15× CHEAPER',759,304,14,'#08111B','center',FM,700);ctx.globalAlpha=a} | |
| const m=sm(.58,.7,v); | |
| if(m>0){ctx.globalAlpha=a*m;T1('$1,000 buys 1× theirs → 25+ Detectonic sensors per hectare',500,372,15,C.off,'center',FM,700);ctx.globalAlpha=a} | |
| const fade=1-sm(.66,.78,v); | |
| if(fade>0){ctx.globalAlpha=a*fade; | |
| ctx.fillStyle='#5C6E7F';ctx.fillRect(X(180),Y(428),110*k,70*k); | |
| ctx.fillRect(X(198),Y(392),16*k,40*k);ctx.fillRect(X(232),Y(384),16*k,48*k); | |
| ctx.strokeStyle='rgba(141,154,168,.7)';ctx.lineWidth=2;ctx.beginPath();ctx.moveTo(X(207),Y(386));ctx.quadraticCurveTo(X(196),Y(364),X(210),Y(350));ctx.stroke(); | |
| T1('FACTORY REQUIRED',235,524,C.steel,11,'center',FM,600);ctx.globalAlpha=a} | |
| const ap=sm(.68,.78,v); | |
| ctx.strokeStyle=C.amber;ctx.lineWidth=3;ctx.beginPath();ctx.moveTo(X(320),Y(463));ctx.lineTo(X(320+200*ap),Y(463));ctx.stroke(); | |
| if(ap>.9){ctx.fillStyle=C.amber;ctx.beginPath();ctx.moveTo(X(522),Y(463));ctx.lineTo(X(506),Y(455));ctx.lineTo(X(506),Y(471));ctx.fill()} | |
| const hp=sm(.76,.88,v); | |
| if(hp>0){ctx.globalAlpha=a*hp;const hx=720,hy=458; | |
| ctx.fillStyle='#7F9A6A';ctx.beginPath();ctx.moveTo(X(hx-60),Y(hy-10));ctx.lineTo(X(hx),Y(hy-60));ctx.lineTo(X(hx+60),Y(hy-10));ctx.closePath();ctx.fill(); | |
| ctx.fillStyle='#22313F';ctx.fillRect(X(hx-48),Y(hy-10),96*k,60*k); | |
| ctx.fillStyle=C.amber;ctx.fillRect(X(hx-12),Y(hy+8),24*k,22*k); | |
| for(let vgi=0;vgi<3;vgi++){const vx=hx-28+vgi*28;ctx.fillStyle=C.off;ctx.beginPath();ctx.arc(X(vx),Y(hy+62),5*k,0,7);ctx.fill();ctx.fillStyle=C.green;rrect(vx-7,hy+68,14,18,4);ctx.fill()} | |
| T1('VOLUNTEERS ASSEMBLE THEM AT HOME',hx,hy+106,C.green,11,'center',FM,600); | |
| T1('same $40 BOM · no factory needed',hx,hy+124,C.steel,10,'center',FM,500);ctx.globalAlpha=a} | |
| ctx.globalAlpha=1; | |
| } | |
| // =================== PERF · on-device latency clock (73.1 s -> 0.70 s per 5-s window) =================== | |
| // measured on ESP32-S31 @ 320 MHz over the 56 challenge clips, 56/56 decision parity vs float ONNX | |
| // (run_m7.log kernel ladder + board_sweep_sizes.py / board_sweep_xiao.py) | |
| const PERF_MS=[ | |
| {v:900, lab:'STOCK INT8 TFLM', sub:'> 15 min per window — unusable', col:'#8D9AA8'}, | |
| {v:73.1, lab:'TFLM FLOAT32', sub:'73.1 s — first working on-device run', col:'#F2A93B'}, | |
| {v:21.6, lab:'CUSTOM IM2COL-GEMM', sub:'21.6 s — hand-written RISC-V GEMM', col:'#F2A93B'}, | |
| {v:1.971,lab:'ESP-NN CONV (M3)', sub:'1.97 s — vendor riscv_pie kernels', col:'#EEF0EA'}, | |
| {v:1.434,lab:'+ CUSTOM SUB/MUL (M4)', sub:'1.43 s — custom elementwise kernels', col:'#EEF0EA'}, | |
| {v:1.311,lab:'FUSED GRAPH (M7)', sub:'1.31 s — deployed model @224', col:'#7F9A6A'}, | |
| {v:0.701,lab:'SQUEEZENET1.1 @128', sub:'0.70 s — SUB-SECOND', col:'#7F9A6A'}]; | |
| const PERF_KT=[0,.08,.22,.36,.50,.64,.78,.92]; // 8 keyframes for 7 milestones: segment i sweeps v[i] -> v[i+1], p >= .92 holds the final value | |
| const PERF_VMIN=0.5,PERF_VMAX=1000; | |
| function perfV(p){if(p<=0)return PERF_MS[0].v; | |
| for(let i=0;i<PERF_KT.length-1;i++){if(p<=PERF_KT[i+1]){const u=ease(clamp((p-PERF_KT[i])/(PERF_KT[i+1]-PERF_KT[i]),0,1)); | |
| const j=Math.min(i+1,PERF_MS.length-1); | |
| return Math.exp(Math.log(PERF_MS[i].v)+(Math.log(PERF_MS[j].v)-Math.log(PERF_MS[i].v))*u)}} | |
| return PERF_MS[PERF_MS.length-1].v} | |
| const fmtV=v=>v>=900?'>15 min':v>=100?Math.round(v)+' s':v>=10?v.toFixed(1)+' s':v>=1?v.toFixed(2)+' s':Math.round(v*1000)+' ms'; | |
| function perfAng(v){const f=(Math.log10(PERF_VMAX)-Math.log10(clamp(v,PERF_VMIN,PERF_VMAX)))/(Math.log10(PERF_VMAX)-Math.log10(PERF_VMIN));return (135+270*f)*Math.PI/180} | |
| function scenePerf(p){ | |
| ctx.fillStyle='#0B1622';ctx.fillRect(0,0,cw,chh); | |
| ctx.fillStyle='rgba(141,154,168,.12)';for(let x=20;x<W;x+=40)for(let y=20;y<H;y+=40){ctx.fillRect(X(x),Y(y),1.4*k,1.4*k)} | |
| const ti=sm(0,.05,p); | |
| ctx.globalAlpha=ti; | |
| T1('ON-DEVICE INFERENCE',500,62,26,C.off,'center',FD,800); | |
| T1('ESP32-S31 @ 320 MHz · one 5-s audio window · 56/56 decision parity vs host float ONNX',500,90,12,C.steel,'center',FM,600); | |
| ctx.globalAlpha=1; | |
| const V=perfV(p),cx=268,cy=336,R=180; | |
| // right panel: milestone rows light up as the needle passes them | |
| PERF_MS.forEach((m,i)=>{const a=sm(PERF_KT[i],PERF_KT[i]+.05,p);if(a<=0)return; | |
| const y=146+i*52,cur=V<=m.v,flash=clamp((p-PERF_KT[i])/.06,0,1); | |
| ctx.globalAlpha=a; | |
| if(cur&&flash<1){ctx.save();ctx.shadowColor=m.col;ctx.shadowBlur=18*(1-flash)*k} | |
| ctx.fillStyle=cur?m.col:'rgba(141,154,168,.4)';diamond(X(536),Y(y+7),5*k,true); | |
| T1(m.lab,556,y+3,14,cur?m.col:C.steel,'left',FM,700); | |
| T1(fmtV(m.v),968,y+3,17,cur?m.col:C.steel,'right',FD,800); | |
| T1(m.sub,556,y+21,10,C.steel,'left',FM,500); | |
| if(cur&&flash<1)ctx.restore(); | |
| ctx.globalAlpha=1}); | |
| const ra=sm(.86,.92,p);if(ra>0){ctx.globalAlpha=ra; | |
| T1('cheaper board · Seeed XIAO ESP32-S3 (~$8)',556,508,11,C.steel,'left',FM,600); | |
| T1('1.23 s @128 · 4.09 s @224',968,508,13,C.off,'right',FM,700); | |
| T1('host CPU · ORT float32 (reference)',556,530,11,C.steel,'left',FM,600); | |
| T1('4.13 ms',968,530,13,C.off,'right',FM,700); | |
| ctx.globalAlpha=1} | |
| // log-scale stopwatch dial | |
| ctx.fillStyle='#10202F';ctx.beginPath();ctx.arc(X(cx),Y(cy),R*k,0,7);ctx.fill(); | |
| ctx.strokeStyle=C.rule;ctx.lineWidth=2;ctx.beginPath();ctx.arc(X(cx),Y(cy),R*k,0,7);ctx.stroke(); | |
| for(let d=0.1;d<=1000;d*=10)for(let m2=1;m2<=9;m2++){const v=d*m2;if(v<PERF_VMIN||v>PERF_VMAX)continue; | |
| const a=perfAng(v),big=m2===1; | |
| ctx.strokeStyle=big?C.steel:'rgba(141,154,168,.35)';ctx.lineWidth=big?2:1; | |
| ctx.beginPath();ctx.moveTo(X(cx+Math.cos(a)*(R-14)),Y(cy+Math.sin(a)*(R-14))); | |
| ctx.lineTo(X(cx+Math.cos(a)*(R-(big?28:21))),Y(cy+Math.sin(a)*(R-(big?28:21))));ctx.stroke()} | |
| [[1000,'>15 min'],[100,'100 s'],[10,'10 s'],[1,'1 s'],[0.7,'0.7 s']].forEach(([v,s])=>{const a=perfAng(v); | |
| T1(s,cx+Math.cos(a)*(R+24),cy+Math.sin(a)*(R+24)+4,11,C.steel,'center',FM,600)}); | |
| PERF_MS.forEach((m,i)=>{const a=perfAng(m.v),passed=V<=m.v; | |
| ctx.globalAlpha=sm(PERF_KT[i],PERF_KT[i]+.05,p); | |
| ctx.fillStyle=passed?m.col:'rgba(141,154,168,.4)'; | |
| ctx.beginPath();ctx.arc(X(cx+Math.cos(a)*(R-35)),Y(cy+Math.sin(a)*(R-35)),(passed?4.5:3)*k,0,7);ctx.fill();ctx.globalAlpha=1}); | |
| // needle (the animated clock hand) | |
| const na=perfAng(V),col=V<1?C.green:C.amber; | |
| ctx.strokeStyle=col;ctx.lineWidth=3.5;ctx.lineCap='round'; | |
| ctx.beginPath();ctx.moveTo(X(cx-Math.cos(na)*16),Y(cy-Math.sin(na)*16));ctx.lineTo(X(cx+Math.cos(na)*(R-46)),Y(cy+Math.sin(na)*(R-46)));ctx.stroke(); | |
| ctx.fillStyle=col;ctx.beginPath();ctx.arc(X(cx),Y(cy),7*k,0,7);ctx.fill(); | |
| // digital countdown in the dial's bottom opening | |
| T1(fmtV(V),cx,cy+112,30,col,'center',FD,800); | |
| T1('PER 5-S WINDOW',cx,cy+140,10,C.steel,'center',FM,600); | |
| // sub-second badge + speedup counter | |
| const bx=sm(.93,.99,p); | |
| if(bx>0){const n=Math.round(73.1/PERF_MS[PERF_MS.length-1].v*ease(bx)); | |
| ctx.globalAlpha=bx; | |
| ctx.fillStyle=C.green;rrect(cx-72,104,144,32,7);ctx.fill(); | |
| T1('SUB-SECOND',cx,126,14,'#08111B','center',FM,700); | |
| T1('73.1 s → 0.70 s · ×'+n+' FASTER',500,566,20,C.green,'center',FD,800); | |
| T1('than the first working on-device run',500,590,11,C.steel,'center',FM,500); | |
| ctx.globalAlpha=1} | |
| } | |
| function drawModel(u){ | |
| ctx.fillStyle='#0B1622';ctx.fillRect(0,0,cw,chh); | |
| ctx.fillStyle='rgba(141,154,168,.12)';for(let x=20;x<W;x+=40)for(let y=20;y<H;y+=40){ctx.fillRect(X(x),Y(y),1.4*k,1.4*k)} | |
| const sc=[[0,9,sceneData],[9,14,sceneMix],[14,24,sceneModels],[24,34,sceneEdge],[34,42,sceneSota]]; | |
| for(const[a,b,f]of sc){if(u>=a&&u<b){const fa=Math.min(sm(a,a+.5,u),1-sm(b-.4,b,u));ctx.globalAlpha=1;ctx.save();f(u-a);ctx.restore(); | |
| if(fa<1){ctx.fillStyle=`rgba(11,22,34,${1-fa})`;ctx.fillRect(0,0,cw,chh)}break}} | |
| } | |
| function specP1(u){if(u<9)return{n:.13};if(u<14)return{cls:Math.floor((u-9)/1.2)%CLS.length};if(u<34)return{n:.1};return{cls:1}} | |
| const sp=document.getElementById('spec'),sx=sp.getContext('2d'),SW=480,SH=96,img=sx.createImageData(1,SH); | |
| sx.fillStyle=C.navy;sx.fillRect(0,0,SW,SH); | |
| function focus(){if(t>=T.truck&&t<T.boom)return'S3';if(t>=T.boom&&t<T.drone)return'S2';if(t>=T.s2+1)return'S2';return'S1'} | |
| function specColumn(){ | |
| if(PART1){const m=specP1(U1);const ci=m.cls,f0=11+1.4*Math.sin(U1*1.3),ph=U1*60; | |
| for(let b=0;b<SH;b++){let val=Math.random()*0.13; | |
| if(ci===0)val+=(ph%40<6?Math.exp(-(ph%40)/2):0)*0.9; | |
| if(ci===1)for(let h=1;h<=8;h++){const c=f0*h;if(c<SH)val+=(1-h*0.08)*Math.exp(-((b-c)**2)/2.4)*(0.85+0.15*Math.random())} | |
| if(ci===2)val+=(Math.sin(ph*.25)>0?1:.2)*Math.exp(-((b-18-8*Math.sin(ph*.08))**2)/30)*.9; | |
| if(ci===3)val+=(ph%24<2?.85*Math.exp(-b/40):0); | |
| if(ci===4&&b<44)val+=0.9*Math.exp(-b/13)*(0.6+0.4*Math.random()); | |
| val=clamp(val,0,1);let r,g,bl;if(val<.5){const u=val/.5;r=13+114*u;g=27+127*u;bl=42+64*u}else{const u=(val-.5)/.5;r=127+111*u;g=154+86*u;bl=106+128*u} | |
| const i=(SH-1-b)*4;img.data[i]=r;img.data[i+1]=g;img.data[i+2]=bl;img.data[i+3]=255} | |
| sx.drawImage(sp,-2,0);sx.putImageData(img,SW-2,0);sx.putImageData(img,SW-1,0);return} | |
| const f=focus();let vs=0,ds=0,bs=0;const v=vehAt(t),p=droneAt(t); | |
| if(f==='S3'&&v)vs=clamp(1-(dist(v,S[2])-40)/330,0,1); | |
| if(f==='S2'&&t<T.drone){const since=t-(BOOM_T+0.9);if(since>=0&&since<1.2)bs=Math.exp(-since*3.2)} | |
| if(p&&(f==='S1'||(f==='S2'&&t>=T.drone))){const node=f==='S1'?S[0]:S[1];ds=clamp(1-(dist(p,node)-60)/300,0,1)} | |
| const f0=11+1.4*Math.sin(t*1.3); | |
| for(let b=0;b<SH;b++){let val=Math.random()*0.13; | |
| if(vs>0&&b<44)val+=vs*0.95*Math.exp(-b/13)*(0.6+0.4*Math.random()); | |
| if(bs>0)val+=bs*(0.95-b*0.004)*(0.7+0.3*Math.random()); | |
| if(ds>0)for(let h=1;h<=8;h++){const c=f0*h;if(c<SH)val+=ds*(1-h*0.08)*Math.exp(-((b-c)**2)/2.4)*(0.85+0.15*Math.random())} | |
| val=clamp(val,0,1);let r,g,bl;if(val<.5){const u=val/.5;r=13+114*u;g=27+127*u;bl=42+64*u}else{const u=(val-.5)/.5;r=127+111*u;g=154+86*u;bl=106+128*u} | |
| const i=(SH-1-b)*4;img.data[i]=r;img.data[i+1]=g;img.data[i+2]=bl;img.data[i+3]=255} | |
| sx.drawImage(sp,-2,0);sx.putImageData(img,SW-2,0);sx.putImageData(img,SW-1,0)} | |
| const $=id=>document.getElementById(id); | |
| const PAUSE='<rect x="3" y="2" width="3.5" height="12"/><rect x="9.5" y="2" width="3.5" height="12"/>',PLAY='<path d="M4 2l10 6-10 6z"/>'; | |
| let shownPlaying=null; | |
| function ui(){$('fill').style.width=(RT/TOTAL*100)+'%';$('bar').setAttribute('aria-valuenow',Math.round(RT/TOTAL*100)); | |
| $('end').hidden=true; | |
| if(shownPlaying!==playing){shownPlaying=playing;$('playIcon').innerHTML=playing?PAUSE:PLAY;$('play').setAttribute('aria-label',playing?'Pause':'Play')}} | |
| function frame(ts){if(last===null)last=ts;const dt=Math.min(.05,(ts-last)/1000);last=ts; | |
| if(playing){RT+=dt;if(RT>=TOTAL)RT-=TOTAL} // loops seamlessly: outro logo wraps into the intro logo | |
| mapTime();if(playing)specColumn(); | |
| const f=MODE==='perf'?'ESP32-S31':MODE==='p2'?focus():MODE==='seg'?'COST':(U1>=9&&U1<14?CLS[Math.floor((U1-9)/1.2)%CLS.length][0]:U1>=34?'DRONE':'DATA');if($('who').textContent!==f)$('who').textContent=f; | |
| $('specBox').classList.toggle('hit',MODE==='p2'&&((t>=T.detect&&t<T.detect+3)||(t>=T.s2&&t<T.s2+2))); | |
| if(MODE==='p1')drawModel(U1);else if(MODE==='seg')drawSegue(SEG);else if(MODE==='p2')draw();else if(MODE==='perf')scenePerf(PERF); | |
| else drawLogo(MODE==='intro'?clamp(1-sm(.5,1.8,RT),0,1):clamp(sm(TOTAL-LOGO+.2,TOTAL-.05,RT),0,1)); | |
| ui();requestAnimationFrame(frame)} | |
| $('play').onclick=()=>{if(!playing&&RT>=TOTAL)RT=0;playing=!playing}; | |
| $('restart').onclick=()=>{RT=0;playing=true}; | |
| $('bar').onclick=e=>{const r=$('bar').getBoundingClientRect();RT=clamp((e.clientX-r.left)/r.width,0,1)*TOTAL;playing=true}; | |
| $('bar').onkeydown=e=>{if(e.key==='ArrowRight'){RT=Math.min(TOTAL,RT+2);e.preventDefault()}if(e.key==='ArrowLeft'){RT=Math.max(0,RT-2);e.preventDefault()}}; | |
| document.addEventListener('keydown',e=>{if(e.target.tagName==='BUTTON')return;if(e.key===' '){e.preventDefault();$('play').click()}}); | |
| const m=/^#t([0-9]{1,3})$/.exec(location.hash);if(m){RT=clamp(+m[1],0,TOTAL);mapTime();for(let i=0;i<240;i++)specColumn()} | |
| if(reduce){mapTime();for(let i=0;i<240;i++)specColumn()} | |
| new ResizeObserver(resize).observe(cv.parentElement);resize(); | |
| requestAnimationFrame(frame); | |
| })(); | |
| </script> | |
| </body></html> |