memoscan
← all memos

Memo 0x07406f3f…fba5f6 on Ethereum

th:b,insetFromGeometry:s,addOutline:i,insetFromGeometryDistance:c,minDistance:p,bounds:{topLeft:[l.minX,l.minY],bottomRight:[l.maxX,l.maxY]},postProcessingArgs:{directional:!0,scribbleStrength:u?h:0,wobbleFreq:f,wobbleAmplitude:d*g}};switch(t){case"noise":case"bnnoise":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldNoiseProps:{...x,wobbleDetail:e.num(1,2)}};case"outline":return{...Z,vectorFieldType:t,boundingGeometry:a};case"directional":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldDirectionalProps:{direction:n}};case"wobbles":return{...Z,vectorFieldType:"wobbles",boundingGeometry:a,blueNoiseProps:{warpStrength:1e3,minDist:1*p,maxDist:1.5*p},wobbleProps:{tension:{min:.5,max:3},maxPointUse:1,maxDivergence:4,maxLinePoints:30}};case"bluenoise":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldNoiseProps:{...x,wobbleDetail:1},blueNoiseProps:{warpStrength:100,minDist:p+d,maxDist:4*(p+d)}};case"edgefill":return{...Z,vectorFieldType:t,boundingGeometry:a,blueNoiseProps:{warpStrength:100,minDist:2*(p+d),maxDist:2.2*(p+d)}}}},Hl=(e,t,n=[],l)=>{if(n.length){let e=n[0],t=l.int(0,e.verts.length-1),i=(t+1)%e.verts.length;return new Ut(...e.verts[t]).angleTo(new Ut(...e.verts[i]))}let i=Wi.getLinesIntersectingFace(e,!1),a=e.center,s=new Set([...t].map((e=>e.meta.lineCategory))),o=[Se.horizontal,Se.vertical,Se.perspective,Se.objects].filter((e=>!s.has(e))),r=i.filter((e=>!t.has(e.constructionLine)&&o.some((t=>t==e.constructionLine.meta.lineCategory))));if(r.length){let e=r.reduce(((e,t)=>Ln(a.toArray(),e.constructionLine.line)<Ln(a.toArray(),t.constructionLine.line)?e:t),r[0]);t.add(e.constructionLine);let n=e.constructionLine.line.map((e=>new Ut(...e)));return n[0].angleTo(n[n.length-1])}},Il=(e,t)=>{let{fade:n,scale:l}=e;return{fade:{in:{enabled:t.bool(n.in.enabledChance),length:t.num(n.in.min,n.in.max)},out:{enabled:t.bool(n.out.enabledChance),length:t.num(n.out.min,n.out.max)}},scale:{in:{enabled:t.bool(l.in.enabledChance),length:t.num(l.in.min,l.in.max)},out:{enabled:t.bool(l.out.enabledChance),length:t.num(l.out.min,l.out.max)}}}};async function Nl(e,t){let{colorOverride:n}=e?.detailObjectProps||{};const l=new _(e?.detailObjectProps?.noiseSeedOverride||t),i=new dn;i.expands(e.polygon),i.expandByValue(10);const a=e.faceRef?.center||i.center,s=e?.detailObjectProps?.inDominantShapes||[],o=e?.detailObjectProps?.inObject||[],d=s.length>0,u=!!e?.isInCurve,h=!!e?.detailObjectProps?.inObject?.length,m=e?.detailObjectProps?.isFineDetail,p=xe(e.lightingIntensity||Ie.default,Ie.clamp),{skipFill:b,skipDetails:g}=e.detailObjectProps||{};let f=Yl(je,{isInDominantPoly:m||d,normal:p,isOverlay:e.category==mn.overlay,isInCurveOrObject:h||u}),x=Yl(Qe,{isInDominantPoly:m||d,normal:p,isOverlay:e.category==mn.overlay,isInCurveOrObject:h||u});const Z=!b&&l.bool(f.fillChance),y=!g&&l.bool(x.fillChance),G=l.bool(f.insetChance),W=l.bool(x.insetChance),v=Z?l.weightedChoice(...f.layerCountChances):0,L=u?0:y?l.weightedChoice(...x.layerCountChances):0;let S=new Set,X=new Set,C=new Set,V=[],K=[],w=!1;function k(t,l,c){const h=[];for(let b=0;b<c;b++){const c=Pl("fill"===l?f:x,b);let g,Z=t.num(c.lineWeight.min,c.lineWeight.max),y=t.num(c.linePressure.min,c.linePressure.max);g=r(.4,Z*t.num(c.minDistanceMult.min,c.minDistanceMult.max)),m&&"detail"===l&&(Z*=.75,g*=.25);const v="fill"===l?zl.filter((e=>!S.has(e))):zl.filter((e=>!X.has(e)));let L,k=t.choice(v);v.length||("fill"===l?S.clear():X.clear(),k=t.choice(zl)),"fill"===l?S.add(k):X.add(k),d&&("fill"===l&&G||"detail"===l&&W)&&(L=u?e.isInCurve.line:s[0].face.vertexlist.map((e=>e.toArray())));let R=c.colorMap[b]||c.colorMap[0],T=t.weightedChoice(...R),M=bl(t,T,a,p,c.colorPalette,"fill"==l?V:K),z=null;if(t.bool(c.fadeAtLineSegmentChance)){let n,l,a=t.int(0,i.vertexList.length-1),s=[i.vertexList[a],i.vertexList[(a+1)%i.vertexList.length]],o=s[0].lerp(s[1],t.num(.01,.99));for(let t=0;t<e.polygon.length;t++){let n=[e.polygon[t],e.polygon[(t+1)%e.polygon.length]],i=Sn(o.toArray(),n[0].toArray(),n[1].toArray());(!l||i<l.dist)&&(l={seg:n,dist:i})}n=l.seg;const{fadeAtLineSegmentDistanceMult:r,fadeAtLineSegmentStrengthMult:d}=c;let u=i.center.distanceTo(n[0].lerp(n[1],.5));z={segment:n,distance:2*u*t.num(r.min,r.max),strength:t.num(d.min,d.max)}}let Y=t.weightedChoice(...c.styleChances),P=0;"directional"===Y&&(P=Hl(e.faceRef,C,o,t));let F,H,I="fill"==l&&u&&(w||0==b&&t.bool(qe.renderLightChance));w=I,"fill"===l?(n?M=n:I&&(M=bl(t,Ke.lightestOrDarkestBasedOnBg,a,p,c.colorPalette,V)),V.push(M)):"detail"==l&&K.push(M);const N=t.bool(c.ignoreLightingChance);F=!(u&&qe.ignoreLighting||N),H=!!(u&&qe.ignoreLighting||N),h.push({paintLineObj:{colorLayerType:T,lineBrightness:F?ye(p,Ie.min,Ie.max,ge(Ie.default,Ie.min,Ie.influencesBrightnessMult),ge(Ie.default,Ie.max,Ie.influencesBrightnessMult)):Ie.default,type:l,lines:[],closedPolyOrLine:!1,noiseOffset:[t.num(-1,1),t.num(-1,1)],canBulge:!0,isShading:!0,canWarp:!0,fadeAtLineSegment:z,lineTapering:Il("bluenoise"==Y&&"detail"==l?{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:0,min:4,max:6}},scale:{in:{enabledChance:100,min:.5,max:.8},out:{enabledChance:100,min:.5,max:.8}}}:c.lineTapering,t),disableSaturationShift:H,linePressure:y*ye(p,Ie.max,Ie.min,ye(Ie.influencesPressureMult,1,0,.5,1),1),edgeSharpness:t.num(c.edgeSharpness.min,c.edgeSharpness.max),accumulationStrength:t.num(c.accumulationStrength.min,c.accumulationStrength.max),materialHardness:t.num(c.materialHardness.min,c.materialHardness.max),lineWeight:.8*Z,lineColor:M},workerData:{streamlineWorkerProps:Fl({type:Y,direction:P,addOutline:"edgefill"==Y,scribble:d?!u&&t.bool(c.scribbleChance):t.bool(c.scribbleChance),scribbleStrength:t.num(c.scribbleStrength.min,c.scribbleStrength.max),random:t,insetFromGeometry:L,insetFromGeometryDistance:{min:c.insetDistance.min,max:c.insetDistance.max},objAABB:i,boundingGeometry:e.polygon.map((e=>e.toArray())),lineWeight:Z,minDistance:"bluenoise"==Y&&"detail"==l?.4*g:r(.4,"fill"==l?g*fe(p,Ie.max,Ie.min,fe(Ie.influencesMinDistanceMult,1,0,1,1),fe(Ie.influencesMinDistanceMult,0,1,1,.5)):g),maxLength:c.maxLength?t.num(c.maxLength.min,c.maxLength.max):1e10,wobbleAmplitude:t.easedNum(We,c.wobbleAmplitude.min,c.wobbleAmplitude.max),wobbleFreq:t.easedNum(We,c.wobbleFreq.min,c.wobbleFreq.max),streamLineProps:{...k,wobbleDetail:t.int(1,2)}}),noiseSeed:xn,randomSeed:q(t)}})}return h}const R=[...k(l,"fill",v),...k(l,"detail",L)],T=R.map((e=>Ml(e.workerData))),M=await Promise.all(T);e.allowExtraDetails=!1,R.filter((e=>"detail"==e.paintLineObj.type)).length>=2&&R.filter((e=>"detail"==e.paintLineObj.type)).every((e=>"directional"==e.workerData.streamlineWorkerProps.vectorFieldType))&&(e.allowExtraDetails=!0);for(let t=0;t<M.length;t++){const n=[],l=M[t],i=R[t].paintLineObj;"detail"==i.type&&"bluenoise"==R[t].workerData.streamlineWorkerProps.vectorFieldType&&(i.lineWeight*=1.5);for(let e of l){const t=e;t.length&&n.push(t)}n.length<1||(i.lines=n,e.detailObject=e.detailObject||[],e.detailObject.push(i))}if(e?.detailObject?.length){let t=[];for(let n=e.detailObject.length-1;n>0;n--){let l=e.detailObject[n-1],i=e.detailObject[n];i.colorLayerType===Ke.previous&&l?.lines?.length&&i?.lines?.length&&(l.lines=[...l.lines,...i.lines],t.push(i))}t.length>0&&(e.detailObject=e.detailObject.filter((e=>!t.includes(e))))}e.allowExtraDetails&&e?.detailObject?.length&&!m&&l.bool(d?80:40)&&async function(e,t){let n=[...Si,...hn].filter((e=>e.category==mn.overlay));for(let t of n){let n=new dn;if(n.expands(t.polygon),e.faceRef.aabb.intersects(n))return}let l=e.detailObject.filter((e=>"detail"==e.type));const i=new dn;i.expands(e.polygon),i.expandByValue(10);const a=e.faceRef?.center||i.center;let s=new kn([],[]);s.insertPolygon(e.polygon.map((e=>e.toArray())),!0);for(let e=0;e<l.length;e++){let t=l[e];for(let e of t.lines)s.insertPolygon(e,!1),await new Promise((e=>setTimeout(e,0)))}s.cleanupTrailingEdges();let o=s.internalFaces(),r=c(yn(a.x,a.y,100,5,40,100)),d=yn(a.x,a.y,600,0,100)>60;if(o.length>2)for(let n of o.filter((e=>e.area>100)))if(n.hedges.every((e=>e.face&&e.twin.face&&e.face!==e.twin.face))&&t.bool(r)){let l=t.num(.35,.45),i=n.vertexlist.map((e=>e.addPolar(e.angleTo(n.center),e.distanceTo(n.center)*l))),a={category:mn.detail,faceRef:n,polygon:i,detailObject:[],detailObjectProps:{isFineDetail:!0,skipDetails:!d,skipFill:!!d,inObject:e.detailObjectProps?.inObject,inDominantShapes:e.detailObjectProps?.inDominantShapes,noiseSeedOverride:q(t)}};Si.push(a)}}(e,l),e.readyForRender=!0}let Ul,Dl,Ol=new Set;function Bl(e){let t,n=0;for(;!t&&n++<200;){let n=J.choice(e.internalFaces()),l=J.choice(n.vertexlist);Ol.has(l)||(t=l)}return t}class Ql{dcel;maxAngle;pathVerts=[];AABB=new dn;constructor(e,t=.3){this.dcel=e,this.maxAngle=t}*findDominantPaths(e=!1){let t=new Set(this.dcel.hedges.filter((e=>e.face&&e.face.area>0&&e.twin.face&&e.twin.face.area>0&&e.origin!==e.twin.origin&&e.face!==e.twin.face)));for(;t.size>0;){let n=t.values().next().value;t.delete(n),t.delete(n.twin);let l=[n.twin.origin],i=[n.origin],a=new Set;a.add(n.origin),a.add(n.twin.origin);let o=0;for(let r of[n,n.twin]){let c=r.twin.origin,d=r===n?l:i,u=r.origin,h=u.angleTo(c);for(;;){const n=c.hedgelist.filter((t=>(!e||t.twin.face&&t.twin.face.area>0)&&t.face&&t.face.area>0&&!a.has(t.twin.origin)&&s(c.angleTo(t.twin.origin)-h)<this.maxAngle)).sort(((e,t)=>s(c.angleTo(e.twin.origin)-h)-s(c.angleTo(t.twin.origin)-h)));if(!n.length)break;let l=n[0];o+=s(c.angleTo(l.twin.origin)-h),t.delete(l),t.delete(l.twin),u=c,c=l.twin.origin,d.push(c),a.add(c),h=u.angleTo(c)}}i.reverse();let r=i.concat(l),c=r.reduce(((e,t,n)=>0===n?0:e+t.distanceTo(r[n-1])),0);yield{vertices:r,length:c,curviness:o/r.length}}}walk(e,t,n=!0){let l=e;if(!l)return;let i=0,a=0;this.AABB.expand(l);let s=new Set;for(s.add(l),Ol.add(l);i<=t&&a++<400;){const e=l.hedgelist.filter((e=>!s.has(e.twin.origin)&&!Ol.has(e.twin.origin)));if(e.sort(((e,t)=>{let n=e.twin.origin,l=t.twin.origin,i=this.AABB.center.distanceTo(n);return this.AABB.center.distanceTo(l)-i})),0===e.length)break;let a=e[0].twin.origin;if(i+=l.distanceTo(a),n&&i>t){let e=(o=l,r=a,c=1-(i-t)/l.distanceTo(a),new Ut(ge(o.x,r.x,c),ge(o.y,r.y,c)));s.add(e),this.AABB.expand(e);break}s.add(a),Ol.add(a),this.AABB.expand(a),l=a}var o,r,c;this.pathVerts.push(...Array.from(s))}}class jl{heap;maxSize;valueFunction;epsilon=g;constructor(e,t){this.valueFunction=t,this.heap=[],this.maxSize=e}size(){return this.heap.length}push(e){this.heap.push(e),this.siftUp(this.heap.length-1),this.heap.length>this.maxSize&&this.heap.pop()}clear(){this.heap=[]}peek(){return this.heap[0]}remove(e){const t=this.heap.findIndex((t=>t===e));-1!==t&&(this.heap[t]=this.heap[this.heap.length-1],this.heap.pop(),t<this.heap.length&&this.siftDown(t))}replaceTop(e){this.heap[0]=e,this.siftDown(0)}toArray(){return[...this.heap]}siftUp(e){for(;e>0;){const t=Math.floor((e-1)/2),n=this.valueFunction(this.heap[e])-this.valueFunction(this.heap[t]);if(n<this.epsilon&&n>-this.epsilon)break;if(n<=0)break;[this.heap[e],this.heap[t]]=[this.heap[t],this.heap[e]],e=t}}siftDown(e){const t=this.heap.length;for(;;){let n=e;const l=2*e+1,i=2*e+2,a=this.valueFunction(this.heap[n]);if(l<t&&this.valueFunction(this.heap[l])-a>this.epsilon&&(n=l),i<t){const e=this.valueFunction(this.heap[n]);this.valueFunction(this.heap[i])-e>this.epsilon&&(n=i)}if(n===e)break;[this.heap[e],this.heap[n]]=[this.heap[n],this.heap[e]],e=n}}}class Jl{position;rotation;dimensions;numSides;cameraPos;fov;aspect;near;far;lights;cullBackfaces;localVertices=[];worldVertices=[];screenVertices=[];constructor(e,t,n,l,i,a=90,s=Y/P,o=.1,r=1e4,c=[],d=!1){this.position=e,this.rotation=t,this.dimensions=n,this.numSides=l,this.cameraPos=i,this.fov=a,this.aspect=s,this.near=o,this.far=r,this.lights=c,this.cullBackfaces=d,this._buildLocalGeometry()}_buildLocalGeometry(){const{width:e,height:t,depth:n}=this.dimensions,l=e/2,i=t/2,a=n/2,s=2*Math.PI/this.numSides,o=this.numSides%2==0?-Math.PI/this.numSides:-Math.PI/2;if(0===n)for(let e=0;e<this.numSides;e++){const t=o+s*e,n=Math.cos(t)*l,a=Math.sin(t)*i;this.localVertices.push({x:n,y:a,z:0})}else for(let e=0;e<this.numSides;e++){const t=o+s*e,n=Math.cos(t),r=Math.sin(t);this.localVertices.push({x:n*l,y:r*i,z:+a}),this.localVertices.push({x:n*l,y:r*i,z:-a})}}getFaces2D(){const e=function(e,t,n,l,i,a){const s=El(e*Math.PI/180),o=_l(t*Math.PI/180),r=ql(n*Math.PI/180),c=$l(l,i,a),d=ei(r,ei(o,s));return ei(c,d)}(this.rotation.x,this.rotation.y,this.rotation.z,this.position.x,this.position.y,this.position.z),t=$l(-this.cameraPos.x,-this.cameraPos.y,-this.cameraPos.z),n=ei(function(e,t,n,l){const i=1/Math.tan(e*Math.PI/180/2),a=1/(n-l);return[[i/t,0,0,0],[0,i,0,0],[0,0,(n+l)*a,n*l*a*2],[0,0,-1,0]]}(this.fov,this.aspect,this.near,this.far),ei(t,e));this.worldVertices=[],this.screenVertices=[];for(const t of this.localVertices){const l=ti(e,[t.x,t.y,t.z,1]);this.worldVertices.push({x:l[0],y:l[1],z:l[2]});const i=ti(n,[t.x,t.y,t.z,1]);0!==i[3]&&(i[0]/=i[3],i[1]/=i[3],i[2]/=i[3]);const a=(.5*i[0]+.5)*Y,s=(1-(.5*i[1]+.5))*P;this.screenVertices.push([a,s])}const l=this._buildFaces(),i=this.cameraPos.x,a=this.cameraPos.y,s=this.cameraPos.z,o=[];for(let e of l){const t=e.indices.map((e=>this.worldVertices[e])),n=e.indices.map((e=>this.screenVertices[e])),l=ni(t),r=li(t),c=ii(l,r,this.lights);if(this.cullBackfaces){const e={x:r.x-i,y:r.y-a,z:r.z-s};l[0]*e.x+l[1]*e.y+l[2]*e.z<0&&o.push({vertices:n,normal:l,lighting:c})}else o.push({vertices:n,normal:l,lighting:c})}return o}_buildFaces(){const e=[],t=this.numSides;if(0!==this.dimensions.depth){const n=[];for(let e=0;e<t;e++)n.push(2*e);e.push({indices:n});const l=[];for(let e=t-1;e>=0;e--)l.push(2*e+1);e.push({indices:l});for(let n=0;n<t;n++){const l=(n+1)%t,i=[2*n,2*n+1,2*l+1,2*l];e.push({indices:i})}}else e.push({indices:Array.from({length:t},((e,t)=>t))});return e}}class Al{vertices;rotation;perspective;zShift;transformOrigin;projectedVertices;vertices3D;constructor(e,t,n=800,l=-50,i={x:Y/2,y:P/2}){this.vertices=e,this.rotation=t,this.perspective=n,this.zShift=l,this.transformOrigin=i}getLineSegments(){let e=new dn;for(let t of this.vertices)e.expands(t.map((e=>new Ut(...e))));const{x:t,y:n,z:l}={...e.center,z:this.zShift},{x:i,y:a,z:s}=this.rotation,o=this.perspective,r=e.center,c=this.vertices.map((e=>e.map((e=>new Ut(...e).subtract(r)))));this.vertices3D=[];for(let e=0;e<c.length;e++){this.vertices3D.push([]);for(const t of c[e])this.vertices3D[e].push({x:t.x,y:t.y,z:0})}const d=function(e,t,n,l,i,a){const s=t*Math.PI/180,o=n*Math.PI/180,r=El(e*Math.PI/180),c=_l(s);let d=ei(ql(o),ei(c,r));return ei($l(l,i,a),d)}(i,a,s,t,n,l),u=this.vertices3D.map((e=>e.map((e=>{const t=[e.x,e.y,e.z,1],n=ti(d,t);return{x:n[0],y:n[1],z:n[2]}}))));return this.projectedVertices=u.map((e=>e.map((e=>function(e,t,n={x:Y/2,y:P/2}){const{x:l,y:i,z:a}=e,s=l-n.x,o=(i-n.y)*t/(t+a);return t+a<=0?null:[s*t/(t+a)+n.x,o+n.y]}(e,o,this.transformOrigin))).filter((e=>null!==e)))).map((e=>e.filter((e=>e[0]>=-100&&e[0]<=Y+100&&e[1]>=-100&&e[1]<=P+100)))).filter((e=>e.length>0)),this.projectedVertices}}function El(e){const t=Math.cos(e),n=Math.sin(e);return[[1,0,0,0],[0,t,-n,0],[0,n,t,0],[0,0,0,1]]}function _l(e){const t=Math.cos(e),n=Math.sin(e);return[[t,0,n,0],[0,1,0,0],[-n,0,t,0],[0,0,0,1]]}function ql(e){const t=Math.cos(e),n=Math.sin(e);return[[t,-n,0,0],[n,t,0,0],[0,0,1,0],[0,0,0,1]]}function $l(e,t,n=0){return[[1,0,0,e],[0,1,0,t],[0,0,1,n],[0,0,0,1]]}function ei(e,t){const n=Array.from(Array(e.length),(()=>Array(t[0].length).fill(0)));for(let l=0;l<e.length;l++)for(let i=0;i<t[0].length;i++)for(let a=0;a<e[0].length;a++)n[l][i]+=e[l][a]*t[a][i];return n}function ti(e,t){const n=[];for(let l=0;l<e.length;l++){let i=0;for(let n=0;n<t.length;n++)i+=e[l][n]*t[n];n.push(i)}return n}function ni(e){const t=e[0],n=e[1],l=e[2],i=[n.x-t.x,n.y-t.y,n.z-t.z],a=[l.x-t.x,l.y-t.y,l.z-t.z],s=[i[1]*a[2]-i[2]*a[1],i[2]*a[0]-i[0]*a[2],i[0]*a[1]-i[1]*a[0]],o=Math.sqrt(s[0]**2+s[1]**2+s[2]**2);return s.map((e=>e/o))}function li(e){const t=e.reduce(((e,t)=>(e.x+=t.x,e.y+=t.y,e.z+=t.z,e)),{x:0,y:0,z:0}),n=e.length;return{x:t.x/n,y:t.y/n,z:t.z/n}}function ii(e,t,n){let l=0;for(const i of n){const n={x:i.position.x-t.x,y:i.position.y-t.y,z:i.position.z-t.z},a=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z);if(0===a)continue;const s=n.x/a,o=n.y/a,r=n.z/a;l+=(e[0]*s+e[1]*o+e[2]*r)*i.brightness}return l}let ai=!1,si=0,oi=0;T();let ri=T();const ci=()=>{if(!ki[si])return void ui();const e=ki[si][0](),t=ki[si][1]||!1;let n,l=!1;const i=()=>{n=e.next(),na?l=!1:(l=!0,n?.done||function(e){ai||(Ul=w.getParameter(w.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),Dl=w.SYNC_FLUSH_COMMANDS_BIT,ai=!0);const t=w.fenceSync(w.SYNC_GPU_COMMANDS_COMPLETE,0);!function n(){const l=w.clientWaitSync(t,Dl,Ul);l===w.ALREADY_SIGNALED||l===w.CONDITION_SATISFIED||na?(clearTimeout(void 0),w.deleteSync(t),e()):setTimeout(n,0)}()}(i))},a=()=>{const s=T();if(t)!l&&!na&&i();else for(;T()-s<1e3/30&&!na&&!n?.done;)n=e.next();oi++,n?.done?(di("Step took"),Ft?.copyBufferToScreen(),l=!1,n=null,si++,ci()):(v(n.value||{showUpdate:!1}),setTimeout(a,0))};a()};function di(e="",t=!1){T(),ri=T()}const ui=()=>{document.complete=!0,nl(gl([...dl][0],[...dl],dl.size)),di("Total render time",!0),function(){for(let e=0;e<Vl.length;e++){const t=Vl[e];t&&t.terminate()}}()};function hi(e,t,n=4){const l=t/2,i=[];for(let t=0;t<e.length-1;t++){const[n,l]=e[t],[a,s]=e[t+1],o=a-n,r=s-l,c=Math.hypot(o,r);if(0===c){i.push([0,0]);continue}const d=-r/c,u=o/c;i.push([d,u])}const a=[],s=[];for(let t=0;t<e.length;t++){const[o,r]=e[t];if(0===t){const[e,t]=i[0],n=e*l,c=t*l;a.push([o+n,r+c]),s.push([o-n,r-c])}else if(t===e.length-1){const[e,t]=i[i.length-1],n=e*l,c=t*l;a.push([o+n,r+c]),s.push([o-n,r-c])}else{const[e,c]=i[t-1],[d,u]=i[t],h=Math.sqrt((e*d+c*u+1)/2);if(0===h){const t=e*l,n=c*l;a.push([o+t,r+n]),s.push([o-t,r-n]);continue}const m=l/h;if(m>n*l){const[t,n]=[e*l,c*l],[i,h]=[d*l,u*l];a.push([o+t,r+n]),a.push([o+i,r+h]),s.push([o-t,r-n]),s.push([o-i,r-h])}else{const[t,n]=[e+d,c+u],i=Math.hypot(t,n);if(0===i){const t=e*l,n=c*l;a.push([o+t,r+n]),s.push([o-t,r-n])}else{const[e,l]=[t/i,n/i],c=e*m,d=l*m;a.push([o+c,r+d]),s.push([o-c,r-d])}}}}return[...a.reverse(),...s]}class mi{root=null;epsilon=g;count=0;wasRemoved=!1;insert(e){this.root=this.insertRec(this.root,e,0),this.count++}compareCoord(e,t){const n=e-t;return Math.abs(n)<this.epsilon||n<0?-1:1}insertRec(e,t,n){return e?((0===e.axis?this.compareCoord(t.point.x,e.point.point.x):this.compareCoord(t.point.y,e.point.point.y))<0?e.left=this.insertRec(e.left,t,n+1):e.right=this.insertRec(e.right,t,n+1),e):{point:t,axis:n%2,left:null,right:null}}remove(e){this.wasRemoved=!1,this.root=this.removeRec(this.root,e,0),this.wasRemoved&&this.count--}removeRec(e,t,n){if(!e)return null;const l=e.axis;if(this.equals(e.point,t)){if(this.wasRemoved=!0,e.right){const t=this.findMin(e.right,l,n+1);e.point=t.point,e.right=this.removeRec(e.right,t.point,n+1)}else{if(!e.left)return null;{const t=this.findMin(e.left,l,n+1);e.point=t.point,e.right=this.removeRec(e.left,t.point,n+1),e.left=null}}return e}{let i;i=0===l?this.compareCoord(t.point.x,e.point.point.x):this.compareCoord(t.point.y,e.point.point.y),i<0?e.left=this.removeRec(e.left,t,n+1):e.right=this.removeRec(e.right,t,n+1)}return e}findMin(e,t,n){if(!e)throw Error("Empty subtree when finding min.");if(e.axis===t)return e.left?this.findMin(e.left,t,n+1):e;const l=e.left?this.findMin(e.left,t,n+1):e,i=e.right?this.findMin(e.right,t,n+1):e;let a=e;return this.compareAxis(l.point,a.point,t)<0&&(a=l),this.compareAxis(i.point,a.point,t)<0&&(a=i),a}findNearest(e){return this.root?this.findNearestRec(this.root,e,this.root.point,0):null}findNearestRec(e,t,n,l){if(!e)return n;let i=n;this.distanceSq(e.point,t)<this.distanceSq(i,t)&&(i=e.point);const a=0===e.axis?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let s,o;return a<-this.epsilon?(s=e.left,o=e.right):a>this.epsilon?(s=e.right,o=e.left):(s=e.left,o=e.right),i=this.findNearestRec(s,t,i,l+1),a**2<this.distanceSq(i,t)&&(i=this.findNearestRec(o,t,i,l+1)),i}findKNearest(e,t){if(!this.root)return[];const n=new jl(t,(e=>e.dist));return this.findKNearestRec(this.root,e,t,n),n.toArray().map((e=>e.point))}getTotalNodes(){return this.count}*pointsWithinDistanceGenerator(e,t){const n=t*t;yield*this.pointsWithinDistanceRecGen(this.root,e,n)}*pointsWithinDistanceRecGen(e,t,n,l=0){if(!e)return;this.distanceSq(e.point,t)<=n&&(yield e.point);const i=0===e.axis?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let a,s;i<-this.epsilon?(a=e.left,s=e.right):(a=e.right,s=e.left),yield*this.pointsWithinDistanceRecGen(a,t,n,l+1),i**2<=n&&(yield*this.pointsWithinDistanceRecGen(s,t,n,l+1))}findKNearestRec(e,t,n,l,i=0){if(!e)return;const a=e.axis,s=this.distanceSq(e.point,t);if(l.size()<n)l.push({dist:s,point:e.point});else{const t=l.peek();t&&s<t.dist&&l.replaceTop({dist:s,point:e.point})}const o=0===a?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let r,c;o<-this.epsilon?(r=e.left,c=e.right):o>this.epsilon?(r=e.right,c=e.left):(r=e.left,c=e.right),this.findKNearestRec(r,t,n,l,i+1);const d=l.peek();d&&o**2<d.dist&&this.findKNearestRec(c,t,n,l,i+1)}distanceSq(e,t){const n=e.point.x-t.point.x,l=e.point.y-t.point.y;return n*n+l*l}compareAxis(e,t,n){const l=0===n?e.point.x-t.point.x:e.point.y-t.point.y;return Math.abs(l)<this.epsilon?0:l}equals(e,t){const n=e.point.x-t.point.x,l=e.point.y-t.point.y;return n*n+l*l<this.epsilon*this.epsilon}}class pi{opts;kTree=new mi;activeList=[];random;epsilon=g;maxDist;constructor(e){this.opts=e,this.random=e.random||J,this.maxDist=e.maxDist||1}*generate(){const{bounds:e,noiseField:t,initialCount:n=1,k:l=50}=this.opts;if(this.opts.seedPoints&&this.opts.seedPoints.length>0)for(let e of this.opts.seedPoints){const n={point:e,minDist:t(e.x,e.y)};this.placePoint(n),this.activeList.push(n),yield n}else for(let l=0;l<n;l++){const n=this.random.num(e.topLeft[0],e.bottomRight[0]),l=this.random.num(e.topLeft[1],e.bottomRight[1]),i=t(n,l),a={point:new Ut(n,l),minDist:i};this.placePoint(a),this.activeList.push(a),yield a}for(;this.activeList.length>0;){const n=0,i=this.activeList[n];let a=!1;for(let n=1;n<l;n++){const s=i.minDist*(.5+l/n),o=this.random.dec()*Math.PI*2,r=i.point.x+Math.cos(o)*s,c=i.point.y+Math.sin(o)*s;if(r<e.topLeft[0]||r>e.bottomRight[0]||c<e.topLeft[1]||c>e.bottomRight[1])continue;const d=t(r,c),u={point:new Ut(r,c),minDist:d};if(this.canPlace(u)){this.placePoint(u),this.activeList.push(u),yield u,a=!0;break}}a||this.activeList.splice(n,1)}}canPlace(e){for(let t of