Spaces:
Running
Running
Download index.html from SheikhMinds/Megha: direct link, hf CLI and curl.
- Browser
- Download file 24.5 kB
-
https://huggingface.co/spaces/SheikhMinds/Megha/resolve/main/index.html
- Command line
-
hf download hf://spaces/SheikhMinds/Megha/index.html
-
curl -L -o index.html https://huggingface.co/spaces/SheikhMinds/Megha/resolve/main/index.html
24.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"> | |
| <title>Megha</title> | |
| <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@300;500&family=Hind+Siliguri:wght@300;400;500&family=IBM+Plex+Mono:wght@400;500&family=Tiro+Bangla&display=swap"> | |
| <style> | |
| :root{ | |
| /* Layout: one full-bleed monsoon sky pinned to the screen. Scrolling flies the camera down through the cloud deck into the rain. | |
| Text panels sit at different depths, approach, hold, then sweep past, alternating left and right. */ | |
| --night:#07131c; | |
| --storm:#16303f; | |
| --cloud:#d4e4ea; | |
| --rain:#a9dbe8; | |
| --jade:#5fe0b0; | |
| --sun:#ff6b4f; | |
| --ink:#eef6f8; | |
| --ink-dim:#bdd1d7; | |
| --scrim:rgba(5,12,19,.62); | |
| --f-display:"Bricolage Grotesque","Helvetica Neue",Arial,sans-serif; | |
| --f-body:"Hind Siliguri","Noto Sans Bengali",system-ui,sans-serif; | |
| --f-bn:"Tiro Bangla","Noto Serif Bengali",serif; | |
| --f-mono:"IBM Plex Mono",ui-monospace,Menlo,Consolas,monospace; | |
| color-scheme:dark; | |
| } | |
| body{background:var(--night);color:var(--ink);font-family:var(--f-body);font-size:18px;line-height:1.55;-webkit-font-smoothing:antialiased} | |
| body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);background:#081a2e;z-index:50} | |
| .track{position:relative;height:1000vh;height:1000svh} | |
| .stage{position:sticky;top:env(safe-area-inset-top,0px);height:calc(100vh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));height:calc(100svh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));overflow:hidden;overflow:clip;background:var(--night)} | |
| #sky{position:absolute;inset:0;width:100%;height:100%;display:block} | |
| .panels{position:absolute;inset:0} | |
| .panel{position:absolute;inset:0;display:flex;align-items:center;justify-content:flex-start;pointer-events:none;opacity:0; | |
| padding-block:64px; | |
| padding-left:max(16px,env(safe-area-inset-left,0px)); | |
| padding-right:max(16px,env(safe-area-inset-right,0px))} | |
| .p-hero{opacity:1;align-items:flex-end;padding-bottom:84px} | |
| .side-end{justify-content:flex-end} | |
| .side-mid{justify-content:center;text-align:center} | |
| @media (min-width:720px){ | |
| .panel{padding-left:max(56px,env(safe-area-inset-left,0px));padding-right:max(72px,env(safe-area-inset-right,0px))} | |
| } | |
| .card{position:relative;isolation:isolate;max-width:34rem;min-width:0;text-shadow:0 1px 18px rgba(4,10,16,.55)} | |
| .card::before{content:"";position:absolute;z-index:-1;inset:-16% -12%;background:radial-gradient(closest-side,var(--scrim),rgba(5,12,19,0))} | |
| .side-mid .card{max-width:40rem} | |
| .side-mid .card p{margin-inline:auto} | |
| .card .eyebrow{font:500 .75rem/1.2 var(--f-mono);letter-spacing:.2em;text-transform:uppercase;color:var(--rain);margin:0 0 1rem} | |
| .card .bn{font:400 clamp(2.2rem,7vw,4.6rem)/1 var(--f-bn);color:var(--jade);margin:0 0 .1em} | |
| .wordmark{font:300 clamp(5rem,23vw,16rem)/.9 var(--f-display);letter-spacing:-.045em;margin:0 0 2rem;color:var(--ink)} | |
| .card .lede{font-size:clamp(1.05rem,1.6vw,1.3rem);max-width:30rem;margin:0;color:var(--ink)} | |
| h2{font:500 clamp(1.9rem,4.6vw,3.4rem)/1.05 var(--f-display);letter-spacing:-.025em;margin:0 0 1.1rem;text-wrap:balance} | |
| h2.long{font-size:clamp(1.7rem,3.6vw,2.6rem)} | |
| .bn-inline{font-family:var(--f-bn);font-weight:400;color:var(--jade)} | |
| .card p{margin:0;max-width:30rem;color:var(--ink-dim);font-size:clamp(1.02rem,1.5vw,1.2rem)} | |
| .foot{margin-top:1.6rem;font:400 .78rem/1.4 var(--f-mono);letter-spacing:.16em;text-transform:uppercase;color:var(--rain)} | |
| .foot [lang=bn]{font-family:var(--f-bn);letter-spacing:0;text-transform:none;font-size:1rem} | |
| .p-size .card{max-width:min(44rem,100%)} | |
| .size{display:flex;flex-direction:column;gap:.5rem;margin:0 0 1.3rem;font-weight:300} | |
| .size .tiny{font:500 .85rem/1 var(--f-mono);letter-spacing:.24em;text-transform:uppercase;color:var(--jade)} | |
| .size .exp{font:300 clamp(3.1rem,13.5vw,9.4rem)/.9 var(--f-display);letter-spacing:-.05em;color:var(--ink)} | |
| .hud{position:absolute;inset:0;pointer-events:none;font-family:var(--f-mono);text-shadow:0 1px 8px rgba(4,10,16,.85)} | |
| .brand{position:absolute;top:14px;left:max(16px,env(safe-area-inset-left,0px));font:500 .75rem/1 var(--f-mono);letter-spacing:.22em;text-transform:uppercase;color:var(--ink)} | |
| .brand [lang=bn]{font-family:var(--f-bn);letter-spacing:0;text-transform:none;font-size:.95rem;margin-left:.4em;color:var(--jade)} | |
| .gauge{position:absolute;top:14px;right:max(16px,env(safe-area-inset-right,0px));display:flex;flex-direction:column;gap:.4rem;text-align:right;font:400 .6875rem/1 var(--f-mono);letter-spacing:.1em;color:var(--ink-dim);font-variant-numeric:tabular-nums} | |
| .gauge .k{text-transform:uppercase;color:var(--rain);margin-right:.5em} | |
| .gauge b{font-weight:500;color:var(--ink);display:inline-block;min-width:3.4ch;text-align:right} | |
| .dots{position:absolute;right:max(10px,env(safe-area-inset-right,0px));top:50%;transform:translateY(-50%);display:none;flex-direction:column;gap:2px;pointer-events:auto} | |
| @media (min-width:720px){.dots{display:flex}} | |
| .dot{width:28px;height:28px;display:grid;place-items:center;background:none;border:0;padding:0;cursor:pointer} | |
| .dot::before{content:"";width:7px;height:7px;border-radius:50%;background:rgba(238,246,248,.38);transition:transform .25s,background .25s} | |
| .dot[aria-current="true"]::before{background:var(--jade);transform:scale(1.55)} | |
| .hint{position:absolute;left:max(16px,env(safe-area-inset-left,0px));bottom:18px;display:flex;align-items:center;gap:.8rem;font:500 .7rem/1 var(--f-mono);letter-spacing:.22em;text-transform:uppercase;color:var(--ink-dim)} | |
| @media (min-width:720px){.hint{left:max(56px,env(safe-area-inset-left,0px))}} | |
| .hint i{display:block;width:1px;height:30px;background:linear-gradient(var(--rain),transparent);transform-origin:top;animation:drip 1.8s ease-in infinite} | |
| @keyframes drip{0%{transform:scaleY(0);opacity:0}30%{opacity:1}100%{transform:scaleY(1);opacity:0}} | |
| .snd{position:absolute;right:max(16px,env(safe-area-inset-right,0px));bottom:16px;pointer-events:auto;font:500 .72rem/1 var(--f-mono);letter-spacing:.14em;text-transform:uppercase;color:var(--ink);background:rgba(5,12,19,.55);border:1px solid rgba(238,246,248,.3);border-radius:999px;padding:.7rem 1rem;cursor:pointer;text-shadow:none} | |
| .snd[aria-pressed="true"]{border-color:var(--jade);color:var(--jade)} | |
| .dot:focus-visible,.snd:focus-visible{outline:2px solid var(--jade);outline-offset:2px} | |
| /* Reduced motion: stacked reading layout over one still frame of the sky */ | |
| .flat .track{height:auto} | |
| .flat .stage{position:relative;top:auto;height:auto;overflow:visible;background:transparent} | |
| .flat #sky{position:fixed;inset:0;z-index:-1} | |
| .flat .panels{position:relative;display:flex;flex-direction:column;gap:6rem;padding-block:6rem 8rem} | |
| .flat .panel{position:relative;inset:auto;opacity:1;transform:none;padding-block:0} | |
| .flat .p-hero{align-items:flex-start;padding-bottom:0} | |
| .flat .hint,.flat .dots,.flat .snd,.flat .gauge{display:none} | |
| @media (prefers-reduced-motion:reduce){.hint i{animation:none}} | |
| body{margin:0} | |
| [hidden]{display:none} | |
| </style> | |
| </head> | |
| <body> | |
| <main class="track" id="track"> | |
| <div class="stage" id="stage"> | |
| <canvas id="sky" aria-hidden="true"></canvas> | |
| <div class="panels"> | |
| <section class="panel p-hero side-start" data-c="0" data-w=".12" data-label="Megha" aria-labelledby="h-hero"> | |
| <div class="card"> | |
| <p class="eyebrow">Now launching · Bangladesh</p> | |
| <p class="bn" lang="bn">মেঘ</p> | |
| <h1 class="wordmark" id="h-hero">Megha</h1> | |
| <p class="lede">The first AI model made in Bangladesh. Tiny, but expensive. Trained on the country’s leading online medicine directory and healthcare portal.</p> | |
| </div> | |
| </section> | |
| <section class="panel side-end" data-c=".16" data-w=".1" data-label="The name" aria-labelledby="h-name"> | |
| <div class="card"> | |
| <p class="eyebrow">The name</p> | |
| <h2 id="h-name">Megha, <span class="bn-inline" lang="bn">মেঘ</span>, is the Bangla word for cloud.</h2> | |
| <p>Clouds gather water and return it as rain. Megha gathers medicine and healthcare knowledge and returns it as a clear answer to one person’s question.</p> | |
| </div> | |
| </section> | |
| <section class="panel p-size side-start" data-c=".34" data-w=".1" data-label="The size" aria-labelledby="h-size"> | |
| <div class="card"> | |
| <p class="eyebrow">The size</p> | |
| <h2 class="size" id="h-size"><span class="tiny">Tiny, but</span><span class="exp">expensive.</span></h2> | |
| <p>Megha is a small model. What it was trained on is what makes it expensive.</p> | |
| </div> | |
| </section> | |
| <section class="panel side-end" data-c=".52" data-w=".1" data-label="The source" aria-labelledby="h-source"> | |
| <div class="card"> | |
| <p class="eyebrow">The source</p> | |
| <h2 class="long" id="h-source">Trained on the leading online medicine directory and healthcare portal in Bangladesh.</h2> | |
| <p>Megha learned from a source built for Bangladesh, where people already go to look up a medicine and find healthcare.</p> | |
| </div> | |
| </section> | |
| <section class="panel side-start" data-c=".7" data-w=".1" data-label="A note on care" aria-labelledby="h-care"> | |
| <div class="card"> | |
| <p class="eyebrow">A note on care</p> | |
| <h2 id="h-care">Health information, not medical advice.</h2> | |
| <p>Megha can help you look things up and understand them. It cannot examine you. For a diagnosis, a prescription or an emergency, speak to a doctor or pharmacist, or call 999.</p> | |
| </div> | |
| </section> | |
| <section class="panel side-mid" data-c=".9" data-w=".1" data-last="1" data-label="Launch" aria-labelledby="h-end"> | |
| <div class="card"> | |
| <p class="eyebrow">Megha is launching</p> | |
| <h2 id="h-end">The rain starts here.</h2> | |
| <p>The first AI model made in Bangladesh is on its way down to you.</p> | |
| <p class="foot"><span lang="bn">মেঘ</span> · Megha · Made in Bangladesh</p> | |
| </div> | |
| </section> | |
| </div> | |
| <div class="hud"> | |
| <div class="brand">Megha <span lang="bn">মেঘ</span></div> | |
| <div class="gauge" aria-hidden="true"> | |
| <div><span class="k">Alt</span><b id="alt">4,200</b> m</div> | |
| <div><span class="k">Rain</span><b id="rainv">0</b> mm/h</div> | |
| </div> | |
| <nav class="dots" id="dots" aria-label="Chapters"></nav> | |
| <div class="hint" id="hint" aria-hidden="true"><i></i><span>Scroll to descend</span></div> | |
| <button class="snd" id="snd" type="button" aria-pressed="false" aria-label="Rain sound">Sound off</button> | |
| </div> | |
| </div> | |
| </main> | |
| <script> | |
| (function(){ | |
| ; | |
| var D=document, track=D.getElementById('track'), stage=D.getElementById('stage'), cv=D.getElementById('sky'), ctx=cv.getContext('2d'); | |
| var flat=!!(window.matchMedia&&matchMedia('(prefers-reduced-motion: reduce)').matches); | |
| if(flat) D.body.classList.add('flat'); | |
| function clamp(v,a,b){a=a===undefined?0:a;b=b===undefined?1:b;return v<a?a:v>b?b:v} | |
| function lerp(a,b,t){return a+(b-a)*t} | |
| function smooth(a,b,v){var t=clamp((v-a)/(b-a));return t*t*(3-2*t)} | |
| function mix(a,b,t){return [a[0]+(b[0]-a[0])*t,a[1]+(b[1]-a[1])*t,a[2]+(b[2]-a[2])*t]} | |
| function rgba(c,a){return 'rgba('+(c[0]|0)+','+(c[1]|0)+','+(c[2]|0)+','+a.toFixed(3)+')'} | |
| function rng(seed){return function(){seed|=0;seed=seed+0x6D2B79F5|0;var t=Math.imul(seed^seed>>>15,1|seed);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296}} | |
| /* ---------- world constants ---------- */ | |
| var ZR=6200, FAR=7000; | |
| var K=[ | |
| {t:0, top:[8,24,44], mid:[26,66,96], hor:[226,140,112]}, | |
| {t:.45, top:[9,20,28], mid:[24,48,62], hor:[70,96,110]}, | |
| {t:.75, top:[6,14,20], mid:[16,36,46], hor:[44,72,82]}, | |
| {t:1, top:[12,34,46], mid:[30,76,76], hor:[236,160,122]} | |
| ]; | |
| function skyAt(p){var i=0;while(i<K.length-2&&p>K[i+1].t)i++;var a=K[i],b=K[i+1],t=smooth(a.t,b.t,p);return {top:mix(a.top,b.top,t),mid:mix(a.mid,b.mid,t),hor:mix(a.hor,b.hor,t)}} | |
| var CY=[[0,-1500],[.15,-1100],[.33,-500],[.5,-60],[.7,150],[1,300]]; | |
| function camY(p){for(var i=0;i<CY.length-1;i++){var a=CY[i],b=CY[i+1];if(p<=b[0]){var u=(p-a[0])/(b[0]-a[0]);return lerp(a[1],b[1],smooth(0,1,u)*.6+u*.4)}}return CY[CY.length-1][1]} | |
| /* ---------- cloud textures ---------- */ | |
| function makeCloud(seed){ | |
| var c=D.createElement('canvas');c.width=320;c.height=180; | |
| var g=c.getContext('2d'),r=rng(seed),puffs=[],n=15+Math.floor(r()*8),i; | |
| for(i=0;i<n;i++){var t=i/(n-1),bump=Math.sin(t*Math.PI); | |
| puffs.push({x:36+t*248+(r()-.5)*26,y:122-bump*(18+r()*34)+(r()-.5)*12,r:20+bump*30*r()+r()*16});} | |
| puffs.forEach(function(p){ | |
| var gr=g.createRadialGradient(p.x,p.y+p.r*.25,p.r*.15,p.x,p.y+p.r*.25,p.r); | |
| gr.addColorStop(0,'rgba(150,176,192,.85)');gr.addColorStop(1,'rgba(150,176,192,0)'); | |
| g.fillStyle=gr;g.beginPath();g.arc(p.x,p.y+p.r*.25,p.r,0,6.2832);g.fill();}); | |
| puffs.forEach(function(p){ | |
| var cx=p.x-p.r*.18,cy=p.y-p.r*.3,gr=g.createRadialGradient(cx,cy,p.r*.05,cx,cy,p.r*.95); | |
| gr.addColorStop(0,'rgba(255,255,255,.95)');gr.addColorStop(.55,'rgba(228,241,246,.6)');gr.addColorStop(1,'rgba(210,228,236,0)'); | |
| g.fillStyle=gr;g.beginPath();g.arc(cx,cy,p.r*.95,0,6.2832);g.fill();}); | |
| g.globalCompositeOperation='destination-out'; | |
| var fl=g.createLinearGradient(0,118,0,160);fl.addColorStop(0,'rgba(0,0,0,0)');fl.addColorStop(1,'rgba(0,0,0,1)'); | |
| g.fillStyle=fl;g.fillRect(0,118,320,62); | |
| return c; | |
| } | |
| var tex=[1,2,3,4,5].map(function(s){return makeCloud(s*97)}); | |
| /* ---------- scene state ---------- */ | |
| var W=800,H=600,HY=312,F=700,dpr=1,vig=null; | |
| var clouds=[],stars=[],drops=[],ripples=[],rippleAcc=0; | |
| var time=0,last=0,pt=0,pv=0,rainI=0,flash=0,nextFlash=4,fx=.5; | |
| var RL=[{n:260,l:[9,17],s:[650,900],lw:.7,al:.3},{n:200,l:[17,30],s:[980,1300],lw:1,al:.42},{n:110,l:[30,52],s:[1500,1900],lw:1.5,al:.55}]; | |
| var SL=.16; | |
| function buildClouds(){ | |
| var r=rng(7),n=(W<700)?190:300,i;clouds=[]; | |
| for(i=0;i<n;i++){ | |
| var z=250+(ZR+FAR)*Math.pow(r(),.9),k=r(),c={z:z,t:Math.floor(r()*5),v:(r()-.5)*14,a:.55+r()*.4},sp=2400+z*.35; | |
| if(k<.68){c.x=(r()-.5)*2*sp;c.y=-500+(r()+r()+r()-1.5)*340;c.s=700+r()*800;} | |
| else if(k<.92){c.x=(r()-.5)*2*sp;c.y=80+r()*340;c.s=900+r()*900;c.a*=.7;} | |
| else{c.x=(r()-.5)*2*sp;c.y=-1300+r()*380;c.s=1000+r()*900;c.a*=.8;} | |
| clouds.push(c); | |
| } | |
| clouds.sort(function(a,b){return b.z-a.z}); | |
| } | |
| function buildStars(){var r=rng(11),i;stars=[];for(i=0;i<80;i++)stars.push({x:r(),y:r(),s:.6+r()*1.0,ph:r()*6.28});} | |
| function initRain(){ | |
| var k=clamp(W*H/(1440*800),.3,1),hs=Math.max(.7,H/800); | |
| drops=RL.map(function(c){var a=[],n=Math.round(c.n*k),i; | |
| for(i=0;i<n;i++)a.push({x:Math.random()*(W+160)-40,y:Math.random()*H,l:lerp(c.l[0],c.l[1],Math.random())*hs,s:lerp(c.s[0],c.s[1],Math.random())*hs}); | |
| return a;}); | |
| } | |
| function resize(){ | |
| var w=flat?window.innerWidth:stage.clientWidth,h=flat?window.innerHeight:stage.clientHeight; | |
| if(!w||!h)return; | |
| dpr=Math.min(window.devicePixelRatio||1,1.5); | |
| cv.width=Math.round(w*dpr);cv.height=Math.round(h*dpr); | |
| var first=!clouds.length; | |
| W=w;H=h;HY=H*.52;F=Math.max(Math.min(W,H)*1.1,Math.max(W,H)*.62); | |
| ctx.setTransform(dpr,0,0,dpr,0,0); | |
| vig=ctx.createRadialGradient(W/2,H/2,Math.min(W,H)*.35,W/2,H/2,Math.hypot(W,H)*.6); | |
| vig.addColorStop(0,'rgba(3,9,14,0)');vig.addColorStop(1,'rgba(3,9,14,.6)'); | |
| if(first){buildClouds();buildStars();} | |
| initRain(); | |
| if(flat)renderStill(); | |
| } | |
| /* ---------- drawing ---------- */ | |
| function render(p,dt){ | |
| var sk=skyAt(p),cy=camY(p),cz=p*ZR,i,g; | |
| rainI=flat?.8:smooth(.3,.5,p)*(1-.55*smooth(.8,1,p)); | |
| ctx.globalCompositeOperation='source-over';ctx.globalAlpha=1; | |
| g=ctx.createLinearGradient(0,0,0,H); | |
| g.addColorStop(0,rgba(sk.top,1));g.addColorStop(.34,rgba(sk.mid,1));g.addColorStop(HY/H,rgba(sk.hor,1));g.addColorStop(1,rgba(sk.mid,1)); | |
| ctx.fillStyle=g;ctx.fillRect(0,0,W,H); | |
| var sa=1-smooth(0,.28,p); | |
| if(sa>.01){ | |
| for(i=0;i<stars.length;i++){var s=stars[i],a=sa*(.3+.45*(.5+.5*Math.sin(time*1.3+s.ph)))*(1-s.y*.6); | |
| ctx.fillStyle='rgba(220,235,255,'+a.toFixed(3)+')';ctx.fillRect(s.x*W,s.y*HY*.9,s.s,s.s);} | |
| } | |
| var sunA=.9*(1-smooth(.03,.3,p))+.95*smooth(.8,1,p); | |
| if(sunA>.01){ | |
| var sx=W*.7,sy=HY-H*.035,R=Math.min(W,H)*.085; | |
| var gl=ctx.createRadialGradient(sx,sy,R*.6,sx,sy,R*7); | |
| gl.addColorStop(0,'rgba(255,120,80,'+(.5*sunA).toFixed(3)+')');gl.addColorStop(1,'rgba(255,120,80,0)'); | |
| ctx.fillStyle=gl;ctx.fillRect(0,0,W,H); | |
| var dg=ctx.createRadialGradient(sx,sy,0,sx,sy,R*1.08); | |
| dg.addColorStop(0,'rgba(255,146,106,'+sunA.toFixed(3)+')');dg.addColorStop(.8,'rgba(244,76,62,'+sunA.toFixed(3)+')');dg.addColorStop(1,'rgba(244,70,60,0)'); | |
| ctx.fillStyle=dg;ctx.beginPath();ctx.arc(sx,sy,R*1.08,0,6.2832);ctx.fill(); | |
| } | |
| var ga=smooth(.6,.88,p); | |
| if(ga>.01){ | |
| var gg=ctx.createLinearGradient(0,HY,0,H); | |
| gg.addColorStop(0,'rgba(70,108,100,'+ga.toFixed(3)+')');gg.addColorStop(.18,'rgba(20,70,56,'+ga.toFixed(3)+')');gg.addColorStop(1,'rgba(4,24,20,'+ga.toFixed(3)+')'); | |
| ctx.fillStyle=gg;ctx.fillRect(0,HY,W,H-HY); | |
| for(i=0;i<14;i+=2){var y0=HY+(H-HY)*Math.pow(i/14,1.9),y1=HY+(H-HY)*Math.pow((i+1)/14,1.9); | |
| ctx.fillStyle='rgba(70,170,120,'+(ga*.07).toFixed(3)+')';ctx.fillRect(0,y0,W,y1-y0);} | |
| ctx.fillStyle='rgba(255,190,150,'+(ga*.3).toFixed(3)+')';ctx.fillRect(0,HY-1,W,2); | |
| if(!flat&&dt>0&&rainI>.05){ | |
| rippleAcc+=dt*rainI*30*ga*clamp(W*H/(1440*800),.4,1); | |
| while(rippleAcc>=1){rippleAcc-=1;if(ripples.length<40)ripples.push({x:Math.random()*W,k:Math.pow(Math.random(),1.5),t:0,life:.9+Math.random()*.5});} | |
| } | |
| ctx.lineWidth=1; | |
| for(i=ripples.length-1;i>=0;i--){var rp=ripples[i];rp.t+=dt/rp.life; | |
| if(rp.t>=1){ripples.splice(i,1);continue;} | |
| var ry=HY+(H-HY)*(.04+.96*rp.k),rr=(4+40*rp.k)*(1-Math.pow(1-rp.t,2)); | |
| ctx.strokeStyle='rgba(190,230,240,'+((1-rp.t)*.4*ga).toFixed(3)+')'; | |
| ctx.beginPath();ctx.ellipse(rp.x,ry,rr,rr*.26,0,0,6.2832);ctx.stroke();} | |
| } | |
| var hz=clamp((-500-cy)/600); | |
| if(hz>.01){ | |
| var hc=HY+(-500-cy)*F/7000,hh=Math.max(40,(-500-cy)*F/7000*.9); | |
| var hg=ctx.createLinearGradient(0,hc-hh,0,hc+hh*1.2); | |
| hg.addColorStop(0,'rgba(206,224,232,0)');hg.addColorStop(.5,'rgba(206,224,232,'+(.5*hz).toFixed(3)+')');hg.addColorStop(1,'rgba(206,224,232,0)'); | |
| ctx.fillStyle=hg;ctx.fillRect(0,hc-hh,W,hh*2.2); | |
| } | |
| var cg=1-smooth(.82,1,p)*.6,wx=flat?0:time; | |
| for(i=0;i<clouds.length;i++){ | |
| var c=clouds[i],d=c.z-cz; | |
| if(d<140||d>FAR)continue; | |
| var k=F/d,px=W/2+(c.x+wx*c.v)*k,py=HY+(c.y-cy)*k,pw=c.s*k,ph=pw*.5625; | |
| if(px+pw/2<0||px-pw/2>W||py+ph/2<0||py-ph/2>H)continue; | |
| ctx.globalAlpha=c.a*smooth(140,650,d)*(1-smooth(FAR*.45,FAR,d))*cg; | |
| ctx.drawImage(tex[c.t],px-pw/2,py-ph/2,pw,ph); | |
| } | |
| ctx.globalAlpha=1; | |
| var fogA=.32*Math.exp(-Math.pow((p-.3)/.14,2)); | |
| if(fogA>.01){ctx.fillStyle='rgba(176,200,210,'+fogA.toFixed(3)+')';ctx.fillRect(0,0,W,H);} | |
| var ta=lerp(.12,.78,smooth(0,.45,p))*(1-smooth(.8,1,p)*.85); | |
| ctx.globalCompositeOperation='multiply';ctx.fillStyle='rgba(112,140,156,'+ta.toFixed(3)+')';ctx.fillRect(0,0,W,H); | |
| ctx.globalCompositeOperation='source-over'; | |
| if(rainI>.01)drawRain(dt); | |
| if(!flat&&rainI>.55&&time>nextFlash){flash=1;nextFlash=time+6+Math.random()*7;fx=.15+Math.random()*.7;} | |
| if(flash>.01){ | |
| var fg=ctx.createRadialGradient(W*fx,H*.18,0,W*fx,H*.18,W*.8); | |
| fg.addColorStop(0,'rgba(205,228,255,'+(flash*.2).toFixed(3)+')');fg.addColorStop(1,'rgba(205,228,255,0)'); | |
| ctx.fillStyle=fg;ctx.fillRect(0,0,W,H);flash*=Math.exp(-dt*3); | |
| } | |
| ctx.fillStyle=vig;ctx.fillRect(0,0,W,H); | |
| } | |
| function drawRain(dt){ | |
| ctx.lineCap='round'; | |
| for(var L=0;L<3;L++){ | |
| var cfg=RL[L],ds=drops[L],act=Math.floor(ds.length*rainI),i; | |
| if(act<1)continue; | |
| ctx.strokeStyle='rgba(169,219,232,'+(cfg.al*(.35+.65*rainI)).toFixed(3)+')'; | |
| ctx.lineWidth=cfg.lw;ctx.beginPath(); | |
| for(i=0;i<act;i++){var d=ds[i];d.y+=d.s*dt; | |
| if(d.y>H+d.l){d.y=-d.l-Math.random()*H*.25;d.x=Math.random()*(W+160)-40;} | |
| ctx.moveTo(d.x,d.y);ctx.lineTo(d.x-d.l*SL,d.y+d.l);} | |
| ctx.stroke(); | |
| } | |
| } | |
| function renderStill(){pv=.45;time=0;render(.45,0)} | |
| /* ---------- panels, hud, dots ---------- */ | |
| var panels=Array.prototype.slice.call(D.querySelectorAll('.panel')).map(function(el){ | |
| return {el:el,c:parseFloat(el.getAttribute('data-c')),w:parseFloat(el.getAttribute('data-w')),last:el.hasAttribute('data-last'),key:''}; | |
| }); | |
| function updatePanels(p){ | |
| for(var i=0;i<panels.length;i++){ | |
| var pn=panels[i],u=(p-pn.c)/pn.w,s=1,o=1,a,b; | |
| if(u<-.4){ | |
| if(u<=-1){o=0;s=.5;} | |
| else{a=(u+1)/.6;s=.5+.476*(1-Math.pow(1-a,3));o=smooth(0,.7,a);} | |
| }else if(u<=.4){s=1+u*.06;} | |
| else if(pn.last){s=1.024;} | |
| else if(u>=1){o=0;s=2.9;} | |
| else{b=(u-.4)/.6;s=1.024+Math.pow(b,3)*1.9;o=1-clamp(b/.8);} | |
| var key=s.toFixed(3)+'|'+o.toFixed(3); | |
| if(key!==pn.key){pn.key=key;pn.el.style.transform='scale('+s.toFixed(4)+')';pn.el.style.opacity=o.toFixed(3);} | |
| } | |
| } | |
| var altEl=D.getElementById('alt'),rainEl=D.getElementById('rainv'),hintEl=D.getElementById('hint'),dotsEl=D.getElementById('dots'); | |
| var lastAlt=-1,lastRv=-1,lastDot=-1; | |
| function updateHud(p){ | |
| var alt=Math.round(lerp(4200,0,p)/10)*10;if(alt!==lastAlt){lastAlt=alt;altEl.textContent=alt.toLocaleString('en-US');} | |
| var rv=Math.round(rainI*64);if(rv!==lastRv){lastRv=rv;rainEl.textContent=rv;} | |
| hintEl.style.opacity=clamp(1-p*28).toFixed(2); | |
| var best=0,bd=9,i;for(i=0;i<panels.length;i++){var dd=Math.abs(p-panels[i].c);if(dd<bd){bd=dd;best=i;}} | |
| if(best!==lastDot){lastDot=best;for(i=0;i<panels.length;i++){if(i===best)panels[i].dot.setAttribute('aria-current','true');else panels[i].dot.removeAttribute('aria-current');}} | |
| } | |
| function goTo(c){ | |
| var tr=track.getBoundingClientRect(),st=stage.getBoundingClientRect(),span=tr.height-st.height,cur=st.top-tr.top; | |
| window.scrollBy({top:c*span-cur,behavior:'smooth'}); | |
| } | |
| panels.forEach(function(pn){ | |
| var b=D.createElement('button');b.type='button';b.className='dot'; | |
| b.setAttribute('aria-label',pn.el.getAttribute('data-label')); | |
| b.addEventListener('click',function(){goTo(pn.c)}); | |
| dotsEl.appendChild(b);pn.dot=b; | |
| }); | |
| /* ---------- rain sound (starts only on click) ---------- */ | |
| var snd=D.getElementById('snd'),actx=null,sg=null,soundOn=false,lastSnd=0; | |
| function setupAudio(){ | |
| var AC=window.AudioContext||window.webkitAudioContext;if(!AC)return false; | |
| actx=new AC(); | |
| var n=actx.sampleRate*2,buf=actx.createBuffer(1,n,actx.sampleRate),d=buf.getChannelData(0),b=0,i; | |
| for(i=0;i<n;i++){var wn=Math.random()*2-1;b=b*.96+wn*.04;d[i]=Math.max(-1,Math.min(1,wn*.45+b*2.6));} | |
| var src=actx.createBufferSource();src.buffer=buf;src.loop=true; | |
| var hp=actx.createBiquadFilter();hp.type='highpass';hp.frequency.value=420; | |
| var lp=actx.createBiquadFilter();lp.type='lowpass';lp.frequency.value=7200; | |
| sg=actx.createGain();sg.gain.value=0; | |
| src.connect(hp);hp.connect(lp);lp.connect(sg);sg.connect(actx.destination);src.start(); | |
| return true; | |
| } | |
| snd.addEventListener('click',function(){ | |
| try{ | |
| if(!actx&&!setupAudio()){snd.hidden=true;return;} | |
| soundOn=!soundOn; | |
| if(soundOn&&actx.state==='suspended')actx.resume(); | |
| snd.setAttribute('aria-pressed',soundOn?'true':'false'); | |
| snd.textContent=soundOn?'Sound on':'Sound off'; | |
| if(!soundOn)sg.gain.setTargetAtTime(0,actx.currentTime,.1); | |
| }catch(e){snd.hidden=true;} | |
| }); | |
| /* ---------- loop ---------- */ | |
| function readScroll(){ | |
| if(flat)return; | |
| var tr=track.getBoundingClientRect(),st=stage.getBoundingClientRect(),span=tr.height-st.height; | |
| pt=span>0?clamp((st.top-tr.top)/span):0; | |
| } | |
| function frame(now){ | |
| var dt=Math.min(.05,(now-last)/1000||.016);last=now;time+=dt; | |
| pv+=(pt-pv)*(1-Math.exp(-dt*5.5));if(Math.abs(pt-pv)<.00005)pv=pt; | |
| render(pv,dt);updatePanels(pv);updateHud(pv); | |
| if(soundOn&&sg&&time-lastSnd>.12){lastSnd=time;sg.gain.setTargetAtTime(.02+.2*rainI,actx.currentTime,.25);} | |
| requestAnimationFrame(frame); | |
| } | |
| resize(); | |
| if(flat){ | |
| window.addEventListener('resize',resize); | |
| }else{ | |
| readScroll();pv=pt; | |
| window.addEventListener('scroll',readScroll,{passive:true}); | |
| if(window.ResizeObserver)new ResizeObserver(function(){resize();readScroll();}).observe(stage); | |
| else window.addEventListener('resize',function(){resize();readScroll();}); | |
| requestAnimationFrame(function(t){last=t;frame(t);}); | |
| } | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |