memoscan
← all memos

Memo 0x367ac7b0…d703dd on Ethereum

rn xyz2rgb(lab2xyz(lab));}\n\n\n// Copyright (c) 2020 Björn Ottosson (MIT License)\nvec3 oklab_mix(vec3 cA,vec3 cB,float h){\nconst mat3 mA=mat3(.4121656120,.2118591070,.0883097947,.5362752080,.6807189584,.2818474174,.0514575653,.1074065790,.6302613616);\nconst mat3 mB=mat3(4.0767245293,-1.2681437731,-.0041119885,-3.3072168827,2.6093323231,-.7034763098,.2307590544,-.3411344290,1.7068625689); \nvec3 lA=pow(mA*cA,vec3(1./3.));\nvec3 lB=pow(mA*cB,vec3(1./3.));\nvec3 l=mix(lA,lB,h);\nreturn mB*(l*l*l);\n}\n\n// Copyright (c) 2023 Ronald van Wijnen (MIT License)\n#define S_S 38\n#define S_G 2.4\n#define S_E.0001\nfloat s_uc(float x){return (x<.04045)?x/12.92:pow((x+.055)/1.055,S_G);}\nfloat s_c(float x){return (x<.0031308)?x*12.92:1.055*pow(x,1./S_G)-.055;}\nvec3 s_s2l(vec3 s){return vec3(s_uc(s[0]),s_uc(s[1]),s_uc(s[2]));}\nvec3 s_l2s(vec3 l){return clamp(vec3(s_c(l[0]),s_c(l[1]),s_c(l[2])),.0,1.);}\nvoid s_up(vec3 l,out float w,out float c,out float m,out float y,out float r,out float g,out float b){\nw=min(l.r,min(l.g,l.b));\nl-=w;\nc=min(l.g,l.b);\nm=min(l.r,l.b);\ny=min(l.r,l.g);\nr=min(max(0.,l.r-l.b),max(0.,l.r-l.g));\ng=min(max(0.,l.g-l.b),max(0.,l.g-l.r));\nb=min(max(0.,l.b-l.g),max(0.,l.b-l.r));\n}\nvoid s_l2r(vec3 l,inout float R[S_S]){\nfloat w,c,m,y,r,g,b;\ns_up(l,w,c,m,y,r,g,b); \nR[0]=max(S_E,w+c*.96853629+m*.51567122+y*.02055257+r*.03147571+g*.49108579+b*.97901834);\nR[1]=max(S_E,w+c*.96855103+m*.54015520+y*.02059936+r*.03146636+g*.46944057+b*.97901649);\nR[2]=max(S_E,w+c*.96859338+m*.62645502+y*.02062723+r*.03140624+g*.40165780+b*.97901118);\nR[3]=max(S_E,w+c*.96877345+m*.75595012+y*.02073387+r*.03119611+g*.24490420+b*.97892146);\nR[4]=max(S_E,w+c*.96942204+m*.92826996+y*.02114202+r*.03053888+g*.06826880+b*.97858555);\nR[5]=max(S_E,w+c*.97143709+m*.97223624+y*.02233154+r*.02856855+g*.02732883+b*.97743705);\nR[6]=max(S_E,w+c*.97541862+m*.98616174+y*.02556857+r*.02459485+g*.01360600+b*.97428075);\nR[7]=max(S_E,w+c*.98074186+m*.98955255+y*.03330189+r*.01929520+g*.01000187+b*.96663223);\nR[8]=max(S_E,w+c*.98580992+m*.98676237+y*.05185294+r*.01423112+g*.01284127+b*.94822893);\nR[9]=max(S_E,w+c*.98971194+m*.97312575+y*.10087639+r*.01033111+g*.02636635+b*.89937713);\nR[10]=max(S_E,w+c*.99238027+m*.91944277+y*.24000413+r*.00765876+g*.07058713+b*.76070164);\nR[11]=max(S_E,w+c*.99409844+m*.32564851+y*.53589066+r*.00593693+g*.70421692+b*.46420440);\nR[12]=max(S_E,w+c*.99517200+m*.13820628+y*.79874659+r*.00485616+g*.85473994+b*.20123039);\nR[13]=max(S_E,w+c*.99576545+m*.05015143+y*.91186529+r*.00426186+g*.95081565+b*.08808402);\nR[14]=max(S_E,w+c*.99593552+m*.02912336+y*.95399623+r*.00409039+g*.97170370+b*.04592894);\nR[15]=max(S_E,w+c*.99564041+m*.02421691+y*.97137099+r*.00438375+g*.97651888+b*.02860373);\nR[16]=max(S_E,w+c*.99464769+m*.02660696+y*.97939505+r*.00537525+g*.97429245+b*.02060067);\nR[17]=max(S_E,w+c*.99229579+m*.03407586+y*.98345207+r*.00772962+g*.97012917+b*.01656701);\nR[18]=max(S_E,w+c*.98638762+m*.04835936+y*.98553736+r*.01366120+g*.94258630+b*.01451549);\nR[19]=max(S_E,w+c*.96829712+m*.00011720+y*.98648905+r*.03181352+g*.99989207+b*.01357964);\nR[20]=max(S_E,w+c*.89228016+m*.00008554+y*.98674535+r*.10791525+g*.99989891+b*.01331243);\nR[21]=max(S_E,w+c*.53740239+m*.85267882+y*.98657555+r*.46249516+g*.13823139+b*.01347661);\nR[22]=max(S_E,w+c*.15360445+m*.93188793+y*.98611877+r*.84604333+g*.06968113+b*.01387181);\nR[23]=max(S_E,w+c*.05705719+m*.94810268+y*.98559942+r*.94275572+g*.05628787+b*.01435472);\nR[24]=max(S_E,w+c*.03126539+m*.94200977+y*.98507063+r*.96860996+g*.06111561+b*.01479836);\nR[25]=max(S_E,w+c*.02205445+m*.91478045+y*.98460039+r*.97783966+g*.08987709+b*.01515250);\nR[26]=max(S_E,w+c*.01802271+m*.87065445+y*.98425301+r*.98187757+g*.13656016+b*.01540513);\nR[27]=max(S_E,w+c*.01613460+m*.78827548+y*.98403909+r*.98377315+g*.22169624+b*.01557233);\nR[28]=max(S_E,w+c*.01520947+m*.65738359+y*.98388535+r*.98470202+g*.32176956+b*.01565710);\nR[29]=max(S_E,w+c*.01475977+m*.59909403+y*.98376116+r*.98515481+g*.36157329+b*.01571025);\nR[30]=max(S_E,w+c*.01454263+m*.56817268+y*.98368246+r*.98537114+g*.48361920+b*.01571916);\nR[31]=max(S_E,w+c*.01444459+m*.54031997+y*.98365023+r*.98546685+g*.46488579+b*.01572133);\nR[32]=max(S_E,w+c*.01439897+m*.52110241+y*.98361309+r*.98550011+g*.47440306+b*.01572502);\nR[33]=max(S_E,w+c*.01437620+m*.51041094+y*.98357259+r*.98551031+g*.48576990+b*.01571717);\nR[34]=max(S_E,w+c*.01436343+m*.50526577+y*.98353856+r*.98550741+g*.49267971+b*.01571905);\nR[35]=max(S_E,w+c*.01435687+m*.50255080+y*.98351247+r*.98551323+g*.49625685+b*.01571059);\nR[36]=max(S_E,w+c*.01435370+m*.50126452+y*.98350101+r*.98551563+g*.49807754+b*.01569728);\nR[37]=max(S_E,w+c*.01435408+m*.50083021+y*.98350852+r*.98551547+g*.49889859+b*.01570020);\n}\nvec3 s_x2s(vec3 v){\nmat3 m;\nm[0]=vec3(3.24306333,-1.53837619,-.49893282);\nm[1]=vec3(-.96896309,1.87542451,.04154303);\nm[2]=vec3(.05568392,-.20417438,1.05799454);\nreturn s_l2s(vec3(dot(m[0],v),dot(m[1],v),dot(m[2],v)));\n}\nvec3 s_r2x(float R[S_S]){\nvec3 v=vec3(0.);\nv+=R[0]*vec3(.00006469,.00000184,.00030502);\nv+=R[1]*vec3(.00021941,.00000621,.00103681);\nv+=R[2]*vec3(.00112057,.00003101,.00531314);\nv+=R[3]*vec3(.00376661,.00010475,.01795439);\nv+=R[4]*vec3(.01188055,.00035364,.05707758);\nv+=R[5]*vec3(.02328644,.00095147,.11365162);\nv+=R[6]*vec3(.03455942,.00228226,.17335873);\nv+=R[7]*vec3(.03722379,.00420733,.19620658);\nv+=R[8]*vec3(.03241838,.00668880,.18608237);\nv+=R[9]*vec3(.02123321,.00988840,.13995048);\nv+=R[10]*vec3(.01049099,.01524945,.08917453);\nv+=R[11]*vec3(.00329584,.02141831,.04789621);\nv+=R[12]*vec3(.00050704,.03342293,.02814563);\nv+=R[13]*vec3(.00094867,.05131001,.01613766);\nv+=R[14]*vec3(.00627372,.07040208,.00775910);\nv+=R[15]*vec3(.01686462,.08783871,.00429615);\nv+=R[16]*vec3(.02868965,.09424905,.00200551);\nv+=R[17]*vec3(.04267481,.09795667,.00086147);\nv+=R[18]*vec3(.05625475,.09415219,.00036904);\nv+=R[19]*vec3(.06947040,.08678102,.00019143);\nv+=R[20]*vec3(.08305315,.07885653,.00014956);\nv+=R[21]*vec3(.08612610,.06352670,.00009231);\nv+=R[22]*vec3(.09046614,.05374142,.00006813);\nv+=R[23]*vec3(.08500387,.04264606,.00002883);\nv+=R[24]*vec3(.07090667,.03161735,.00001577);\nv+=R[25]*vec3(.05062889,.02088521,.00000394);\nv+=R[26]*vec3(.03547396,.01386011,.00000158);\nv+=R[27]*vec3(.02146821,.00810264,.0);\nv+=R[28]*vec3(.01251646,.00463010,.0);\nv+=R[29]*vec3(.00680458,.00249138,.0);\nv+=R[30]*vec3(.00346457,.00125930,.0);\nv+=R[31]*vec3(.00149761,.00054165,.0);\nv+=R[32]*vec3(.00076970,.00027795,.0);\nv+=R[33]*vec3(.00040737,.00014711,.0);\nv+=R[34]*vec3(.00016901,.00006103,.0);\nv+=R[35]*vec3(.00009522,.00003439,.0);\nv+=R[36]*vec3(.00004903,.00001771,.0);\nv+=R[37]*vec3(.00002000,.00000722,.0);\nreturn v;\n}\nfloat s_l2c(float l1,float l2,float t){\nfloat t1=l1*pow(1.-t,2.);\nfloat t2=l2*pow(t,2.);\nreturn t2/(t1+t2);\n}\nvec3 spectral_mix(vec3 c1,vec3 c2,float t){\nvec3 lrgb1=s_s2l(c1);\nvec3 lrgb2=s_s2l(c2);\nfloat R1[S_S];\nfloat R2[S_S];\ns_l2r(lrgb1,R1);\ns_l2r(lrgb2,R2);\nfloat l1=s_r2x(R1)[1];\nfloat l2=s_r2x(R2)[1];\nt=s_l2c(l1,l2,t);\nfloat R[S_S];\nfor (int i=0;i<S_S;i++){\nfloat KS=(1.-t)*(pow(1.-R1[i],2.)/(2.*R1[i]))+t*(pow(1.-R2[i],2.)/(2.*R2[i]));\nfloat KM=1.+KS-sqrt(pow(KS,2.)+2.*KS);\nR[i] = KM;\n}\nreturn s_x2s(s_r2x(R));\n}\nvec4 spectral_mix(vec4 c1,vec4 c2,float t){\nreturn vec4(spectral_mix(c1.rgb,c2.rgb,t),mix(c1.a,c2.a,t));\n}\n\nint cM(int i) {return i%uCn;}\nvoid main(){\nvec2 uv=vUv;\nvec4 cl=vec4(vec3(0.),1.);\nvec4 cieCl=cl,okCl=cl,spcCl=cl;\nfor(int i=0;i<ST-1;i++){\nfloat sR=1./float(ST-(S+(${n}-S)));\nfloat sP=sR*float(i);\nfloat sW=.01*sin(uv.x*PI*2.*${n}.0);\nfloat pos=uv.x+sW;\nfloat sM=smoothstep(sP-F,sP+F,pos)*smoothstep(pos-F,pos+F,sP+sR);\nfloat bM=pow(noise(uv*uVp.xy*.181),2.)*2.-1.;\nfloat bF=.02*sin(fract(pos/sR)*PI);\nfloat sA=gN(\n(pos-sP)/sR,\nmod(sP,sR*3.)\n)+bM*bF;\ncieCl.xyz+=sM*lab2rgb(mix(rgb2lab(uC[cM(i)]),rgb2lab(uC[cM(i)+1]),sA));\nokCl.xyz+=sM*oklab_mix(uC[cM(i)],uC[cM(i)+1],sA);\nspcCl.xyz+=sM*spectral_mix(uC[cM(i)],uC[cM(i)+1],sA);\n}\ncl+=((.1*cieCl+.25*okCl+.7*spcCl));\nfc=cl;\n}\n`)(t.config()),v);let r,a,c,l,p,m,u,y,S,w=!1,A=!1,R=!1,P=!1,E=0,I=0,B=0,T=0,F=[[0,0],[0,0],[0,0]];const k=(e=>{const t=e=>{const t=_[_.indexOf(e)];return[t[2].map((e=>_[e])),t[3].map((e=>_[e]))]},n=(e,n)=>0<t(e)[0].filter((e=>e[0]===n[0])).length,o=[],i=h[e[2][2]],r=M(i[0],i[1]);for(let e=0;e<r/2;e++){const e=_.filter((e=>{let t=0;for(let n=0;n<o.length;n++)if(e===o[n]&&(t++,t>3))return!1;return!0})),n=e[V(e.map((e=>e[1])))];o.push(n,U(t(n)[1]))}return Array(8).fill().map((()=>{const e=z(o),i=[e.splice(0,1)[0]];for(let r=0;999>r&&e.length;r++){const r=i[i.length-1];let a;for(let o=0;o<e.length;o++){const i=e[o];if(i[0]===r[0])continue;if(n(r,i))continue;const s=z(t(r)[1]);for(let t=0;t<s.length;t++){const n=e.indexOf(s[t]);if(-1<n){if(a)continue;a=e.splice(n,1)[0]}}if(!a){a=e.splice(o,1)[0];break}}a||(a=z(o).filter((e=>e[0]!==r[0]&&!n(r,e)))[0]),a||(a=_[0]),i.push(a)}const r=i.map((e=>e[0]));return[["uCn","i",r.length],["uC","v3[]",Float32Array.from([...r,r[0]].flatMap(X))]]}))})(Ie),L=[],O=n=>{ve.update(e,1e3/60),t.frame(n,P,ke,Le),B++},N=()=>{A=!1},$=e=>[e.__src[0]*e.__src[2],e.__src[1]*e.__src[2],e.__src[3],e.__src[4]],Y=e=>[e.position.x*y[0],e.position.y*y[1],e.angle,e.__invalid?0:1],j=e=>[ke?1:0,e.__anim[0],e.__anim[1]],q=(e=!1,v=!1,f)=>{var g=Math.round;if(r=he.innerWidth,c=he.innerHeight,e||v||Ve||r!==a||c!==l){if(a=r,l=c,p=r/c,Ve||(p>=x?r=g(c*x):c=g(r/x),p=x),m=Ae("dpr")||s(he.devicePixelRatio,2),u=[r,c,r*m,c*m,p,m],v){const e=1>p?d*p:d,t=1>p?d:d/p;e/m>r&&(u[2]=e,u[3]=t)}t.resize(u,Ve),y=[u[2]/t.size()[0],u[3]/t.size()[1]],n.resize(u[2],u[3],u[0],u[1]),o.resize(u[2],u[3],u[0],u[1]),v||W(Ce,{width:`${r}px`,height:`${c}px`}),(e=>{const n=s(16384,u[2]*t.config()[1]*t.config()[2]*2);i.resize(n,3,.9*r,.9*c);let o=0;const a=()=>{o++,o===L.length&&G(e)};k.forEach(((e,t)=>{i.frame([E,I],e),L[t]=new Image,L[t].onload=a,L[t].src=Me.toDataURL()}))})((()=>{w||(w=!0,S=G(K)),N(),v&&G(f)}))}},K=()=>{const e=performance.now();var i;E=s(e-T,1e3/30),T=e,I+=E,A||(O([E,I,B]),R=t.resting(),!R||P||ke?(o.frame([E,I],(i=t.bodies(),[["uCl","v3",X(b[Ie[3][2]])],["uCd","v3",X(g)],["uBdS","v4[]",Float32Array.from(i.flatMap($))],["uBdP","v4[]",Float32Array.from(i.flatMap(Y))],["uBdA","v3[]",Float32Array.from(i.flatMap(j))],["uTx","t[]",L,"MIRRORED_REPEAT","LINEAR"],["uI","f",Ue?1:0]])),I>E&&n.frame(I,u[2],u[3],y,t.bodies(!0,!0),Ue,1===Oe)):(A=!0,n.clear())),S=G(K)},H=({target:e,clientX:n,clientY:o},i,r)=>{e instanceof HTMLButtonElement||(F[0]=[n/u[0],o/u[1]],i&&(N(),F[1]=F[0],P=!0,t.pointerDown()),F[2]=[F[0][0]-F[1][0],F[0][1]-F[1][1]],r&&(D(F[2]),P=!1,G(t.pointerUp)))},Z=e=>H(e,!0),J=e=>H(e),Q=e=>H(e,!1,!0);return q(),Fe||(()=>{for(let e=0;e<120&&B<7200;)O([0,0,B]),e=t.resting()?e+1:0})(),{resize:q,save:()=>{q(!0,!0,(()=>Be.toBlob((async e=>{await(async(e,t)=>{const n=document;console.log("Downloading...");const o=window.URL.createObjectURL(e),i=n.body.appendChild(n.createElement("a"));i.href=o,i.download=t,i.click(),n.body.removeChild(i),window.URL.revokeObjectURL(o)})(e,`balance-${Date.now()}-${Ee}.png`),q(!0)}))))},mousedown:e=>{t.mousedown(e),Z(e)},mousemove:e=>{t.mousemove(e),J(e)},mouseup:e=>{t.mouseup(e),Q(e)},touchstart:e=>{e.clientX=e.touches[0].clientX,e.clientY=e.touches[0].clientY,t.touchstart(e),Z(e)},touchmove:e=>{e.clientX=e.touches[0].clientX,e.clientY=e.touches[0].clientY,t.touchmove(e),J(e)},touchend:e=>{e.clientX=e.changedTouches[0].clientX,e.clientY=e.changedTouches[0].clientY,t.touchend(e),Q(e)},cleanup:()=>{he.cancelAnimationFrame(S)}}})()};t(),W(Se,{touchAction:"none",margin:0,display:"flex",alignItems:"center",background:g}),W(Ce,{position:"relative",margin:"0 auto"}),W(Te,{pointerEvents:"none",position:"absolute",inset:0}),W(Be,{background:Ue?g:b[Ie[3][2]]}),W(Me,{position:"absolute",right:0,bottom:0,display:"none"}),Y(he,"resize",(()=>e.resize())),Y(he,"keyup",(t=>{S();const n=t.key.toLowerCase();"s"===n&&e.save(),"`"===n&&(Oe=++Oe%3,W(Me,{display:2===Oe?"block":"none"}))}));let n=!1;const o=$(Se,N("nav")),i=$(o,N("button")),r=$(o,N("button")),a=$(o,N("div")),c=$(a,N("button")),l=$(a,N("button")),p=$(a,N("button")),m=$(a,N("button")),u=$(a,N("button"));W(o,{position:"absolute",right:0,top:0,padding:"10px",opacity:0,textAlign:"right",fontSize:"20px",fontFamily:"monospace",transition:"opacity 0.2s",transform:"translateZ(0)"}),W(a,{display:"none",flexDirection:"column",margin:"5px 0 0",fontSize:"17px"});const y=()=>{W(o,{opacity:0})},S=()=>{W(o,{opacity:1}),clearTimeout(ze),ze=setTimeout(y,3e3)},w=(e,t)=>(e?we.delete(t):we.set(t,""),Pe()||he.history.replaceState({},"",he.location.pathname+`?${we}`.replace(/=(?=&|$)/g,"")),!e),A=()=>{Le=w(Le,"excite"),P(),t()};Y(Ce,"mousedown",(t=>{S(),e.mousedown(t)})),Y(_e,"mousemove",(t=>{S(),e.mousemove(t)})),Y(_e,"mouseup",(t=>{S(),e.mouseup(t)})),Y(Ce,"touchstart",(t=>{S(),e.touchstart(t)})),Y(_e,"touchmove",(t=>{S(),e.touchmove(t)})),Y(_e,"touchend",(t=>{S(),e.touchend(t)}));const R=[[i,()=>"+",()=>{n=!n,n?(i.innerText="-",W(a,{display:"flex"})):(i.innerText="+",W(a,{display:"none"}))}],[r,()=>"×",()=>W(o,{display:"none"})],[c,()=>(Ve?"☑":"☐")+" expand",()=>{Ve=w(Ve,"expand"),P(),t()}],[l,()=>(Fe?"☑":"☐")+" expose",()=>{Fe=w(Fe,"expose"),P(),t()}],[p,()=>(ke?"☑":"☐")+" excess",()=>{ke=w(ke,"excess"),Le&&A(),P(),t()}],[m,()=>(Le?"☑":"☐")+" excite",A,()=>!ke],[u,()=>"↓ export",()=>e.save()]];R.forEach((e=>{W(e[0],{fontSize:"inherit",fontFamily:"inherit",color:g,padding:"5px 10px",margin:"4px 2px 0",textAlign:"left"}),Y(e[0],"click",e[2])}));const P=()=>{R.forEach((e=>{e[0].innerText=e[1](),e[3]&&(e[0].disabled=e[3]()?"disabled":"")}))};P()})()})();