0x85582125…5972sent to0x96a83b48…d253·#22,595,612·view on Etherscan
ion:i,maxPointUse:a,layers:s,maxLinePoints:o,pointsToConsider:r,insetMult:c}=qe,d=Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.objects&&e.meta.isClosed&&J.bool(50))).map((e=>Dn(e.line.map((e=>new Ut(...e))))));for(let u=0;u<s;u++){let s=function(t,l){return yn(t,l,0,400,e,e*n)},u=Ae.margin+e*c,h=Ae.margin+e*c,m=new pi({maxDist:e*n,bounds:{topLeft:Bt(new Ut(u,h)).toArray(),bottomRight:Bt(new Ut(Y-u,P-h)).toArray()},noiseField:s,seedPoints:d}),p=m.generate();for(let e of p)yield;let b,g=m.kTree,f=[],x=new Set,Z=new Map,y=e=>{x.add(b);let t=Z.get(e)||0;Z.set(e,t+1),Z.get(e)>=a&&g.remove(e)};for(;!(g.count<=0);){if(!b){let e={point:new Ut(J.num(0,Y),J.num(0,P)),minDist:1/0};b=g.findNearest(e),y(b)}let e=J.choice(g.findKNearest(b,r).filter((e=>!x.has(e)&&e.point.distanceTo(b.point)<b.minDist*l)));!e||x.size>=o||g.count<=0?(f.push([...x].map((e=>e.point))),x=new Set,b=null):(b=e,y(b))}let G=[];for(let e of f){if(e.length<3)continue;let t=Zi(xi(e,{tension:J.num(i.min,i.max),cyclic:!1}),6,!1).map((e=>new Ut(e.x,e.y)));G.push(t)}for(let n of G){if(n.length<3)continue;let l=hi(n.map((e=>e.toArray())),J.int(e*(1-t),e*(1+t)),120);Xi.push({line:l,id:Jn(),meta:{lineCategory:Se.curves,isClosed:!0}}),Wi.addLine(l,{lineCategory:Se.curves,isClosed:!0})}}}],[function*(){for(let e=0;e<Ue.layers;e++){let{maxDist:t,minDist:n,bnFreq:l,minSizeMult:i,maxSizeMult:a,fieldFreq:s,maxSides:o,minSides:r,clampRotationTo:c,layerScaleMult:d,perspective:u}=Ue,h=0==e?1:e*d,m=Ue.cropTo==Ce.border?Li:Ue.cropTo==Ce.scene?[[0,0],[Y,P]]:null,p=null;null!==m&&(p=new dn,p.expandsByPoint(m));let b=function(e,i){return yn(e,i,0,l,n*h,t*h)},g=new pi({maxDist:t*h,bounds:{topLeft:Li[0],bottomRight:Li[2]},noiseField:b}).generate(),f=J.num(150,300)*J.choice([-1,1]),x=40;for(let t of g){let n=Ue.forceYUp?0:yn(t.point.x,t.point.y,1e3,s,-40,x),l=yn(t.point.x+1e3,t.point.y+1e3,2e3,s,-(x+f),x+f),d=Ue.forceYUp?0:yn(t.point.x-1e3,t.point.y-1e3,-1e3,s,-40,x),h={w:i,h:i,d:i},m={w:a,h:a,d:a},b=J.weightedChoice([1,"w"],[3,"h"],[0,"d"]),g=J.weightedChoice([1,1],[3,2],[1,3]);h[b]*=g,m[b]*=g;let Z=Mi({sides:J.easedInt(ve,r,o),perspectiveCenter:vi,perspectiveStrength:u,width:J.num(t.minDist*h.w,t.minDist*m.w),height:J.num(t.minDist*h.h,t.minDist*m.h),depth:J.num(t.minDist*h.d,t.minDist*m.d*(0==e?Ue.zDepthMaxMult:1)),center:[t.point.x,t.point.y],rotationProps:{x:xe(n,c),y:xe(l,c),z:xe(d,c)}}),y=J.int(0,1e10),G=Z.faces.reduce(((e,t)=>e+Un(t.vertices.map((e=>new Ut(...e))))),0);Z.faces=Z.faces.filter((e=>null===p||!e.vertices.some((e=>!p.containsPoint(new Ut(...e))))));for(let e of Z.faces)e.vertices=e.vertices.map((t=>{if(!(t[0]>=Li[0][0]&&t[1]>=Li[0][1]&&t[0]<=Li[2][0]&&t[1]<=Li[2][1]))return t;let n=new dn;n.expandsByPoint(e.vertices),n.expandByValue(20);let l=Wi.getLinesIntersectingOrContainedWithinAABB(n).filter((e=>{let t=e.meta.lineCategory;return t==Se.horizontal||t==Se.vertical||t==Se.perspective}));if(!l.length)return t;let i=l.reduce(((e,n)=>Ln(t,e.line)<Ln(t,n.line)?e:n),l[0]);return vn(t,i.line)}));for(let e of Z.faces)Ki.addPolygon(e.vertices,{category:"face",meta:{id:y,lightingIntensity:e.lighting,normal:e.normal,area:Un(e.vertices.map((e=>new Ut(...e)))),totalArea:G}});wi.push(Z),yield{showUpdate:!0,message:"Generating Scene",isPercent:!1,value:""}}}let e=Ki.getAllPolygons();const n=e.map((e=>e.meta.meta.lightingIntensity));let l,i;if(n.length>4){const e=[...n].sort(((e,t)=>e-t)),a=e[t(.25*e.length)],s=e[.75*t(e.length)],o=s-a,r=a-2*o,c=s+2*o,d=n.filter((e=>e>=r&&e<=c)),u=d.length>=2?d:n;l=.9*Math.min(...u),i=Math.max(...u)}else l=.9*Math.min(...n),i=Math.max(...n);e.forEach((e=>{const t=e.meta.meta.lightingIntensity;let n=ye(t,l,i,0,1),a=ye(We(n),-0,1,Ie.min,Ie.max);e.meta.meta.lightingIntensity=a}));for(let t of e){let e={line:t.verts,id:Jn(),meta:{lineCategory:Se.objects,id:t.meta.meta.id,isClosed:!0}};Xi.push(e),Wi.addLine(t.verts,e.meta)}}],[function*(){let e=yi.internalFaces().sort(((e,t)=>t.area-e.area))[0],n=e.area,l=n,i=e,s=new Set,r=_e;for(Ee[Se.objects]>0&&r.push(Se.objects);l/n>.95+g;){let e=Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.vertical||e.meta.lineCategory==Se.horizontal)),t=J.choice(e);yi.splitFaceByPolyLine(i,t.line,t.meta.isClosed,!1),s.add(t),i=yi.internalFaces().sort(((e,t)=>t.area-e.area))[0],l=i.area,yield{showUpdate:!0,message:"Searching for initial structure",isPercent:!0,value:o(.95*n/l*100,100)}}yi.cleanupTrailingEdges();let c=!0,d=new Map;for(let e=0;e<it;e++){if(e%t(it/5)==0&&e>0&&e<t(it-it/5)){let e=new Ql(yi,.75).findDominantPaths(),t=[];for(let n of e)t.push(n);[...t.filter((e=>e.curviness>.02)).sort(((e,t)=>t.length-e.length)).slice(0,2),...t.filter((e=>e.curviness<.02)).sort(((e,t)=>t.length-e.length)).slice(0,2)].forEach((e=>{let t=e.vertices;if(c){for(let e=1;e<t.length-2;e++){let n=[t[e],t[e+1]],l=yi.findHedge(n[0].x,n[0].y,n[1].x,n[1].y);l?.face?.area>0&&yi.removeEdge(n[0].x,n[0].y,n[1].x,n[1].y)}c=!1}else{let e=[t[0],t[1]],n=e[0].distanceTo(e[1]);for(let l=1;l<t.length-2;l++){let i=t[l].distanceTo(t[l+1]);i>n&&(e=[t[l],t[l+1]],n=i);let a=yi.findHedge(e[0].x,e[0].y,e[1].x,e[1].y);a?.face?.area>0&&a.twin.face?.area>0&&yi.removeEdge(e[0].x,e[0].y,e[1].x,e[1].y)}}})),yi.cleanupDegenerateHoles(),yi.cleanupTrailingEdges(),Ri.clear()}yi.cleanupTrailingEdges(),yi.insertPolygon(Li,!0);let l,i=yi.internalFaces();Ri.update(i);let s=Ri.topN(1e3).filter((e=>!Ti.has(e.id))),o=[];for(let e of s){let t=new kn([],[]);t.insertPolygon(e.vertexlist.map((e=>e.toArray())),!0);let i=t.faces[0],a=new Set,s=()=>{const n=[];for(let l=0;l<o.length;l++){const s=o[l];if(a.has(s.constructionLine.id))continue;const r=s.constructionLine.meta.lineCategory,c=s.constructionLine.meta.lineSubCategory;if(Pi(r,e.aabb.center,Ee[r],c)<=0)continue;const d=s.constructionLine.line;let u=s?.constructionLine?.meta?.aabb;if(u||(u=new dn,u.expandsByPoint(d),s.constructionLine.meta.aabb=u),!e.aabb.intersects(u))continue;const h=s?.constructionLine?.meta?.isClosed,m=t.splitFaceByPolyLine(i,d,h,!0);m?.lines?.length>0&&m?.intersectionCount>=2&&n.push(s)}o=n},r=e,c=n/10;if(e.area>c){let t=100,n=new dn;for(n.expand(e.center);!o.length&&n.area<c&&n.area<e.area;){n.expandByValue(t),o=Wi.linesIntersectingAABB(n),t+=50,s();for(let e of o)a.add(e.constructionLine.id)}}if(o.length||(o=Wi.getLinesIntersectingFace(r,!1),s()),o.length>0){l={face:e,intersecting:o},t.dispose();break}}if(!l)break;let{face:r,intersecting:h}=l,m=new Map;Object.values(Se).forEach((e=>{"string"!=typeof e&&0!=Ee[e]&&m.set(e,h.filter((t=>{let n=t.constructionLine.meta;return n.lineCategory===e&&!(n.unableToSplitFaces&&n.unableToSplitFaces.has(r.id))})))}));let p=[];if(m.forEach(((e,t)=>{if(!e.length)return;let n=Pi(t,r.aabb.center,Ee[t]);if(n>0)if(e.some((e=>e.constructionLine.meta?.lineSubCategory))){let n=new Map;e.map((e=>{let t=e.constructionLine.meta.lineSubCategory;n.has(t)?n.get(t).push(e):n.set(t,[e])}));for(let[e,l]of n){let n=Pi(t,r.aabb.center,Ee[t],e);p.push([n,l.reduce(((e,t)=>{let n=Ln(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance-g?{distance:n,line:t}:e}),{distance:1/0,line:null}).line])}}else p.push([n,e.reduce(((e,t)=>{let n=Ln(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance-g?{distance:n,line:t}:e}),{distance:1/0,line:null}).line])})),st>0){let e=h.filter((e=>e.constructionLine?.meta?.used&&!e.constructionLine?.meta?.unableToSplitFaces?.has(r.id)&&e.constructionLine.meta.lineCategory==Se.objects)).reduce(((e,t)=>{let n=Ln(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance?{distance:n,line:t}:e}),{distance:1/0,line:null}).line;e&&p.push([Pi(Se.used,r.aabb.center,st),e])}if(p=p.filter((e=>e[1])),0==p.length){Ti.add(r.id);continue}let b=J.weightedChoice(...p),f=yi.splitFaceByPolyLine(r,b.constructionLine.line,b.constructionLine.meta.isClosed,!1,J.bool(nt.longestSplitOnlyChance));if(f&&(b.constructionLine.meta.used=!0),!f&&(d.set(r.id,(d.get(r.id)||0)+1),e--,!b.constructionLine.meta.unableToSplitFaces&&(b.constructionLine.meta.unableToSplitFaces=new Set),b.constructionLine.meta.unableToSplitFaces.add(r.id),d.get(r.id)>5)){let e=yi.faces.find((e=>e.id==r.id));for(let t of e.hedges.filter((t=>t.face==e)))yi.removeEdge(t.origin.x,t.origin.y,t.twin.origin.x,t.twin.origin.y);yi.cleanupTrailingEdges()}yield{showUpdate:!0,message:"Composing",isPercent:!0,value:t(100*(u=e/it,1-a(1-u,3)))}}var u}],[function*(){wi.sort(((e,t)=>e.faces.reduce(((e,t)=>e+Un(t.vertices.map((e=>new Ut(...e))))),0)-t.faces.reduce(((e,t)=>e+Un(t.vertices.map((e=>new Ut(...e))))),0))),wi=ll(wi.slice(t(wi.length/4),n(wi.length/4*2)));for(let e=0;e<wi.length;e++){if(J.bool(100-De.forceInsertObjectsChance))continue;let t=wi[e];for(let e of t.faces)J.bool(50)||(yi.insertPolygon(e.vertices,!0),J.bool(50)&&yi.removeEdgesInsidePolygon(e.vertices))}let e=Xi.filter((e=>e.meta.lineCategory==Se.curves)).sort(((e,t)=>{let n=Un(e.line.map((e=>new Ut(...e))));return Un(t.line.map((e=>new Ut(...e))))-n}));for(let n=0;n<e.length;n++){if(J.bool(100-De.forceInsertCurvesChance))continue;let l=e[n];n<t(e.length/10)&&(yi.insertPolygon(l.line,!0),yi.removeEdgesInsidePolygon(l.line,10))}}],[function*(){let e=yi.internalFaces().filter((e=>e.area>1)),n=e.length*at;for(let l=0;l<n&&!(e.length<10);l++){let i=J.choice(e.sort(((e,t)=>{const n=e.area-t.area;return Math.abs(n)<g?e.id-t.id:n})).slice(0,100));if(!i)continue;let a=i.hedges.filter((e=>e.twin&&e.face!==e.twin.face&&e.twin.face.area>0&&e.face.area>0)),s=J.choice(a);s&&yi.removeEdge(s.origin.x,s.origin.y,s.twin.origin.x,s.twin.origin.y),yi.cleanupTrailingEdges(),e=yi.internalFaces().filter((e=>e.area>1)),yield{showUpdate:!0,message:"Deconstructing",isPercent:!0,value:t(l/n*100)}}}],[function*(){yi.insertPolygon(Li,!0)}],[function*(){let e=new Ql(yi,.4).findDominantPaths();for(let t of e)Ci.push(t),yield{showUpdate:!0,message:"Walking Paths",isPercent:!1,value:Ci.length}}],[function*(){Gi=new kn(Li,[[0,1],[1,2],[2,3],[3,0]]);let e=Oe.meshDensity,t=Gi.internalFaces()[0].area;Gi.dispose();let n=P/15,l=[J.num(Y/2,Y/2),J.num(P/2-n,P/2+n)],i=Ci.sort(((e,t)=>Ln(l,e.vertices.map((e=>e.toArray())))-Ln(l,t.vertices.map((e=>e.toArray()))))).slice(0,Ci.length),a=[],s=0;for(;s<e&&i.length>0;){let n=i.shift();Gi.insertPolygon(n.vertices.map((e=>[e.x,e.y])),!1),a.push(n),s=Gi.internalFaces().reduce(((e,t)=>e+t.area),0)/t*100,yield{showUpdate:!0,message:"Defining subject",isPercent:!0,value:s/e*100}}Gi.cleanupTrailingEdges();let o=Gi.vertices.filter((e=>e.y<.75*P&&Mn(e.toArray(),Li)));for(let e of o)for(let t of e.hedgelist){let e=[t.origin.x,t.origin.y],n=[t.twin.origin.x,t.twin.origin.y];if(Mn(e,Li)&&Mn(n,Li)){if(t.origin.distanceTo(t.twin.origin)<10)continue;Gi.removeEdge(e[0],e[1],n[0],n[1])}}Gi.cleanupTrailingEdges(),Vi.push(...a.sort(((e,t)=>t.length-e.length)))}],[function*(){let e=Ci.filter((e=>{let t=(tt.cropToMargin?tt.margin:Ae.margin)*Oe.dominantLineInsetMultiplier;return!e.vertices.some((e=>e.x<=t||e.x>=Y-t||e.y<=t||e.y>=P-t))}));"none"!==Oe.lineFilter&&(e=e.filter((e=>{let t=e.curviness>.01;return"curves"==Oe.lineFilter?t:!t})));let n=[];for(let l of e){let e=t(l.vertices.length/2),i=!1;for(let t of n){let n=0;for(let a of l.vertices){for(let l of t.vertices)if(a.isEqualTo(l)&&(n++,n>=e)){i=!0;break}if(i)break}if(i)break}i||n.push(l)}e=n,Oe.cropToDominantShape&&(e=e.filter((e=>Gi.getFacesAtPoint(e.vertices[0].toArray()).length>0&&Gi.getFacesAtPoint(e.vertices[e.vertices.length-1].toArray()).length>0)));let a=t(e.length/100*Oe.skipLongest),s=e.sort(((e,t)=>t.length-e.length)).slice(a,e.length/100*Oe.percentage+a),o=Re.bg[0][0]>.5?Re.line[0]:[...Re.line,...Re.base,...Re.accent].filter((e=>e[1]<.05)).reduce(((e,t)=>t[0]>e[0]?t:e),Re.line[0]),r=[...Re.line,...Re.base,...Re.accent].filter((e=>e[1]<.05)).reduce(((e,t)=>t[0]>e[0]?t:e),Re.line[0]);for(let e of s){if(J.bool(50)){let t=e.vertices.reduce(((t,n,l)=>0===l?0:t+n.distanceTo(e.vertices[l-1])),0)/J.num(10,15),n=e.vertices[1].angleTo(e.vertices[0]),a=new Ut(e.vertices[0].x+i(n)*t,e.vertices[0].y+l(n)*t),s=e.vertices[e.vertices.length-2].angleTo(e.vertices[e.vertices.length-1]),o=new Ut(e.vertices[e.vertices.length-1].x+i(s)*t,e.vertices[e.vertices.length-1].y+l(s)*t);e.vertices=[a,...e.vertices,o]}let t=new dn;t.expands(e.vertices),t.expandByValue(Oe.thickness.max+3);let n={polygon:t.vertexList,faceRef:null,category:mn.walker,readyForRender:!0,detailObject:[{lines:[e.vertices.map((e=>e.toArray()))],noiseOffset:[J.num(-1,1),J.num(-1,1)],closedPolyOrLine:!1,materialHardness:J.num(Oe.materialHardness.min,Oe.materialHardness.max),linePressure:J.num(Oe.linePressure.min,Oe.linePressure.max),canWarp:!0,lineTapering:Il(Oe.lineTapering,J),lineWeight:J.num(Oe.thickness.min,Oe.thickness.max),lineColor:Oe.backgroundColor?r:Oe.colors?J.choice([...Re.accent,...Re.base,...Re.line]):o}]};Si.push(n)}}],[function*(){let e=Ne.count;for(let t=0;t<e;t++){let e=new Ql(yi),t=Bl(yi);if(!t)break;e.walk(t,J.int(Ne.length.min,Ne.length.max),!0),e.AABB.expandByValue(10);let n=Ne.isLineColor?Re.line[0]:Ne.colors?J.weightedChoice([1,J.choice(Re.accent)],[0,J.choice(Re.line)],[1,J.choice(Re.base)]):J.choice(Re.bg),{fade:l,scale:i}=Ne.lineTapering,a={polygon:e.AABB.vertexList,faceRef:null,category:mn.walker,readyForRender:!0,detailObject:[{lines:[e.pathVerts.map((e=>e.toArray()))],closedPolyOrLine:!1,noiseOffset:[J.num(-1,1),J.num(-1,1)],lineTapering:{fade:{in:{enabled:J.bool(l.in.enabledChance),length:J.num(l.in.min,l.in.max)},out:{enabled:J.bool(l.out.enabledChance),length:J.num(l.out.min,l.out.max)}},scale:{in:{enabled:J.bool(i.in.enabledChance),length:J.num(i.in.min,i.in.max)},out:{enabled:J.bool(i.out.enabledChance),length:J.num(i.out.min,i.out.max)}}},linePressure:J.num(Ne.hardness.min,Ne.hardness.max),canWarp:J.bool(Ne.warpChance),lineWeight:J.num(Ne.thickness.min,Ne.thickness.max),lineColor:n}]};Si.push(a)}}],[function*(){let e=yi.internalFaces().filter((e=>e.area>1));const n=e.map((e=>e.area));if(n.length>4){const l=[...n].sort(((e,t)=>e-t)),i=l[t(.25*l.length)],a=l[t(.75*l.length)],s=a+10*(a-i);e.length,e=e.filter((e=>e.area<=s)),e.length}let l=new dn;l.expandsByPoint(Li),e=e.filter((e=>l.containsPoint(e.center))),tt.cropToMargin&&(e=e.filter((e=>e.center.x>tt.margin&&e.center.x<Y-tt.margin&&e.center.y>tt.margin&&e.center.y<P-tt.margin)));let i=Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.curves&&e.meta.used)),a=e=>{let n=e.aabb;for(let l of i){let i=l.line.map((e=>new Ut(...e)));if(l.meta?.aabb||(l.meta.aabb=new dn,l.meta.aabb.expands(i)),l.meta.aabb.intersects(n)){let n=t(.9*e.vertexlist.length),a=0;for(let t=0;t<e.vertexlist.length;t++){if(a>=n)return l;let s=e.vertexlist[t],o=!1;for(let e of i)if(s.isEqualTo(e)){a++,o=!0;break}!o&&In(i,s)&&a++}}}},s=e=>Ki.getPolygonsAtPoint(e.center.toArray()).sort(((e,t)=>e.meta.meta.totalArea-t.meta.meta.totalArea)),o=e=>{const t=Gi.getFacesIntersectingPoly(e.vertexlist.map((e=>[e.x,e.y])));return e.vertexlist.every((e=>t.some((t=>Mn(e.toArray(),t.face.vertexlist.map((e=>e.toArray())))||In(t.face.vertexlist,e)))))?t:[]};for(let n=0;n<e.length;n++){let l=e[n],i=n,r=s(l),c=a(l),d=o(l),u=r.length?r[0].meta.meta.lightingIntensity:Ie.default,h={polygon:l.vertexlist,faceRef:l,lightingIntensity:u,category:mn.foreground,isInCurve:c,detailObjectProps:{inObject:r,inDominantShapes:d}};Si.push(h),yield{showUpdate:!0,message:"Determining Layout",isPercent:!0,value:t(i/e.length*100)}}const r=[...Si.filter((e=>e.category==mn.foreground&&e.lightingIntensity)).map((e=>e.lightingIntensity))].sort(((e,t)=>e-t));for(let e of Si){const t=(c=e.lightingIntensity,(r.indexOf(c)+r.lastIndexOf(c))/2/(r.length-1));e.lightingIntensity=ge(fe(Le(t),0,1,Ie.min,Ie.max),e.lightingIntensity,.9)}var c}],[function*(){let{freqMultiplier:e}=et,t=e,n=500*e;Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.objects&&e.meta.used)).forEach((e=>{vl.add(e.meta.id)}));let l=Si.filter((e=>e.category==mn.foreground)),{base:i,accent:a,line:s,bg:o}=Re,r=ll([...i,...a,s[0],...o]),c=J.int(0,r.length-1);ol=function(e,t,n="right"){let l=e.slice();for(let e=0;e<t;e++)l=il(l,n);return l}(r,c),ol.length>et.maxAccents&&(ol=ol.slice(0,et.maxAccents));let d=et.mutation;if("none"!==d){let e=e=>{let t,n=hl;switch(d){case"offsetUp":t=n;break;case"offsetDown":t=-30}return J.choice(xl(e,cl,t,et.samplesForPaletteOffset))},t=[];for(let n=1;n<ol.length;n++){let l=ol[n],i=ol[n-1],a=J.bool(50);if(i&&a){let n=e(i);t.push(n)}else t.push(l)}ol=t}yl=sl(t,ol.length,0,ml,l.filter((e=>e.detailObjectProps?.inDominantShapes?.length>0)).map((e=>e.faceRef.center))),Gl=sl(n,rl.length,0,ml,l.filter((e=>!e.detailObjectProps?.inDominantShapes?.length)).map((e=>e.faceRef.center))),rl=fl(Gl,rl),ol=fl(yl,ol)}],[function*(){let e=Si.filter((e=>e.category==mn.foreground&&e.detailObjectProps?.inDominantShapes?.length>0)),t=new Ut(Y/2,P/2),n=e.map((e=>e.faceRef.hedges.reduce(((e,n)=>e.origin?n.origin?t.distanceTo(e.origin)<t.distanceTo(n.origin)?e:n:e:n),e.faceRef.hedges[0])));for(let e=0;e<lt.count;e++){let e=xe(J.num(Be.scale*lt.size.min,Be.scale*lt.size.max),Be.scale),t=n.map((e=>{let t=e.origin.lerp(e.twin.origin,.5);return{distance:Ln(t.toArray(),Li,!0),edge:e,point:t}})).filter((t=>t.distance>1.25*e)),l=2.5*e;t.sort(((e,t)=>Math.abs(e.distance-l)-Math.abs(t.distance-l)));let i=t[0];n.splice(n.indexOf(i.edge),1);let a=i.point,s=J.num(0,360),o=_n({center:a.toArray(),radius:e,startAngle:s,endAngle:s+359.5}),r=new Al([o],{x:J.num(-15,15),y:J.num(-15,15),z:J.num(-15,15)},1200,0,{x:vi[0],y:vi[1]}).getLineSegments(),c={polygon:r[0].map((e=>new Ut(...e))),faceRef:null,category:mn.overlay,readyForRender:!1,detailObjectProps:{}};if(Si.push(c),lt.outline){let e=r[0],t=new dn;t.expandsByPoint(e),t.expandByValue(2*Oe.thickness.max);let n={polygon:t.vertexList,faceRef:null,category:mn.overlayOutline,readyForRender:!0,detailObject:[{lines:[e],noiseOffset:[J.num(-1,1),J.num(-1,1)],closedPolyOrLine:!1,materialHardness:J.num(Oe.materialHardness.min,Oe.materialHardness.max),linePressure:J.num(Oe.linePressure.min,Oe.linePressure.max),canWarp:!1,lineTapering:Il(Oe.lineTapering,J),lineWeight:J.num(Oe.thickness.min,Oe.thickness.max),lineColor:Oe.backgroundColor?Re.bg[0]:Oe.colors?J.choice([...Re.accent,...Re.base,...Re.line]):Re.line[0]}]};Si.push(n)}}}],[function*(){let{enabled:e,linePressure:t,materialHardness:n,lineWeight:l,percentage:i,lineTapering:a}=Je;if(!e)return;let s=Xi.filter((e=>e.meta.used)).filter((()=>J.bool(i))),o=new dn;o.expands([new Ut(0,0),new Ut(Y,P)]);let r={polygon:o.vertexList,faceRef:null,category:mn.constructionLine,readyForRender:!0,detailObject:[{lines:s.map((e=>e.line)),closedPolyOrLine:!1,noiseOffset:[J.num(-1,1),J.num(-1,1)],linePressure:J.num(t.min,t.max),materialHardness:J.num(n.min,n.max),canWarp:!1,lineTapering:Il(a,J),lineWeight:J.num(l.min,l.max),lineColor:Re.line[0]}]};Si.push(r)}],[function*(){const e={[mn.constructionLine]:0,[mn.background]:1,[mn.foreground]:2,[mn.detail]:3,[mn.walker]:3,[mn.overlay]:4,[mn.overlayOutline]:5};Si.sort(((t,n)=>{if(e[t.category]<e[n.category])return-1;if(e[t.category]>e[n.category])return 1;let l=new dn;l.expands(t.polygon);let i=new dn;return i.expands(n.polygon),new Ut(l.maxX,l.maxY).distanceTo(new Ut(0,0))-new Ut(i.maxX,i.maxY).distanceTo(new Ut(0,0))}))}],[function*(){let e=new Map,n=0,l="◴ ◷ ◶ ◵".split(" "),i=function*(){let e=oe(!0),t=new dn;for(t.expands([new Ut(e.xOff,e.yOff),new Ut(e.xOff+e.width,e.yOff+e.height)]),t.expandByValue(10);Si.length;){let e=Si[0];if(e.readyForRender){if(e.detailObject?.length){let n=new dn;if(n.expands(e.polygon),t.intersects(n)){bn(e);for(let t=0;t<e.detailObject.length;t++)rn(e.detailObject[t]);w.flush(),Ft.copyBufferToScreen(),yield{rendering:!0}}}let n=Si.splice(0,1);hn.push(...n)}else yield{rendering:!1}}Ft.copyBufferToScreen()}(),a=!1,s=[];for(let e=0;e<1e3;e++)s.push(q());let o=0;for(;!a;){if(na){yield{showUpdate:!0,message:"Rendering Paused",value:"press space to continue",isPercent:!1};continue}for(let t=0;t<Si.length;t++){let l=Si[t];if((l.category==mn.foreground||l.category==mn.detail||l.category==mn.overlay)&&!l.detailsProcessed){l.detailsProcessed=!0,e.set(n,!1);let t=n;Nl(l,s[o++%s.length]).then((()=>{e.set(t,!0)})),n++}}let r=i.next();a=r.done;let c=r.value?.rendering||!1,d=0;for(let e of Object.keys(Rl))0==Rl[e]&&(d+=1);let u=[...e.values()].reduce(((e,t)=>e+(t?0:1)),0);if(yield{showUpdate:!c&&(u>0||d>0||u>0),message:""+l[t(oi/4)%4],isPercent:!1,value:`${d>0?`Waiting on 1 of ${d} threads, `:"Waiting for"} ${u} jobs queued`},0==u&&0==kl.length&&0==d&&a)break}yield{showUpdate:!1},Ft.copyBufferToScreen()},!0]],Ri=new class{heap;constructor(e){this.heap=new jl(1e10,e)}clear(){this.heap.clear()}topN(e){return this.heap.toArray().slice(0,e)}update(e){const t=new Set(this.heap.toArray());for(const n of e)t.has(n)?t.delete(n):this.heap.push(n);for(const e of t)this.heap.remove(e);return this.heap.toArray()}}((e=>{let{polyOverfitting:t,noiseOverfittingSpread:n,noiseOverfitFreq:l}=nt,i=e.area;if(1!==t&&(i*=Ki.getPolygonsAtPoint(e.center.toArray()).length>0?1:t),n>0){let t=n/2,a=sl(l,10,0,Ge);i*=xe(ye(yn(e.center.x,e.center.y,0,l,1-t,1+t),0,1,a.min,a.max),.001)}return xe(i,.001)})),Ti=new Set;function Mi(e){let t={x:e.center[0],y:e.center[1],z:-100},n={width:e.width,height:e.height,depth:e.depth};return{faces:new Jl(t,e.rotationProps,n,e.sides,{x:e.perspectiveCenter[0],y:e.perspectiveCenter[1],z:-1e3},90,Y/P,.001,1e3,[{position:Ie.position,brightness:1},{position:{x:-Ie.position.x,y:-Ie.position.y,z:Ie.position.z},brightness:.95},{position:{x:0,y:Ie.position.y,z:-1e3},brightness:.2},{position:{x:0,y:-Ie.position.y,z:-1e3},brightness:.2}],!0).getFaces2D(),shapeArgs:e}}let zi,Yi=!1,Pi=(e,t,n,l=0)=>{let i=1e3*n,a=1e3*l;if(!Yi){let e=J.num(800,1600),t=nt.noiseFieldCategoryInfluence;zi={[Se.used]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.horizontal]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.vertical]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.perspective]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.circle]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.wobbles]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.curves]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.rects]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.borderRect]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.triangle]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.objects]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)}},Yi=!0}let s=ve,o=sl(zi[e].freq,10,zi[e].offset,s),r=ye(s(xe(yn(t.x+zi[e].offset,t.y+zi[e].offset,zi[e].offset-a,zi[e].freq,0,1),.3)),o.min,o.max,zi[e].min,zi[e].max);return c(i*r)},Fi=()=>[Ai,ji,Ji,qi,_i,Ei,()=>!0],Hi=0,