memoscan
← all memos

Memo 0x3e89e634…d4bbb2 on Ethereum

let l=PolyBool.difference(i,n);for(let t=0;t<l.regions.length;t++){let n=l.regions[t],i=It(n);if(n.length>0&&i>P){let t=lr()<.9?mt(n,r):this.allExistingPolys[e].vars,l=new ct(n,t,i,!0);o.push(l)}else i<P&&i>ee&&te.push(n)}}else o.push(this.allExistingPolys[e])}this.allExistingPolys=[...o]}sortPolys(e,t=null){dt(this.allExistingPolys,e,t)}}function dt(e,t,r=null){"xA"==t?e.sort(((e,t)=>e.bL.x-t.bL.x)):"xD"==t?e.sort(((e,t)=>t.bL.x-e.bL.x)):"yA"==t?e.sort(((e,t)=>e.bL.y-t.bL.y)):"yD"==t?e.sort(((e,t)=>t.bL.y-e.bL.y)):"random"==t?e.sort(((e,t)=>Te(e.bL.y)-Te(t.bL.y))):"distance"==t&&e.sort(((e,t)=>e.center.distanceToSquared(r)-t.center.distanceToSquared(r)))}function pt(e){let t=1-G*(1-e)/g;return[hr(-G*e,b*t),hr(G*e,b*t),hr(G*e,-b*t),hr(-G*e,-b*t)]}function gt(e,t,r){let n=t.x-e.x,o=t.y-e.y,i=hr(.5*(t.x+e.x),.5*(t.y+e.y));var l=new Ur({shape:[n,o],radius:r,tries:50}).fill();for(let e=0;e<l.length;e++)l[e][0]-=.5*n,l[e][1]-=.5*o,l[e][0]+=i.x,l[e][1]+=i.y;return l}function yt(e,t=.05){return Math.abs(e.x)<G+t&&Math.abs(e.y)<b+t}let vt=hr(1024.644,39582.48823),xt=hr(45.6399,324.56641);function bt(e){let t=pr(e,3,2*N,xt),r=hr(pr(e,6,.003,vt),0);return r.rotateAround(O,t),e.add(r)}function mt(e,t,r=null){return{colors:t<0?x.getRandomColor():x.getNColor(e,t),tier:t<0?0:t,type:r}}function wt(e,t,r,n=null,o=!0,i=!1){t.addPoly(e,mt(e,r,n),o,i)}function Pt(e,t,r,n=!1,o=!1){let i=hr(r,0).rotateAround(O,t);i.x=tr(i.x,$),i.y=tr(i.y,$);hr(.1,0).rotateAround(O,t);let l=or(e);const s=new t3.Shape(l);let a=i.x,u=i.y;var h=new t3.Matrix4;h.set(1,0,a,0,0,1,u,0,0,0,1,0,0,0,0,1);const c=new t3.ExtrudeGeometry(s,{steps:1,depth:1,bevelEnabled:!1});c.applyMatrix4(h),c.verticesNeedUpdate=!0;let f=[];const d=c.vertices;for(let e=0;e<c.faces.length;e++){const t=c.faces[e];let r=[[d[t.a].x,d[t.a].y],[d[t.b].x,d[t.b].y],[d[t.c].x,d[t.c].y],[d[t.a].x,d[t.a].y]];f.push(r)}let p=Tt(f),g=[...e];if(n&&Et(g,i.clone()),o){const e=Rt(g);let t=[];for(let r=0;r<p.length;r++){const n=Rt(p[r]);let o={regions:[]};try{o=PolyBool.difference(n,e)}catch(e){t=p;break}for(let e=0;e<o.regions.length;e++){let r=o.regions[e];r.length>0&&(Wt(r),St(r),t.push(r))}}return{face:g,edges:t}}return{face:g,edges:p}}function Rt(e,t=!1){return{regions:[e],inverted:t}}let Ct=hr();function Bt(e,t,r=null,n=!1,o=!1){let i,l=e;o&&(l=[...e]),null==r?i=O:null==r.x?(Ct.set(r[0],r[1]),i=Ct):i=r;for(let r=0;r<l.length;r++){let o=e[r][0],s=e[r][1];n&&(o-=i.x,s-=i.y),o*=t,s*=t,n&&(o+=i.x,s+=i.y),l[r]=[o,s]}if(o)return l}function Et(e,t,r=!1,n=!1){let o=[];for(let i=0;i<e.length;i++){let l=e[i][0]+t.x,s=e[i][1]+t.y;r?n?o.push([tr(l,$),tr(s,$)]):e[i]=[tr(l,$),tr(s,$)]:n?o.push([l,s]):e[i]=[l,s]}if(n)return o}function Lt(e,t,r=null,n=!1,o=!1){let i,l=e;o&&(l=[...e]),null==r?i=O:null==r.x?(Ct.set(r[0],r[1]),i=Ct):i=r;let s=hr();for(let e=0;e<l.length;e++)s.set(l[e][0],l[e][1]),n?(s.sub(i),s.rotateAround(O,t),s.add(i)):s.rotateAround(i,t),l[e]=[s.x,s.y];if(o)return l}function St(e){for(let t=0;t<e.length;t++){let r=tr(e[t][0],$),n=tr(e[t][1],$);e[t]=[r,n]}}function Tt(e){let t=[];for(let r=0;r<e.length;r++){St(e[r]);let n=Rt(e[r]);t.push(n)}var r,n;let o;try{for(var i=PolyBool.segments(t[0]),l=1;l<t.length;l++){r=PolyBool.segments(t[l]);try{n=PolyBool.combine(i,r)}catch(e){continue}i=PolyBool.selectUnion(n)}o=PolyBool.polygon(i);for(let e=0;e<o.regions.length;e++)Wt(o.regions[e]),St(o.regions[e])}catch(e){return[]}return o.regions}function kt(e,t=!1){var r,n,o,i;let l=!1,s=!1;null!=e[0].x?(r=e[0].x,n=e[0].x,o=e[0].y,i=e[0].y,s=e[0].x==e[e.length-1].x&&e[0].y==e[e.length-1].y):(l=!0,s=e[0][0]==e[e.length-1][0]&&e[0][1]==e[e.length-1][1],r=e[0][0],n=e[0][0],o=e[0][1],i=e[0][1]);for(let t=s?1:0;t<e.length;t++){var a=e[t];r=Math.min(l?a[0]:a.x,r),n=Math.max(l?a[0]:a.x,n),o=Math.min(l?a[1]:a.y,o),i=Math.max(l?a[1]:a.y,i)}let u=hr(r,i),h=hr(n,i),c=hr(n,o),f=hr(r,o),d=hr(.5*(f.x+h.x),.5*(f.y+h.y));return t?[u,h,c,f,d]:[u,h,c,f]}function Mt(e){return[e.tL,e.tR,e.bR,e.bL]}function At(e,t){for(var r=!1,n=t[0][0],o=t[0][0],i=t[0][1],l=t[0][1],s=1;s<t.length;s++){var a=t[s];n=Math.min(a[0],n),o=Math.max(a[0],o),i=Math.min(a[1],i),l=Math.max(a[1],l)}if(e[0]<=n||e[0]>=o||e[1]<=i||e[1]>=l)return!1;for(var u=0,h=t.length-1;u<t.length;h=u++)t[u][1]>=e[1]!=t[h][1]>=e[1]&&e[0]<=(t[h][0]-t[u][0])*(e[1]-t[u][1])/(t[h][1]-t[u][1])+t[u][0]&&(r=!r);return r}function It(e){if(e.length<3)return;let t=e;null!=e[0].x&&(t=Kt(e));for(var r=0,n=0,o=t.length;n<o;n++){r+=t[n][0]*t[n==t.length-1?0:n+1][1]*.5,r-=t[n==t.length-1?0:n+1][0]*t[n][1]*.5}return Math.abs(r)}function Wt(e){if(e[0][0]==e[e.length-1][0]&&e[0][1]==e[e.length-1][1])return;let t=[e[0][0],e[0][1]];e.push(t)}function Ft(e,t){let r=null;if(rr(e),t<=0)return e;try{r=h.data(e).arcSegments(4).padding(t)}catch(e){}return r}function Nt(e,t=!1,r=!1){let n,o,i,l=e;switch(r&&("oilBorder"==e?l="oilSmall":"waterColorBorder"==e?l="waterColorSmall":"inverted"==e?l="inverted":"spacedOut"==e?l="spacedOut":"skeleton"==e?l="skeleton":"messy"==e&&(l="messy")),t&&("oilBorder"==e?l="oilNoBorder":"waterColorBorder"==e?l="waterColorNoBorder":"inverted"==e||"spacedOut"==e?l="oilNoBorder":"skeleton"==e?l="skeleton":"messy"==e&&(l="oilNoBorder")),l){case"oilBorder":o="normal",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:2.5,borderPosition:0,borderThickness:3,shapeMask:!0,enableShading:!0};break;case"waterColorBorder":o="waterColor",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:4,borderPosition:2,borderThickness:0,shapeMask:!0,enableShading:!0};break;case"oilNoBorder":o="normal",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:10,borderPosition:0,borderThickness:0,shapeMask:!0,enableShading:!1};break;case"oilSmall":o="normal",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:2,borderPosition:0,borderThickness:0,shapeMask:!0,enableShading:!1};break;case"waterColorNoBorder":o="waterColor",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:20,borderPosition:0,borderThickness:0,shapeMask:!0,enableShading:!1};break;case"waterColorSmall":o="waterColor",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:2,borderPosition:0,borderThickness:0,shapeMask:!0,enableShading:!1};break;case"sigThin":o="sigThin",i=j[o].brushWidth,n={fillMode:"path",brushType:o,fillPosition:0,borderPosition:0,borderThickness:0,shapeMask:!1,enableShading:!1,colors:[ur(10,10,10),ur(10,10,10)]};break;case"sigThick":o="sigThick",i=j[o].brushWidth,n={fillMode:"path",brushType:o,fillPosition:0,borderPosition:0,borderThickness:0,shapeMask:!1,enableShading:!1,colors:[ur(10,10,10),ur(10,10,10)]};break;case"inverted":o="normal",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:-50,borderPosition:-13,borderThickness:36,shapeMask:!0,enableShading:!0};break;case"lines":o="thin",i=j[o].brushWidth,n={fillMode:"lines",brushType:o,fillPosition:0,borderPosition:0,borderThickness:0,shapeMask:!1,enableShading:!1,offset:A,angle:M};break;case"messy":o="messy",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:20,borderPosition:18,borderThickness:0,shapeMask:!0,enableShading:!1};break;case"spacedOut":o="normal",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:-7,borderPosition:-10,borderThickness:5,shapeMask:!0,enableShading:!0};break;case"skeleton":o="normal",i=j[o].brushWidth,n={fillMode:"offset",brushType:o,offset:.6*-i,initOffset:0,max:100,fillPosition:-2048,borderPosition:-20,borderThickness:12,shapeMask:!0,enableShading:!0};break;case"outline":o="thin",i=j[o].brushWidth,n={fillMode:"path",brushType:o,offset:-i,initOffset:0,max:100,fillPosition:-2048,borderPosition:0,borderThickness:10,shapeMask:!1,enableShading:!1};break;case"tiny":o="sortOfThin",i=j[o].brushWidth,n={fillMode:"path",brushType:o,fillPosition:0,borderPosition:0,borderThickness:0,shapeMask:!1,enableShading:!1}}return n}function Ot(){let e=G/b,t=window.innerHeight;window.innerWidth/t>e?(s.domElement.style.width="auto",s.domElement.style.height="100%"):(s.domElement.style.width="100%",s.domElement.style.height="auto")}let _t=0,Dt=1,qt=!1,Vt=0,zt=!1;let jt=!1;function Ut(e){if(!e&&!zt)return void window.alert("Please wait for rendering to finish before saving the image.");jt=!0;let t=fe.toString(),r=6-t.length,n="";for(let e=0;e<r;e++)n+="0";let o=n+t+"_",l=_t.toString();r=6-l.length,n="";for(let e=0;e<r;e++)n+="0";let a=n+l,u=document.createElement("a");u.setAttribute("download",a+ce+"_"+x.fullPalette.name+"_"+d+"_ "+o+de+"_"+tokenData.hash+".png");let h=hr(y,v);"skeleton"!=Me?(R.render(B.scene,i),C.render(E.scene,i),L.render(S.scene,i,!0)):(R.render(B.scene,i),C.render(E.scene,i,!0)),s.domElement.toBlob((function(t){let r=URL.createObjectURL(t);const n=document.createElement("canvas"),o=n.getContext("2d");o.canvas.width=h.x,o.canvas.height=h.y,o.fillRect(0,0,o.canvas.width,o.canvas.height);const i=new Image;i.onload=function(){o.drawImage(i,0,0,h.x,h.y);let t=n.toDataURL("image/png").replace("image/png","image/octet-stream");u.setAttribute("href",t),u.click(),n.remove(),u.remove(),e&&setTimeout((function(){T.dispose(),k.dispose(),C.dispose(),R.dispose(),L.dispose();let e=(parseInt(ke.e)+1).toString();window.location.href="http://127.0.0.1:8080/?e="+e}),2e3)},i.src=r}))}function Ht(e,t,r){const n=e,o=e,i=new Uint8Array(n*o*(r>1?4:1)),l=1e3;let s=0,a=[],u=[];for(let e=0;e<r;e++)a.push(lr(-l,l)),u.push(lr(-l,l));let h=hr();hr(1,1);for(let e=0;e<o;e++)for(let l=0;l<n;l++)for(let c=0;c<r;c++){let r=0;h.set((l/(n-1)*2-1)*t+a[c],(e/(o-1)*2-1)*t+u[c]),r=Dr(h.x,h.y),i[s++]=128*r+128}let c=t3.RedFormat;r>1&&(c=t3.RGBAFormat);let f=new t3.DataTexture(i,n,o,c);return f.format=c,f.wrapS=t3.MirroredRepeatWrapping,f.wrapT=t3.MirroredRepeatWrapping,f.minFilter=t3.LinearFilter,f.magFilter=t3.LinearFilter,f.unpackAlignment=1,f.needsUpdate=!0,f}function Xt(e,t,r){let n=[],o=.5*e.x,i=.5*e.y,l=hr(-o,i).rotateAround(O,r).add(t),s=hr(o,i).rotateAround(O,r).add(t),a=hr(o,-i).rotateAround(O,r).add(t),u=hr(-o,-i).rotateAround(O,r).add(t);return n.push([l.x,l.y],[s.x,s.y],[a.x,a.y],[u.x,u.y],[l.x,l.y]),n}function Yt(e,t,r){let n=[];for(let o=0;o<e.length;o+=2){let i=tr((e[o+0]-1500)*t+r.x,$),l=tr((e[o+1]-1400)*-t+r.y,$);n.push([i,l])}return n}function Jt(e,t,r,n,o,i,l=_,s=-1,a=null,u=!0){let h=2*N/e,c=[],f=-1==s?lr(0,20*N):s;for(let d=0;d<e;d++){let e=hr(t,0);if(e.rotateAround(O,h*d+f),e.multiply(l),e.add(r),null!=a&&e.rotateAround(a,s),o>0)if(u)e.add(gr(e,n,o,i));else{let t=hr(o,0);t.rotateAround(O,2*pr(e,n.x,1,i)*N),e.add(t)}c.push([e.x,e.y])}return c.push([c[0][0],c[0][1]]),c}function Gt(e,t,r,n,o,i,l,s=O,a=!0){let u=[],h=.5*e.x,c=.5*e.y,f=hr(-h,c),d=hr(h,c),p=hr(h,-c),g=hr(-h,-c),y=hr();for(let e=f.x;e<d.x;e+=n){if(y.set(e,d.y),y.rotateAround(s,r).add(t),i>0)if(a)y.add(gr(y,o,i,l));else{let e=.1*Math.round(10*pr(y,o.x,1,O))*2*N,t=hr(1,0).rotateAround(O,e).multiplyScalar(i);y.add(t)}u.push([y.x,y.y])}for(let e=d.y;e>p.y;e-=n){if(y.set(p.x,e),y.rotateAround(s,r).add(t),i>0)if(a)y.add(gr(y,o,i,l));else{let e=.1*Math.round(10*pr(y,o.x,1,O))*2*N,t=hr(1,0).rotateAround(O,e).multiplyScalar(i);y.add(t)}u.push([y.x,y.y])}for(let e=p.x;e>g.x;e-=n){if(y.set(e,g.y),y.rotateAround(s,r).add(t),i>0)if(a)y.add(gr(y,o,i,l));else{let e=.1*Math.round(10*pr(y,o.x,1,O))*2*N,t=hr(1,0).rotateAround(O,e).multiplyScalar(i);y.add(t)}u.push([y.x,y.y])}for(let e=g.y;e<f.y;e+=n){if(y.set(f.x,e),y.rotateAround(s,r).add(t),i>0)if(a)y.add(gr(y,o,i,l));else{let e=.1*Math.round(10*pr(y,o.x,1,O))*2*N,t=hr(1,0).rotateAround(O,e).multiplyScalar(i);y.add(t)}u.push([y.x,y.y])}return Wt(u),u}function Qt(e,t,r,n){const o=e,i=t,l=r,s=n,a=i[0]-o[0],u=i[1]-o[1],h=s[0]-l[0],c=s[1]-l[1],f=a*c-h*u;if(0==f)return;const d=o[0]-l[0],p=o[1]-l[1],g=a*p-u*d;if(g<0==f>0)return;const y=h*p-c*d;if(y<0==f>0)return;if(g>f==f>0||y>f==f>0)return;const v=y/f;return[tr(o[0]+v*a,$),tr(o[1]+v*u,$)]}function $t(e){let t=[];for(let r=0;r<e.length;r++)t.push([e[r][0],e[r][1]]);return t}function Kt(e){let t=[];for(let r=0;r<e.length;r++)t.push([e[r].x,e[r].y]);return t}function Zt(e){return hr(e[0],e[1])}function er(e){return[e.x,e.y]}function tr(e,t){var r=Math.pow(10,t||0);return Math.round(e*r)/r}function rr(e){for(let t=0;t<e.length-1;t++)e[t][0]+=lr(-.0015,.0015),e[t][1]+=lr(-.0015,.0015);e[e.length-1][0]=e[0][0],e[e.length-1][1]=e[0][1]}function nr(e){let t,r=e.length;for(;0!=r;)t=Math.floor(lr(0,1)*r),r--,[e[r],e[t]]=[e[t],e[r]];return e}function or(e){let t=[];for(let r=0;r<e.length;r++)t.push(hr(e[r][0],e[r][1]));return t}function ir(e,t,r){return Math.floor(lr(e,t-1e-6,r))}function lr(e=0,t=1,r=1){let n=u.random_dec();return Math.pow(n,r)*(t-e)+e}function sr(e=0,t=0,r=0){return new t3.Color(e,t,r)}function ar(e=0){return new t3.Color(e)}function ur(e=0,t=0,r=0){return new t3.Vector3(e,t,r)}function hr(e=0,t=0){return new t3.Vector2(e,t)}function cr(){return t3.Math}function fr(){return lr(0,100)}function dr(e,t,r,n){let o=r-e,i=n-t;return Math.sqrt(i*i+o*o)}function pr(e,t,r,n){let o=V.set(e.x,e.y).multiplyScalar(t);return o.add(hr(n.x+m.x,n.y+m.y)),Dr(o.x,o.y)*r}function gr(e,t,r,n){let o=e,i=1e-5,l=o.x+n.x+m.x,s=o.y+n.y+m.y;l*=t.x,s*=t.y;var a=Dr(l+i,s),u=Dr(l-i,s),h=(a-u)/(2*i);return hr(((a=Dr(l,s+i))-(u=Dr(l,s-i)))/(2*i),-h).rotateAround(O,w).multiplyScalar(r)}class yr{constructor(e){this.colors=e}}class vr{constructor(){let e=lr(),t=e<.01?0:e<.03?1:e<.06?2:e<.1?3:e<.14?4:e<.22?5:e<.3?6:e<.38?7:e<.47?8:e<.57?9:e<.66?10:e<.76?11:e<.86?12:13;this.fullPalette=me[t];let r=lr();this.nColorMode=r<.7?"normal":r<.8?"vertical":r<.9?"horizontal":"high",this.hardColors=!0,this.fullPalette.colors.length<6&&this.addColorsToPalette(),nr(this.fullPalette.colors),this.currentSubPalettes=[]}addColorsToPalette(){let e=[];for(let t=0;t<this.fullPalette.colors.length;t++){let r=Pr(this.fullPalette.colors[t],.35,.1).getHex();e.push(r)}this.fullPalette.colors.push(...e)}splitPalette(e){this.currentSubPalettes=[];let t=[],r=[...this.fullPalette.colors];for(let n=0;n<e;n++){let e=r.length-1,n=new t3.Color(r[e]);r.splice(e,1),e=r.length-1;let o=new t3.Color(r[e]);r.splice(e,1),t.push([n,o])}for(let n=0;n<e;n++){for(let e=0;e<r.length;e++){let o,i=r[e];o=new t3.Color(i),t[n].push(o)}this.currentSubPalettes.push(new yr(t[n]))}}getColorWithType(e){return this.currentSubPalettes[e].getColor()}getRandomColor(){return this.currentSubPalettes[0].colors[ir(0,this.currentSubPalettes[0].colors.length)]}getNColor(e,t,r=null){let n;n=null==r?hr(e[0][0],e[0][1]):hr(r.x,r.y);let o=O.clone();d&&o.add(hr(338.7221,9928.1124));let i=o.clone().add(hr(994.23344,39485.665));"normal"==x.nColorMode||("vertical"==x.nColorMode?(n.x*=2,n.y*=.5):"horizontal"==x.nColorMode?(n.x*=.5,n.y*=2):"high"==x.nColorMode?(n.x*=2,n.y*=2):"low"==x.nColorMode&&(n.x*=.5,n.y*=.5));let l,s=cr().clamp(.5*pr(n,.75,1,o)+.5+lr(-0,0),0,1),a=cr().clamp(.5*pr(n,.75,1,i)+.5+lr(-0,0),0,1),u=mr(this.currentSubPalettes[t].colors,s),h=new t3.Color(u.r,u.g,u.b);if(lr()<.5){let e=mr(this.currentSubPalettes[t].colors,a);l=Cr(new t3.Color(e.r,e.g,e.b),.05)}else l=Cr(h,.1);return[Rr(h,.3,.08),l]}}let xr=sr(),br=(sr(1,1,1),sr(.1,.1,.1));function mr(e,t){let r=(t=cr().clamp(t,0,.99999))/(1/(e.length-1)),n=Math.floor(r),o=r-n;return null==e[n]||null==e[n+1]?br:(xr.setRGB(e[n].r,e[n].g,e[n].b),o=x.hardColors?1*Math.round(1*o):.25*Math.round(4*o),xr.lerp(e[n+1],o),xr)}function wr(e,t=.2){return Cr(ar(e),t)}function Pr(e,t,r){return Rr(ar(e),t,r)}function Rr(e,t=.3,r=.1){let n={h:0,s:0,l:0};e.getHSL(n);let o,i,l,s=n.l<1-t,a=n.l>t,u=.9;return lr()<.25&&(u=.6),s&&a?(o=n.h,i=cr().clamp(n.s*lr(u,1.05),0,1),l=cr().clamp(n.l+lr(.5*-r,.5*r),0,1)):s?(o=n.h,i=cr().clamp(n.s*lr(u,1.05),0,1),l=cr().clamp(n.l+lr(.25*-r,.75*r),0,1)):a&&(o=n.h,i=cr().clamp(n.s*lr(u,1.05),0,1),l=cr().clamp(n.l+lr(.75*-r,.25*r),0,1)),e.setHSL(o,i,l)}function Cr(e,t=.2){let r={h:0,s:0,l:0};e.getHSL(r);let n=r.h,o=cr().clamp(r.s+lr(0,.05),0,1),i=cr().clamp(r.l-t,0,1);return sr().setHSL(n,o,i)}function Br(e,t=.2){return function(e,t=.2){let r=e,n={h:0,s:0,l:0};r.getHSL(n);let o=n.h,i=cr().clamp(n.s+lr(-.02,.02),0,1),l=cr().clamp(n.l+t,0,1);return sr().setHSL(o,i,l)}(ar(e),t)}function Er(e,t,r){var n=t[0],o=t[1],i=r[0]-n,l=r[1]-o;if(0!==i||0!==l){var s=((e[0]-n)*i+(e[1]-o)*l)/(i*i+l*l);s>1?(n=r[0],o=r[1]):s>0&&(n+=i*s,o+=l*s)}return(i=e[0]-n)*i+(l=e[1]-o)*l}function Lr(e,t,r,n,o){for(var i,l=n,s=t+1;s<r;s++){var a=Er(e[s],e[t],e[r]);a>l&&(i=s,l=a)}l>n&&(i-t>1&&Lr(e,t,i,n,o),o.push(e[i]),r-i>1&&Lr(e,i,r,n,o))}function Sr(e,t){var r=e.length-1,n=[e[0]];return Lr(e,0,r,t,n),n.push(e[r]),n}function Tr(e,t,r){if(e.length<=2)return e;var n=void 0!==t?t*t:1;return e=r?e:function(e,t){for(var r,n,o,i,l,s=e[0],a=[s],u=1,h=e.length;u<h;u++)r=e[u],o=s,i=void 0,l=void 0,i=(n=r)[0]-o[0],l=n[1]-o[1],i*i+l*l>t&&(a.push(r),s=r);return s!==r&&a.push(r),a}(e,n),e=Sr(e,n)}class kr{static isWebGLAvailable(){try{const e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}}static isWebGL2Available(){try{const e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}}static getWebGLErrorMessage(){return this.getErrorMessage(1)}static getWebGL2ErrorMessage(){return this.getErrorMessage(2)}static getErrorMessage(e){const t={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let r="Your $0 does not seem to support WebGL2. <br> Please view Metropolis on a modern device.";const n=document.createElement("div");return n.id="webglmessage",n.style.fontFamily="monospace",n.style.fontSize="13px",n.style.fontWeight="normal",n.style.textAlign="center",n.style.background="#fff",n.style.color="#000",n.style.padding="1.5em",n.style.width="600px",n.style.margin="5em auto 0",r=t[e]?r.replace("$0","graphics card"):r.replace("$0","browser"),r=r.replace("$1",{1:"WebGL",2:"WebGL 2"}[e]),n.innerHTML=r,n}}function Mr(e,t,r){this.x=e,this.y=t,this.z=r}Mr.prototype.dot2=function(e,t){return this.x*e+this.y*t},Mr.prototype.dot3=function(e,t,r){return this.x*e+this.y*t+this.z*r};var Ar=[new Mr(1,1,0),new Mr(-1,1,0),new Mr(1,-1,0),new Mr(-1,-1,0),new Mr(1,0,1),new Mr(-1,0,1),new Mr(1,0,-1),new Mr(-1,0,-1),new Mr(0,1,1),new Mr(0,-1,1),new Mr(0,1,-1),new Mr(0,-1,-1)],Ir=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],Wr=new Array(512),Fr=new Array(512);let Nr=function(e){e>0&&e<1&&(e*=65536),(e=Math.floor(e))<256&&(e|=e<<8);for(var t=0;t<256;t++){var r;r=1&t?Ir[t]^255&e:Ir[t]^e>>8&255,Wr[t]=Wr[t+256]=r,Fr[t]=Fr[t+256]=Ar[r%12]}};var Or=.5*(Math.sqrt(3)-1),_r=(3-Math.sqrt(3))/6;let Dr=function(e,t){var r,n,o=(e+t)*Or,i=Math.floor(e+o),l=Math.floor(t+o),s=(i+l)*_r,a=e-i+s,u=t-l+s;a>u?(r=1,n=0):(r=0,n=1);var h=a-r+_r,c=u-n+_r,f=a-1+2*_r,d=u-1+2*_r,p=Fr[(i&=255)+Wr[l&=255]],g=Fr[i+r+Wr[l+n]],y=Fr[i+1+Wr[l+1]],v=.5-a*a-u*u,x=.5-h*h-c*c,b=.5-f*f-d*d;return 70*((v<0?0:(v*=v)*v*p.dot2(a,u))+(x<0?0:(x*=x)*x*g.dot2(h,c))+(b<0?0:(b*=b)*b*y.dot2(f,d)))};function qr(){this.vertices=null,this.edges=null,this.cells=null,this.toRecycle=null,this.beachsectionJunkyard=[],this.circleEventJunkyard=[],this.vertexJunkyard=[],this.edgeJunkyard=[],this.cellJunkyard=[]}qr.prototype.reset=function(){if(this.beachline||(this.beachline=new this.RBTree),this.beachline.root)for(var e=this.beachline.getFirst(this.beachline.root);e;)this.beachsectionJunkyard.push(e),e=e.rbNext;this.beachline.root=null,this.circleEvents||(this.circleEvents=new this.RBTree),this.circleEvents.root=this.firstCircleEvent=null,this.vertices=[],this.edges=[],this.cells=[]},qr.prototype.sqrt=Math.sqrt,qr.prototype.abs=Math.abs,qr.prototype.ε=qr.ε=1e-9,qr.prototype.invε=qr.invε=1/qr.ε,qr.prototype.equalWithEpsilon=function(e,t){return this.abs(e-t)<1e-9},qr.prototype.greaterThanWithEpsilon=function(e,t){return e-t>1e-9},qr.prototype.greaterThanOrEqualWithEpsilon=function(e,t){return t-e<1e-9},qr.prototype.lessThanWithEpsilon=function(e,t){return t-e>1e-9},qr.prototype.lessThanOrEqualWithEpsilon=function(e,t){return e-t<1e-9},qr.prototype.RBTree=function(){this.root=null},qr.prototype.RBTree.prototype.rbInsertSuccessor=function(e,t){var r,n,o;if(e){if(t.rbPrevious=e,t.rbNext=e.rbNext,e.rbNext&&(e.rbNext.rbPrevious=t),e.rbNext=t,e.rbRight){for(e=e.rbRight;e.rbLeft;)e=e.rbLeft;e.rbLeft=t}else e.rbRight=t;r=e}else this.root?(e=this.getFirst(this.root),t.rbPrevious=null,t.rbNext=e,e.rbPrevious=t,e.rbLeft=t,r=e):(t.rbPrevious=t.rbNext=null,this.root=t,r=null);for(t.rbLeft=t.rbRight=null,t.rbParent=r,t.rbRed=!0,e=t;r&&r.rbRed;)r===(n=r.rbParent).rbLeft?(o=n.rbRight)&&o.rbRed?(r.rbRed=o.rbRed=!1,n.rbRed=!0,e=n):(e===r.rbRight&&(this.rbRotateLeft(r),r=(e=r).rbParent),r.rbRed=!1,n.rbRed=!0,this.rbRotateRight(n)):(o=n.rbLeft)&&o.rbRed?(r.rbRed=o.rbRed=!1,n.rbRed=!0,e=n):(e===r.rbLeft&&(this.rbRotateRight(r),r=(e=r).rbParent),r.rbRed=!1,n.rbRed=!0,this.rbRotateLeft(n)),r=e.rbParent;this.root.rbRed=!1},qr.prototype.RBTree.prototype.rbRemoveNode=function(e){e.rbNext&&(e.rbNext.rbPrevious=e.rbPrevious),e.rbPrevious&&(e.rbPrevious.rbNext=e.rbNext),e.rbNext=e.rbPrevious=null;var t,r,n=e.rbParent,o=e.rbLeft,i=e.rbRight;if(t=o?i?this.getFirst(i):o:i,n?n.rbLeft===e?n.rbLeft=t:n.rbRight=t:this.root=t,o&&i?(r=t.rbRed,t.rbRed=e.rbRed,t.rbLeft=o,o.rbParent=t,t!==i?(n=t.rbParent,t.rbParent=e.rbParent,e=t.rbRight,n.rbLeft=e,t.rbRight=i,i.rbParent=t):(t.rbParent=n,n=t,e=t.rbRight)):(r=e.rbRed,e=t),e&&(e.rbParent=n),!r)if(e&&e.rbRed)e.rbRed=!1;else{var l;do{if(e===this.root)break;if(e===n.rbLeft){if((l=n.rbRight).rbRed&&(l.rbRed=!1,n.rbRed=!0,this.rbRotateLeft(n),l=n.rbRight),l.rbLeft&&l.rbLeft.rbRed||l.rbRight&&l.rbRight.rbRed){l.rbRight&&l.rbRight.rbRed||(l.rbLeft.rbRed=!1,l.rbRed=!0,this.rbRotateRight(l),l=n.rbRight),l.rbRed=n.rbRed,n.rbRed=l.rbRight.rbRed=!1,this.rbRotateLeft(n),e=this.root;break}}else if((l=n.rbLeft).rbRed&&(l.rbRed=!1,n.rbRed=!0,this.rbRotateRight(n),l=n.rbLeft),l.rbLeft&&l.rbLeft.rbRed||l.rbRight&&l.rbRight.rbRed){l.rbLeft&&l.rbLeft.rbRed||(l.rbRight.rbRed=!1,l.rbRed=!0,this.rbRotateLeft(l),l=n.rbLeft),l.rbRed=n.rbRed,n.rbRed=l.rbLeft.rbRed=!1,this.rbRotateRight(n),e=this.root;break}l.rbRed=!0,e=n,n=n.rbParent}while(!e.rbRed);e&&(e.rbRed=!1)}},qr.prototype.RBTree.prototype.rbRotateLeft=function(e){var t=e,r=e.rbRight,n=t.rbParent;n?n.rbLeft===t?n.rbLeft=r:n.rbRight=r:this.root=r,r.rbParent=n,t.rbParent=r,t.rbRight=r.rbLeft,t.rbRight&&(t.rbRight.rbParent=t),r.rbLeft=t},qr.prototype.RBTree.prototype.rbRotateRight=function(e){var t=e,r=e.rbLeft,n=t.rbParent;n?n.rbLeft===t?n.rbLeft=r:n.rbRight=r:this.root=r,r.rbParent=n,t.rbParent=r,t.rbLeft=r.rbRight,t.rbLeft&&(t.rbLeft.rbParent=t),r.rbRight=t},qr.prototype.RBTree.prototype.getFirst=function(e){for(;e.rbLeft;)e=e.rbLeft;return e},qr.prototype.RBTree.prototype.getLast=function(e){for(;e.rbRight;)e=e.rbRight;return e},qr.prototype.Diagram=function(e){this.site=e},qr.prototype.Cell=function(e){this.site=e,this.halfedges=[],this.closeMe=!1},qr.prototype.Cell.prototype.init=function(e){return this.site=e,this.halfedges=[],this.closeMe=!1,this},