0x92972fee…0b05sent to0x99a9b7c1…b069·#15,814,175·view on Etherscan
esFromLevel(e))}computeBranch(t,r){const o=this.getSrc(t),[i,a,n]=[o,t.dst,t.control].map((e=>y.vecToP5Vec(e))),l=p5.Vector.sub(a,i).normalize();let c=e.atan2(l.y,l.x);const d=r.angle,h=d/Math.max(1,r.branchFactor-1)+2*Math.PI,m=r.angleOff??0,p=[],u=e.shuffle([...new Array(r.branchFactor)].map(((t,o)=>o<=Math.round(e.random(.25*r.branchFactor,r.branchFactor)))));for(let e=0;e<r.branchFactor;e++){const o=r.length,l=h*(r.type!==s.None&&r.type!==s.Flair||!(u[e]||4===r.branchFactor&&r.angle===1.5*Math.PI)||"growing"!==y.CONFIG.getProp("treeStage")?e:0)+c+m-d/2,f={dst:{x:a.x+o*Math.cos(l),y:a.y+o*Math.sin(l)},control:p5.Vector.add(a,p5.Vector.sub(a,r.type===s.Petals?i:n).normalize().mult(r.curvature*o+.00137)),parentId:t.id,level:r,id:this.branches.length};p.push(f),this.branches.push(f)}return p}computeBranches(e){this.branchLevelIndices=new Array(e.levels.length);const t=[...e.levels];for(let e=0;e<t.length;e++){let r=this.branches.length;const o=this.getBranchesFromLevel(e-1);let i=t[e];if(!(i.length<=0)){for(const e of o)this.computeBranch(e,i);this.branchLevelIndices[e]=[r,this.branches.length],i.pop&&(e-=i.pop,t.splice(e+1,i.pop))}}return this.branches}toScreen(t){return(t+1)/2*e.width}toNdcTrans(e,t,r){return(e+t)/r}getSrc(e){return{x:e.parentId>=0?this.branches[e.parentId].dst.x:0,y:e.parentId>=0?this.branches[e.parentId].dst.y:1e-4}}getMaxControlSize(){return this.getControlSize(this.getMainStem())}getMinControlSize(){return this.getControlSize(this.getLastBranch())}getMainStem(){return this.branches[this.branches.findIndex((e=>e.level.type===s.MainStem))]}getLastBranch(){return this.branches[this.branches.length-1]}glUniformInit=t=>{const{maxY:r,middleX:o,middleY:a,scale:n}=this.getScreenParams();let s=this.branches.map((e=>{let t=this.toNdcTrans(...e.parentId>=0?[this.getSrc(e).y,a,n]:[r,a,n]);return e.parentId<0&&(t=1.05),[this.toNdcTrans(e.dst.x,o,n),this.toNdcTrans(e.dst.y,a,n),this.toNdcTrans(this.getSrc(e).x,o,n),t]})).flat();const l=this.branches.map((e=>{const{middleX:t,middleY:r,scale:o}=this.getScreenParams(),i=e.level;return[this.toNdcTrans(e.control.x,t,o),this.toNdcTrans(e.control.y,r,o),this.getControlSizeGL(e),i.stroke]})).flat(),c=t.memo.combineTex,d=c._renderer.GL,h=this.branches.length,m=e=>({height:1,width:h,texData:e}),p={dataType:d.FLOAT,format:d.RGBA,internalFormat:d.RGBA32F,minFilter:d.NEAREST,magFilter:d.NEAREST,wrapS:d.CLAMP_TO_EDGE,wrapT:d.CLAMP_TO_EDGE},u=new p5.Texture(c._renderer,m(new Float32Array(s)),p),f=new p5.Texture(c._renderer,m(new Float32Array(l)),p),g={...p,dataType:d.UNSIGNED_BYTE,internalFormat:d.RGBA,wrapS:d.REPEAT,wrapT:d.REPEAT},v=t.CONFIG.getProp("palette"),x=v[v.length-1],b=new p5.Texture(c._renderer,{height:1,width:v.length,texData:new Uint8Array([...v.map((e=>[...t.p5ColorToByteArr(e),1]))].flat())},g),y=new p5.Texture(c._renderer,{height:1,width:v.length-1,texData:new Uint8Array([...v.slice(1).map((e=>[...t.p5ColorToByteArr(e),1]))].flat())},g),F=new Uint8Array(this.branches.map((e=>{const t=e.level;return 0!==t.curvature?t.fill:i.None}))),C=new p5.Texture(c._renderer,m(F),{...p,dataType:d.UNSIGNED_BYTE,format:d.RED_INTEGER,internalFormat:d.R8UI,wrapS:d.REPEAT,wrapT:d.REPEAT});return{branches:u,controls:f,palette:b,paletteWOutBg:y,bgCol:t.p5ColorToArr(x),fills:C,boxDims:[...this.getBoxDims()],darkestCol:t.p5ColorToArr([...t.CONFIG.getProp("palette")].sort(((r,o)=>t.luma(e.color(r))-t.luma(e.color(o))))[0])}};getBoxDims=()=>{const{minX:t,maxX:r,maxY:o,minY:i,middleX:n,middleY:s,scale:l,margin:c}=this.getScreenParams(),d=this.toNdcTrans(t,n,l),h=this.toNdcTrans(i,s,l),m=[(this.toNdcTrans(r,n,l)-d)/2,(this.toNdcTrans(o,s,l)-h)/2],p=this.branches[0],u=f(this.getSrc(p).x,this.getSrc(p).y,p.control.x,p.control.y,p.dst.x,p.dst.y),g=this.toNdcTrans(u.x.min,n,l),v=this.toNdcTrans(u.x.max,n,l),x=Math.max(v,Math.abs(g)),b=e.shuffle(["fit"!==y.CONFIG.getProp("windowMargin")?.55:1,1].map(((e,t)=>({dim:e,i:t})))),F=b.sort(((e,t)=>m[e.i]-m[t.i])).map(((e,t)=>e.dim*m[t]));return F[0]=1!==b[0].dim?(()=>{const e=c/l;return Math.abs(x-F[0])<e?x+e:F[0]})():F[0],F.map(((e,t)=>1!==b[t].dim?a.steps(e,32,!0):e))};renderGl(){y.drawPost(`\n${h}\n${d}\n${m}\nfloat luma(vec3 color){return dot(color, vec3(0.299, 0.587, 0.114));}\nuniform sampler2D branches;uniform sampler2D controls;uniform sampler2D palette;uniform vec3 bgCol;uniform usampler2D fills;uniform vec2 boxDims;uniform vec3 darkestCol;float alpha = 0.39999;float thick = 0.0007;uint None = uint(0);uint Full = uint(1);uint Half = uint(2);struct Ret {float outline;vec3 blended;float patternFill;float outsideFill;float circles;float circlesWOutBorder;};vec3 blendSub(float d1, vec3 col, vec4 col1) {float alpha = col1.a;float antialiasEdges = 0.002;d1 = smoothstep(-antialiasEdges, antialiasEdges, d1);return d1 <= 0. ? col - col1.a : col.rgb;}Ret f(vec2 st) {float outline = 10.;vec3 blended = vec3(1.);float patternFill = 10.;float outsideFill = 10.;float circles = 10.;float circlesWOutBorder = 10.;for (int i = 0; i < ${this.branches.length}; i++) {vec4 branch = texelFetch(branches, ivec2(i,0), 0);vec2 dst = branch.xy;vec2 parentDst = branch.zw;\t\tvec4 control = texelFetch(controls, ivec2(i,0), 0);float d;uint isFilled = texelFetch(fills, ivec2(i,0), 0).r;float curve = sdBezier(st, dst, control.xy, parentDst)-thick;float line = sdSegment(st, dst, parentDst)-thick * 0.65;float curves = -1.;float innerPattern = -1.; float outerThickFact = 6.;d = sdFilledBezier(st, dst, control.xy, parentDst); float outerThick = thick * outerThickFact;if (isFilled == Full || isFilled == Half){vec2 projecting = control.xy;vec2 projectingOn = dst - parentDst;\t\t\tfloat dotted = dot(projecting, projectingOn);vec2 projected = sign(dotted) * dotted / dot(projectingOn, projectingOn) * (projectingOn) + parentDst;vec2 reflectVec = reflect(projected - projecting, normalize(projectingOn));vec2 flippedControl = reflectVec + projected; float curve1 = sdBezier(st, dst, flippedControl, parentDst)-thick;curves = opUnion(curve, curve1);bool controlBranchParallel = abs(dot(normalize(dst-parentDst), normalize(control.xy-parentDst))) >= 0.999;if (controlBranchParallel) { outsideFill = opUnion(outsideFill, curve - thick*4. * control.w); continue; } innerPattern = opSmoothUnion(curve, curve1, 0.015);if (isFilled == Full) {d = opUnion(d, sdFilledBezier(st, dst, flippedControl, parentDst));\t\t\t\toutsideFill = opUnion(outsideFill, curve1 - outerThick);} else {outsideFill = opUnion(outsideFill, line - outerThick);}outsideFill = opUnion(outsideFill, curve - outerThick);\t\t\tfloat bandaidThickness = thick * 8.;float bandaid = sdSegment(st, dst, parentDst)-bandaidThickness;d = d <= 0. ? opUnion(d, bandaid) : d;blended = blendSub(d+thick, blended, vec4(vec3(0), alpha));\t\t\tif (isFilled == Full){outline = opUnion(outline, curves);} else if (isFilled == Half) {outline = opUnion(outline, opUnion(line, curve));}} else {outsideFill = opUnion(outsideFill, curve - thick*4. * control.w);if (i == 0) {outsideFill -= pow(map(st.y, branch.y, 1., 0., 1.) * 0.02,1.5);}}\t\tif (innerPattern != -1.) {patternFill =\td <= 0. ? opUnion(patternFill, innerPattern) : patternFill;}\t\tfloat radius = control.z;if (i > 0 && radius > 0.) {float circle = sdCircle(st - control.xy, radius);float subCircle = sdCircle(st - control.xy, max(radius + thick*2.*map(radius,0.005,0.04,0.75,1.), radius+thick));circlesWOutBorder = min(circlesWOutBorder, subCircle);circle = opSubtraction(circle, subCircle);circles = min(circles, circle);}} return Ret(outline, blended, patternFill, outsideFill, circles, circlesWOutBorder);}\n`,`vec2 origSt = st;st = uv * 2. - 1.;Ret ret = f(st);float outline = ret.outline;float blended = ret.blended.r;float blendedNorm = fract(ret.blended.r);float circles = ret.circles;float circlesWOutBorder = ret.circlesWOutBorder;float patternFill = ret.patternFill;float outsideFill = ret.outsideFill;patternFill = abs(patternFill) < 0.005 ? patternFill : fract(pow(patternFill, 0.5) * 10.);float boxRound = 0.03;float maxDim = max(boxDims.x, boxDims.y);float box_ = ${"max"!==y.CONFIG.getProp("windowMargin")?y.CONFIG.getProp("diamond")?"sdBox(rotateVec(st, PI*.25), vec2(maxDim/1.4121)-boxRound)":"sdBox(st, boxDims-boxRound)":"0."};\n${y.CONFIG.getProp("windowBars")?`vec2 repeat = vec2(${(()=>{const t=y.CONFIG.getProp("windowBars"),r=this.getBoxDims();return"max"===y.CONFIG.getProp("windowMargin")?y.CONFIG.getProp("windowBars"):e.map(Math.min(...r)/Math.max(...r),0,1,t-.2,t)})()}${"center"===y.CONFIG.getProp("windowBarsPerspective")?"":"left"===y.CONFIG.getProp("windowBarsPerspective")||"right"===y.CONFIG.getProp("windowBarsPerspective")?`*map(${"left"!==y.CONFIG.getProp("windowBarsPerspective")?"1.-":""}uv.x,0.,1.,0.5,1.)`:`*map(${"out"===y.CONFIG.getProp("windowBarsPerspective")?"1.-":""}abs(st.x),0.,1.,0.65,1.)`}); float barRound = boxRound*0.5/max(repeat.x, repeat.y);float barThick = 0.53;`:""}float box = ${y.CONFIG.getProp("windowBars")?"max(box_-boxRound, (sdBox(vec2(mod(st, repeat) - repeat + repeat/2.) / repeat, vec2(maxDim*barThick-barRound))-barRound))":"box_-boxRound"};float boxOutlineThick = thick;bool insideBox = box <= boxOutlineThick;bool outsideCircles = circlesWOutBorder > 0.;float circlesOutline = clamp(circles / fwidth(circles * (scaleFactor * 0.75)), 0.,1.); outline = outsideCircles ? outline : circlesOutline;blended = outsideCircles ? blended : 0.5;bool outsidePetals = blended >= 0.999;bool insidePetals = !outsidePetals;bool insideFill = outsideFill-thick < 0.;float colSteps = 4.;vec3 oCol;vec3 bgCol = texture(palette, vec2(1., 0)).rgb;vec3 fgCol = texture(palette, vec2(0., 0)).rgb;vec3 midCol = texture(palette, vec2(0.5)).rgb;oCol = !insidePetals && !insideFill ? fgCol : oCol;float lumaBg = luma(oCol);float bgOutlineCol = lumaBg < 0.45 ? 1. : lumaBg > 0.55 ? 0. : step(0.5, ${e.random().toPrecision(2)});oCol = mix(vec3(bgOutlineCol), oCol, negMult(tex.r, 0.15));float innerPattern = (insidePetals && outsideCircles) ? blendedNorm > 0. ? fract(((blendedNorm + steps(patternFill, 3.)) ) + 0.75) : 0. : blended;oCol = insidePetals ? texture(palette, vec2(innerPattern)).rgb : oCol;${"max"!==y.CONFIG.getProp("windowMargin")?"origSt.y += (1.-boxDims.y)*0.5;":""}float cloudsSdf = map(1.-origSt.y, 0., 1., 0.25, 1.) * mix(noi