Files
advent-of-slop-03-copenhage…/assets/index-B6U23M2C.js
T
2026-12-03 23:00:48 +00:00

50 lines
17 KiB
JavaScript

(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=`https://advent-of-slop.quesma.com`,t=`
nav {
position: fixed;
top: 0;
right: 0;
z-index: 2147483647;
display: flex;
flex-wrap: wrap;
gap: 0 0.35em;
max-width: 100vw;
box-sizing: border-box;
padding: 0.35rem 0.7rem;
border-bottom-left-radius: 0.5rem;
background: #b8232f;
font: 700 0.8125rem/1.2 system-ui, sans-serif;
}
a {
color: #f6ecd6;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
`,n=(e,t)=>{let n=document.createElement(`a`);return n.href=e,n.textContent=t,n},r=class extends HTMLElement{connectedCallback(){let r=Number(this.getAttribute(`day`));if(!Number.isInteger(r)||r<1||r>24)throw Error(`<advent-badge> needs day="1" to day="24", got ${this.getAttribute(`day`)}`);let i=this.getAttribute(`name`);if(i===null||i.trim()===``)throw Error(`<advent-badge> needs name="...", the title of its day, such as name="Living fishtank"`);let a=document.createElement(`style`);a.textContent=t;let o=document.createElement(`nav`);o.append(n(`${e}/`,`Advent of AI Slop`),n(`${e}/day/${r}/`,`[Day ${r}] ${i}`)),this.attachShadow({mode:`open`}).append(a,o)}};customElements.define(`advent-badge`,r);var i=[150,350,600,900,1300],a=72;function o(e){return e.cy+.62*e.r}function s(e){let t=o(e)-e.cy;return Math.sqrt(Math.max(0,e.r*e.r-t*t))}var c=class{flakes=[];drift=new Float32Array(a);target=i[1];g;constructor(e){this.g=e}resize(e){this.g=e}maxDrift(){return .3*this.g.r}driftAt(e){let t=this.g,n=s(t),r=(e-(t.cx-n))/(2*n);if(r<0||r>1)return 0;let i=Math.min(71,Math.floor(r*a));return this.drift[i]??0}driftDepthCm(){let e=0;for(let t of this.drift)e+=t;return e/a/this.g.r*30}serializeDrift(){return Array.from(this.drift,e=>Math.round(e*100)/100)}loadDrift(e){if(e.length!==a)return;let t=this.maxDrift();for(let n=0;n<a;n++)this.drift[n]=Math.min(t,Math.max(0,e[n]??0))}sweep(){this.drift.fill(0)}spawn(e){let t=this.g,n=Math.random()*Math.PI*2,r=Math.sqrt(Math.random())*(t.r*.92),i=e?t.cy+Math.random()*t.r*.5:t.cy-t.r+Math.random()*t.r*.6;this.flakes.push({x:t.cx+Math.cos(n)*r,y:i,vx:(Math.random()-.5)*.05*t.r,vy:Math.random()*.05*t.r,r:t.r*(.004+Math.random()*.008),phase:Math.random()*Math.PI*2,alpha:.55+Math.random()*.45})}shake(e){let t=e*this.g.r;for(let e of this.flakes)e.vx+=(Math.random()-.5)*1.4*t,e.vy+=(Math.random()-.9)*1.2*t;let n=.05*e;for(let e=0;e<a;e++){let t=this.drift[e]??0,r=t*n;this.drift[e]=t-r}}puff(e,t){let n=this.g;for(let r=0;r<26&&!(this.flakes.length>=this.target+60);r++){let r=-Math.PI/2+(Math.random()-.5)*1.6,i=n.r*(.2+Math.random()*.5);this.flakes.push({x:e,y:t,vx:Math.cos(r)*i,vy:Math.sin(r)*i,r:n.r*(.004+Math.random()*.007),phase:Math.random()*Math.PI*2,alpha:.7+Math.random()*.3})}}update(e){let t=this.g,n=.3*t.r,r=.35*t.r,i=t.r-3,c=s(t),l=t.cx-c,u=this.maxDrift();if(this.flakes.length<this.target){let e=Math.min(6,this.target-this.flakes.length);for(let t=0;t<e;t++)this.spawn(!1)}else this.flakes.length>this.target+80&&this.flakes.splice(0,this.flakes.length-this.target);let d=[];for(let s of this.flakes){s.vy+=n*e,s.phase+=2.2*e,s.vx+=Math.sin(s.phase)*r*e;let f=Math.max(0,1-1.4*e);s.vx*=f,s.vy*=f,s.x+=s.vx*e,s.y+=s.vy*e;let p=s.x-t.cx,m=s.y-t.cy,h=Math.hypot(p,m);if(h>i-s.r){let e=p/h,n=m/h;s.x=t.cx+e*(i-s.r),s.y=t.cy+n*(i-s.r);let r=s.vx*e+s.vy*n;r>0&&(s.vx-=1.35*r*e,s.vy-=1.35*r*n)}let g=(s.x-l)/(2*c);if(g>=0&&g<=1){let e=Math.min(71,Math.floor(g*a)),n=o(t)-(this.drift[e]??0);if(s.y>=n-s.r*.5){let t=this.drift[e]??0;this.drift[e]=Math.min(u,t+s.r*.32);let n=this.drift[Math.max(0,e-1)]??0,r=this.drift[Math.min(71,e+1)]??0,i=(n+r)/2;t-i>this.g.r*.012&&(this.drift[e]=t-(t-i)*.25,e>0&&(this.drift[e-1]=n+(t-i)*.125),e<71&&(this.drift[e+1]=r+(t-i)*.125));continue}}else if(s.y>o(t))continue;d.push(s)}this.flakes=d}};function l(e){let t=e>>>0;return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var u=[`#c8503f`,`#d9a441`,`#4a7fa5`,`#7a9b64`,`#b5651d`,`#a63d5a`,`#c9b458`,`#3f6d8e`,`#d07a4a`,`#8a5a83`,`#c05a4a`,`#5d8a68`,`#caa06a`,`#456b93`];function d(e=1864){let t=l(e),n=[],r=.015;for(;r<.985;){let e=.055+t()*.045;if(r+e>.99)break;let i=t(),a=2+Math.floor(t()*2),o=2+Math.floor(t()*3),s=[];for(let e=0;e<a*o;e++)s.push(t()<.62);n.push({x:r+e/2,w:e,h:.24+t()*.16,color:u[Math.floor(t()*u.length)]??`#c8503f`,gable:i<.45?`tri`:i<.85?`step`:`flat`,cols:a,rows:o,lit:s,crane:t()<.16}),r+=e+.004}let i=[.14,.38,.62,.86],a=[],o=[`#2b3a55`,`#5a2b2b`,`#2f4a3a`,`#4a3a5a`,`#1f2937`,`#6b4a2f`];for(let e=0;e<7;e++)a.push({x:t(),speed:.012+t()*.02,dir:t()<.5?1:-1,h:.05+t()*.018,coat:o[Math.floor(t()*o.length)]??`#2b3a55`});return{houses:n,lamps:i,people:a}}var f={day:{skyTop:`#8fb4d4`,skyBottom:`#dcebf4`,far:`#93a9bd`,water:`#3c5f7a`,quay:`#cfd9e2`,snow:`#ffffff`,snowShade:`#dfe7f0`,lit:!1,stars:!1,glow:`rgba(255,220,140,0)`},dusk:{skyTop:`#3d3a68`,skyBottom:`#e8935a`,far:`#5b5378`,water:`#3a3a63`,quay:`#b9a9b8`,snow:`#f4e9ec`,snowShade:`#d8c4cf`,lit:!0,stars:!1,glow:`rgba(255,190,110,0.55)`},night:{skyTop:`#0a142e`,skyBottom:`#20375e`,far:`#2c4060`,water:`#12203c`,quay:`#5f7392`,snow:`#dbe6f5`,snowShade:`#b9c9e0`,lit:!0,stars:!0,glow:`rgba(255,205,130,0.7)`}};function p(e,t,n,r){let i=f[n],a=e.createLinearGradient(0,t.cy-t.r,0,t.cy+t.r);if(a.addColorStop(0,i.skyTop),a.addColorStop(1,i.skyBottom),e.fillStyle=a,e.fillRect(t.cx-t.r,t.cy-t.r,t.r*2,t.r*2),i.stars){let n=l(7);e.fillStyle=`rgba(255,255,255,0.9)`;for(let i=0;i<40;i++){let a=t.cx+(n()*2-1)*t.r*.9,o=t.cy-t.r+n()*t.r*.9;e.globalAlpha=.25+.55*(.5+.5*Math.sin(r*2+i)),e.fillRect(a,o,1.6,1.6)}e.globalAlpha=1;let i=t.cx+t.r*.45,a=t.cy-t.r*.62,o=e.createRadialGradient(i,a,0,i,a,t.r*.16);o.addColorStop(0,`rgba(240,240,220,0.95)`),o.addColorStop(.35,`rgba(240,240,220,0.85)`),o.addColorStop(1,`rgba(240,240,220,0)`),e.fillStyle=o,e.beginPath(),e.arc(i,a,t.r*.16,0,Math.PI*2),e.fill()}}function m(e,t,n){let r=f[n],i=o(t);e.fillStyle=r.far;let a=t.cx-t.r*.52,s=t.r*.075,c=t.r*.34;e.fillRect(a-s/2,i-c,s,c);let l=t.r*.3;e.beginPath(),e.moveTo(a-s/2,i-c),e.lineTo(a,i-c-l),e.lineTo(a+s/2,i-c),e.closePath(),e.fill(),e.strokeStyle=`rgba(255,255,255,0.35)`,e.lineWidth=Math.max(1,t.r*.006),e.beginPath();for(let n=0;n<=60;n++){let r=n/60,o=i-c-l*r,u=s/2*(1-r)+t.r*.004,d=a+Math.sin(r*6*Math.PI*2)*u;n===0?e.moveTo(d,o):e.lineTo(d,o)}e.stroke(),e.fillStyle=r.lit?`#e8c060`:`#c9b98a`,e.beginPath(),e.arc(a,i-c-l-t.r*.018,t.r*.016,0,Math.PI*2),e.fill();let u=t.cx+t.r*.5,d=t.r*.16,p=t.r*.2;e.fillStyle=r.far,e.fillRect(u-d/2,i-p,d,p),e.fillRect(u-d*.22,i-p-t.r*.12,d*.44,t.r*.12);let m=t.cx+t.r*.12,h=t.r*.26;e.fillRect(m-t.r*.03,i-h,t.r*.06,h),e.beginPath(),e.moveTo(m-t.r*.045,i-h),e.lineTo(m,i-h-t.r*.11),e.lineTo(m+t.r*.045,i-h),e.closePath(),e.fill()}function h(e,t,n,r,i){let a=f[n],s=o(t),c=Math.sqrt(Math.max(0,t.r*t.r-(s-t.cy)*(s-t.cy))),l=t.cx-c,u=c*2,d=Math.max(1.5,t.r*.012);for(let i of r.houses){let r=l+i.x*u,o=i.w*u/2,c=i.h*t.r,f=s-c;if(e.fillStyle=i.color,e.fillRect(r-o,f,o*2,c),e.beginPath(),i.gable===`tri`)e.moveTo(r-o,f),e.lineTo(r,f-o*.75),e.lineTo(r+o,f);else if(i.gable===`step`){let t=o*2/7,n=o*.7/3;e.moveTo(r-o,f);let i=r-o,a=f;for(let r=0;r<3;r++)e.lineTo(i+t,a),e.lineTo(i+t,a-n),i+=t,a-=n;e.lineTo(i+t,a),i+=t;for(let r=0;r<3;r++)e.lineTo(i+t,a),e.lineTo(i+t,a+n),i+=t,a+=n;e.lineTo(r+o,f)}else e.rect(r-o,f-o*.18,o*2,o*.18);e.closePath(),e.fill(),e.strokeStyle=a.snow,e.lineWidth=d,e.lineJoin=`round`,e.beginPath(),i.gable===`tri`?(e.moveTo(r-o,f),e.lineTo(r,f-o*.75),e.lineTo(r+o,f)):(e.moveTo(r-o,f),e.lineTo(r+o,f)),e.stroke(),i.crane&&(e.strokeStyle=`#3a3128`,e.lineWidth=Math.max(1,t.r*.006),e.beginPath(),e.moveTo(r+o*.5,f-o*.3),e.lineTo(r+o*.5,f-o*1.3),e.lineTo(r-o*.35,f-o*1.05),e.moveTo(r+o*.5,f-o*1.3),e.lineTo(r+o*.95,f-o*1.05),e.stroke());let p=o*2/(i.cols*1.9),m=c*.72/(i.rows*1.55);for(let s=0;s<i.cols;s++)for(let l=0;l<i.rows;l++){let u=r-o+o*2*((s+.5)/i.cols)-p/2,d=f+c*.12+c*.78*(l/i.rows);a.lit&&(i.lit[s*i.rows+l]??!1)?(e.fillStyle=`#ffd98a`,e.fillRect(u,d,p,m),e.fillStyle=a.glow,e.fillRect(u-p*.4,d-m*.4,p*1.8,m*1.8)):(e.fillStyle=n===`night`?`#1c2c48`:`rgba(30,40,55,0.55)`,e.fillRect(u,d,p,m)),e.fillStyle=a.snow,e.fillRect(u,d,p,Math.max(1,t.r*.004))}}for(let n of r.lamps){let r=l+n*u,o=s-i(r),c=t.r*.16;e.strokeStyle=`#22303f`,e.lineWidth=Math.max(1.2,t.r*.008),e.beginPath(),e.moveTo(r,o),e.lineTo(r,o-c),e.stroke();let d=t.r*.016;if(a.lit){let t=e.createRadialGradient(r,o-c,0,r,o-c,d*6);t.addColorStop(0,`rgba(255,215,140,0.85)`),t.addColorStop(1,`rgba(255,215,140,0)`),e.fillStyle=t,e.beginPath(),e.arc(r,o-c,d*6,0,Math.PI*2),e.fill(),e.fillStyle=`#ffe6ad`}else e.fillStyle=`#5a6a7a`;e.beginPath(),e.arc(r,o-c-d,d,0,Math.PI*2),e.fill(),e.fillStyle=a.snow,e.beginPath(),e.ellipse(r,o-c-d*2.1,d*1.3,d*.5,0,0,Math.PI*2),e.fill()}}function g(e,t,n,r,i){let a=o(t),s=Math.sqrt(Math.max(0,t.r*t.r-(a-t.cy)*(a-t.cy))),c=t.cx-s,l=s*2;for(let o of n.people){let n=c+o.x*l,s=a-r(n),u=o.h*t.r,d=Math.sin(i*6*(o.speed/.02))*u*.22;e.strokeStyle=o.coat,e.fillStyle=o.coat,e.lineWidth=Math.max(1.4,u*.16),e.lineCap=`round`,e.beginPath(),e.moveTo(n,s-u*.75),e.lineTo(n,s-u*.3),e.stroke(),e.beginPath(),e.arc(n,s-u*.88,u*.14,0,Math.PI*2),e.fill(),e.beginPath(),e.moveTo(n,s-u*.3),e.lineTo(n+d,s),e.moveTo(n,s-u*.3),e.lineTo(n-d,s),e.stroke()}}function _(e,t,n,r){let i=f[n],a=o(t),s=Math.sqrt(Math.max(0,t.r*t.r-(a-t.cy)*(a-t.cy))),c=t.cx-s,l=s*2;e.fillStyle=i.snow,e.beginPath(),e.moveTo(c,a);for(let t=0;t<=96;t++){let n=c+l*t/96;e.lineTo(n,a-r(n))}e.lineTo(c+l,a),e.closePath(),e.fill(),e.strokeStyle=`rgba(255,255,255,0.8)`,e.lineWidth=Math.max(1,t.r*.005),e.beginPath();for(let t=0;t<=96;t++){let n=c+l*t/96,i=a-r(n);t===0?e.moveTo(n,i):e.lineTo(n,i)}e.stroke()}function v(e,t,n){let r=f[n],i=o(t);e.fillStyle=r.quay,e.fillRect(t.cx-t.r,i,t.r*2,t.r)}var y=`aos-day3-copenhagen-globe`;function b(){let e={density:1,theme:`dusk`,drift:[],shakes:0};try{let t=localStorage.getItem(y);if(!t)return e;let n=JSON.parse(t);return{density:typeof n.density==`number`?n.density:e.density,theme:n.theme===`day`||n.theme===`dusk`||n.theme===`night`?n.theme:e.theme,drift:Array.isArray(n.drift)?n.drift:[],shakes:typeof n.shakes==`number`?n.shakes:0}}catch{return e}}var x=document.getElementById(`app`);if(!x)throw Error(`missing #app`);x.innerHTML=`
<header>
<h1>Københavnerkuglen</h1>
<p class="sub">A snow globe of Copenhagen. Grab it and <em>shake</em> it — or just hit the button.</p>
</header>
<div id="stage">
<canvas id="globe" aria-label="A snow globe of Copenhagen's Nyhavn with falling snow"></canvas>
</div>
<div id="hud">
<span id="stat-drift" class="stat"></span>
<span id="stat-flakes" class="stat"></span>
<span id="stat-shakes" class="stat"></span>
</div>
<div id="controls">
<button id="shake-btn" type="button">🌨️ Ryst den!</button>
<label class="ctl">Sne
<input id="density" type="range" min="0" max="4" step="1" />
</label>
<div class="ctl themes" role="group" aria-label="Time of day">
<button type="button" data-theme="day">Dag</button>
<button type="button" data-theme="dusk">Aften</button>
<button type="button" data-theme="night">Nat</button>
</div>
<button id="sweep-btn" type="button" title="Shovel the drift away">🧹 Fej snescooten</button>
</div>
<p class="hint">Tip: click the drift for a puff, or press <kbd>space</kbd> to shake.</p>
`;var S=document.getElementById(`globe`),C=S.getContext(`2d`);if(!C)throw Error(`no 2d context`);var w=document.getElementById(`stat-drift`),T=document.getElementById(`stat-flakes`),E=document.getElementById(`stat-shakes`),ee=document.getElementById(`shake-btn`),D=document.getElementById(`sweep-btn`),O=document.getElementById(`density`),k=Array.from(document.querySelectorAll(`#controls .themes button`)),A=b(),j=A.theme,M=A.shakes,N=d(),P=new c({cx:0,cy:0,r:1});P.target=i[A.density]??i[1],O.value=String(A.density);var F={cx:0,cy:0,r:1},I=1;function L(){let e=document.getElementById(`stage`),t=Math.min(e.clientWidth,620);I=window.devicePixelRatio||1,S.width=Math.round(t*I),S.height=Math.round(t*1.12*I),S.style.width=`${t}px`,S.style.height=`${t*1.12}px`,F={cx:t*I/2,cy:t*I*1.12/2-t*I*.02,r:t*I*.42},P.resize(F)}L(),A.drift.length>0&&P.loadDrift(A.drift),window.addEventListener(`resize`,L);var R=0,z=0;function B(e){let t=Math.min(1,e);R=Math.max(R,F.r*.055*t),P.shake(t),M+=1,Y()}var V=!1,H=0,U=0,W=0,G=[],K=!1;S.addEventListener(`pointerdown`,e=>{V=!0,K=!1,H=e.clientX,U=performance.now(),W=0,G=[],S.setPointerCapture(e.pointerId)}),S.addEventListener(`pointermove`,e=>{if(!V)return;let t=performance.now(),n=Math.max(1,t-U)/1e3,r=(e.clientX-H)/n;Math.abs(e.clientX-H)>2&&(K=!0),Math.abs(r)>F.r*1.2&&Math.sign(r)!==Math.sign(W)&&W!==0&&(G.push(t),G=G.filter(e=>t-e<700),G.length>=2&&(B(.45+.55*Math.min(1,Math.abs(r)/(F.r*6))),G=[])),Math.abs(r)>20&&(W=r),H=e.clientX,U=t}),S.addEventListener(`pointerup`,e=>{if(V=!1,!K){let t=S.getBoundingClientRect(),n=(e.clientX-t.left)*I,r=(e.clientY-t.top)*I;Math.hypot(n-F.cx,r-F.cy)<F.r*.95&&P.puff(n,r)}}),ee.addEventListener(`click`,()=>B(.9)),window.addEventListener(`keydown`,e=>{e.code===`Space`&&!(e.target instanceof HTMLButtonElement)&&(e.preventDefault(),B(.85))}),D.addEventListener(`click`,()=>{P.sweep(),Y()}),O.addEventListener(`input`,()=>{P.target=i[Number(O.value)]??i[1],Y()});for(let e of k)e.addEventListener(`click`,()=>{let t=e.dataset.theme;(t===`day`||t===`dusk`||t===`night`)&&(j=t,q(),Y())});function q(){for(let e of k)e.classList.toggle(`active`,e.dataset.theme===j)}q();var J=0;function Y(){window.clearTimeout(J),J=window.setTimeout(X,400)}function X(){let e={density:Number(O.value),theme:j,drift:P.serializeDrift(),shakes:M};try{localStorage.setItem(y,JSON.stringify(e))}catch{}}window.addEventListener(`beforeunload`,X),window.setInterval(X,1e4);function te(){let{cx:e,cy:t,r:n}=F,r=t+n*.78,i=n*.62,a=n*.95,o=n*.34,s=C.createLinearGradient(e-i,0,e+i,0);s.addColorStop(0,`#7a5c2e`),s.addColorStop(.5,`#d9b45f`),s.addColorStop(1,`#7a5c2e`),C.fillStyle=s,C.beginPath(),C.moveTo(e-i,r),C.lineTo(e+i,r),C.lineTo(e+i*1.06,r+n*.07),C.lineTo(e-i*1.06,r+n*.07),C.closePath(),C.fill();let c=C.createLinearGradient(e-a,0,e+a,0);c.addColorStop(0,`#3a2417`),c.addColorStop(.5,`#6b4226`),c.addColorStop(1,`#3a2417`),C.fillStyle=c,C.beginPath(),C.moveTo(e-i*1.06,r+n*.07),C.lineTo(e+i*1.06,r+n*.07),C.lineTo(e+a,r+o),C.lineTo(e-a,r+o),C.closePath(),C.fill(),C.fillStyle=`#caa95c`;let l=n*.42,u=n*.085,d=r+o*.52;C.beginPath(),C.roundRect(e-l/2,d-u/2,l,u,u*.3),C.fill(),C.fillStyle=`#3a2417`,C.font=`700 ${Math.round(u*.52)}px system-ui, sans-serif`,C.textAlign=`center`,C.textBaseline=`middle`,C.fillText(`KØBENHAVN`,e,d+u*.04)}function ne(){let{cx:e,cy:t,r:n}=F;C.lineWidth=Math.max(2,n*.014),C.strokeStyle=`rgba(210,225,240,0.5)`,C.beginPath(),C.arc(e,t,n,0,Math.PI*2),C.stroke(),C.save(),C.beginPath(),C.arc(e,t,n,0,Math.PI*2),C.clip();let r=C.createLinearGradient(e-n,t-n,e-n*.2,t+n*.2);r.addColorStop(0,`rgba(255,255,255,0.34)`),r.addColorStop(.5,`rgba(255,255,255,0.06)`),r.addColorStop(1,`rgba(255,255,255,0)`),C.fillStyle=r,C.fillRect(e-n,t-n,n*2,n*2),C.fillStyle=`rgba(255,255,255,0.5)`,C.beginPath(),C.ellipse(e-n*.45,t-n*.55,n*.1,n*.05,-.7,0,Math.PI*2),C.fill();let i=C.createRadialGradient(e,t,n*.75,e,t,n);i.addColorStop(0,`rgba(20,30,50,0)`),i.addColorStop(1,`rgba(20,30,50,0.28)`),C.fillStyle=i,C.fillRect(e-n,t-n,n*2,n*2),C.restore()}var Z=performance.now(),Q=0;function $(e){let t=Math.min(.033,(e-Z)/1e3);Z=e,Q+=t;let n=0,r=0;R>.5?(z+=t*34,R*=Math.exp(-t*3.2),n=Math.sin(z)*R,r=Math.sin(z*.8+1.2)*R*.35):R=0;for(let e of N.people)e.x+=e.speed*e.dir*t,e.x>.99&&(e.dir=-1),e.x<.01&&(e.dir=1);P.update(t);let i=S.width,a=S.height;C.clearRect(0,0,i,a),C.save(),C.translate(n,r),C.save(),C.beginPath(),C.arc(F.cx,F.cy,F.r,0,Math.PI*2),C.clip(),p(C,F,j,Q),m(C,F,j),v(C,F,j),h(C,F,j,N,e=>P.driftAt(e)),g(C,F,N,e=>P.driftAt(e),Q),_(C,F,j,e=>P.driftAt(e)),C.fillStyle=j===`night`?`#e8f0fb`:`#ffffff`;for(let e of P.flakes)C.globalAlpha=e.alpha,C.beginPath(),C.arc(e.x,e.y,e.r,0,Math.PI*2),C.fill();C.globalAlpha=1,C.restore(),ne(),te(),C.restore(),w.textContent=`drift: ${P.driftDepthCm().toFixed(1)} cm`,T.textContent=`flakes: ${P.flakes.length}`,E.textContent=`shakes: ${M}${M>=100?` 💪`:``}`,requestAnimationFrame($)}requestAnimationFrame($);