memoscan
← all memos

Memo 0x5f1427d6…012e25 on Ethereum

class FastPoisson{constructor(){this.points=[],this.index=0,this.radius=7,this.dead=!1}solve(t){let s=45,e=80;8==t&&(s=25,e=45);let i=this.radius,$=myWidth,h=myHeight,_;i=Math.min(i,$/s*.9),i*=i;let l,r=createVector(R.random_dec(),R.random_dec());for(let a=0;a<e;a++)for(let g=0;g<s;g++){let p=0;for(;;){r=createVector(R.random_dec(),R.random_dec());let x=createVector(r.x+g,r.y+a);x.x/=s,x.y/=e,x.x*=$,x.y*=h;let o=g+a*e,f=g-1+a*e,c=g+(a-1)*e,n=g-1+(a-1)*e,d=g+1+(a-1)*e,y=this.points[f],b=this.points[c],P=this.points[n],u=this.points[d];if(0!=g&&0==a){if(p5.Vector.sub(y,x).magSq()>i){this.points[o]=x;break}}else if(0==g&&0!=a){if(p5.Vector.sub(b,x).magSq()>i){this.points[o]=x;break}}else if(0==g&&0==a){this.points[o]=x;break}else if(0!=g&&0!=a&&g!=s-1){let m=p5.Vector.sub(b,x);p5.Vector.sub(y,x),p5.Vector.sub(P,x),p5.Vector.sub(u,x);let k=m.magSq(),v=m.magSq(),w=m.magSq(),B=m.magSq();if(k>i&&v>i&&w>i&&B>i){this.points[o]=x;break}}else if(0!=g&&0!=a&&g==s-1){let S=p5.Vector.sub(b,x);p5.Vector.sub(y,x),p5.Vector.sub(P,x);let W=S.magSq(),q=S.magSq(),T=S.magSq();if(W>i&&q>i&&T>i){this.points[o]=x;break}}if(++p>1e3)break}}}render(t,s){for(let e=0;e<this.points.length;e++)if(this.points[e]){let i=this.points[e],$=i.x,h=i.y,_=R.random_num(5,7),l=palettes.getBg(R.random_num(0,1)),r=R.random_num(0,TWO_PI);0==s?drawCherryBlossom(t,$,h,_,l,r,0):1==s&&drawMum(t,$,h,3*_,l,r)}}}class Fabric{constructor(t,s){this.spacing=t,this.bgType=s,this.sw=.05*t,this.hexBgPs=[],this.gridBgPs=[],this.hexps=[],this.hexps2=[],this.gridps=[],this.buildPsArrays()}buildPsArrays(){let t=this.spacing,s=.5*t,e=myHeight/t+1,i=myWidth/(.866*t)+1;for(let $=0;$<e;$++)for(let h=0;h<i;h++){let _=h*t*.866,l=$*t;h%2==0&&(l+=s),this.hexBgPs.push({x:_,y:l,i:$,j:h})}this.hexBgPs.sort((t,s)=>t.y-s.y),e=myHeight/t+1,i=myWidth/s+1;for(let r=0;r<e;r++)for(let a=0;a<i;a++){let g=a*s,p=r*t;a%2==0&&(p+=s),this.gridBgPs.push({x:g,y:p,i:r,j:a})}this.gridBgPs.sort((t,s)=>t.y-s.y);let x=TWO_PI/6;for(let o=0;o<6;o++){let f=x*(o+.5),c=cos(f),n=sin(f);this.hexps.push({x:c,y:n,t:f}),f+=.5*x,c=cos(f),n=sin(f),this.hexps2.push({x:c,y:n,t:f})}x=TWO_PI/4;for(let d=0;d<4;d++){let y=x*(d+.5),b=cos(y),P=sin(y);this.gridps.push({x:b,y:P})}}drawFabric(t){if(t.background(palettes.getBg(0)),this.bgType<=6){t.stroke(palettes.getBg(1)),t.strokeWeight(this.sw);let s=R.random_int(0,2);for(let e of this.hexBgPs){let i=e.x,$=e.y,h=e.i,_=e.j;0==this.bgType?this.drawHexWeave(t,i,$,this.spacing):1==this.bgType?this.drawDiamondWaves(t,i,$,this.spacing):2==this.bgType?this.drawCircleWaves(t,i,$,h,_,this.spacing,s):3==this.bgType?this.drawHempLeaves(t,i,$,h,_,this.spacing):4==this.bgType?this.drawHexWeave2(t,i,$,this.spacing):5==this.bgType?this.drawBasketWeave(t,i,$,h,_,this.spacing,s):6==this.bgType&&this.drawHexStars(t,i,$,h,_,this.spacing,s)}}else 7==this.bgType?poisson.render(t,0):8==this.bgType&&poisson.render(t,1)}drawHexWeave(t,s,e,i){let $=.6*i,h=.3*i;t.noStroke();for(let _=0;_<6;_+=2){let l=map(_,0,6,0,1,!0),r=[],a=_,g=(_+1)%6,p=(_+5)%6,x=this.hexps[a].x,o=this.hexps[a].y,f=this.hexps[g].x,c=this.hexps[g].y,n=this.hexps[p].x,d=this.hexps[p].y,y=s,b=e,P=s+f*$,u=e+c*$,m=P+n*h,k=u+d*h,v=s+x*h,w=e+o*h,B=s+n*$,S=e+d*$,W=B+f*h,q=S+c*h;for(let T of(r.push({x:y,y:b}),r.push({x:P,y:u}),r.push({x:m,y:k}),r.push({x:v,y:w}),r.push({x:W,y:q}),r.push({x:B,y:S}),t.fill(palettes.getBg(l)),t.beginShape(),r))t.vertex(T.x,T.y);t.endShape(CLOSE)}}drawDiamondWaves(t,s,e,i){let $=.05*i;for(let h=0;h<4;h++){let _=map(h,0,3,.25,1),l=lerp(0,i,_),r=this.hexps[3].x,a=this.hexps[3].y,g=this.hexps[4].x,p=this.hexps[4].y,x=this.hexps[5].x,o=this.hexps[5].y;drawDottedLine(t,s+r*l,e+a*l,s+g*l,e+p*l,2*h+2,$),drawDottedLine(t,s+g*l,e+p*l,s+x*l,e+o*l,2*h+2,$)}}drawHexStars(t,s,e,i,$,h,_){let l=.15*h,r=.5*l,a=.25*h,g=this.hexps[4].x,p=this.hexps[4].y,x=this.hexps[3].x,o=this.hexps[3].y,f=this.hexps[5].x,c=this.hexps[5].y;if(i%3==(2+($+1)%2)%3){drawDottedLine(t,s+g,e+p,s+g*h,e+p*h,3,l);for(let n=1;n<6;n+=2){let d=n,y=this.hexps[d].x,b=this.hexps[d].y;t.line(s+y*r,e+b*r,s+y*a,e+b*a)}}else if(i%3==(1+($+1)%2)%3){drawDottedLine(t,s+x,e+o,s+x*h,e+o*h,3,l),drawDottedLine(t,s+f,e+c,s+f*h,e+c*h,3,l);for(let P=0;P<6;P+=2){let u=P,m=this.hexps[u].x,k=this.hexps[u].y;t.line(s+m*r,e+k*r,s+m*a,e+k*a)}}else if(i%3==(0+($+1)%2)%3){for(let v=0;v<6;v++){let w=v,B=this.hexps[w].x,S=this.hexps[w].y;t.line(s+B*r,e+S*r,s+B*a,e+S*a)}drawDottedHex(t,this.hexps,s,e,.6*h),0==_?drawDottedHex(t,this.hexps,s,e,.4*h):2==_&&drawDottedHex(t,this.hexps,s,e,.8*h)}}drawBasketWeave(t,s,e,i,$,h,_){let l=.15*h,r=.8;1==_?r=.7:2==_&&(r=.8);let a=h*r,g=.65*h;if(i%3==(0+($+1)%2)%3){for(let p=0;p<6;p++){let x=p,o=(p+1)%6,f=this.hexps2[x].x*a,c=this.hexps2[x].y*a,n=this.hexps2[o].x*a,d=this.hexps2[o].y*a,y=this.hexps2[x].x*g,b=this.hexps2[x].y*g,P=this.hexps2[o].x*g,u=this.hexps2[o].y*g,m=n-f,k=d-c;n=f+2*m,d=c+2*k,0==_?(t.strokeWeight(.5*this.sw),t.line(s+f,e+c,s+n,e+d),t.strokeWeight(2*this.sw),t.line(s+y,e+b,s+P,e+u)):drawDottedLine(t,s+f,e+c,s+n,e+d,5,l)}1==_?(drawDottedHex(t,this.hexps2,s,e,.5*h),drawDottedHex(t,this.hexps2,s,e,.6*h)):2==_&&(t.fill(palettes.getBg(1)),t.circle(s,e,.75*h))}}drawCircleWaves(t,s,e,i,$,h,_){let l=palettes.getBg(0),r=palettes.getBg(1);t.stroke(l);let a;if(0==_?a=8:1==_?a=int(map(noise(.008*s,.2*e),.25,.75,6,9,!0)):2==_&&(a=10),t.fill(color(0,45)),t.circle(s,e,2.1*h),2==_){if(i%2==0&&$%2==0)t.fill(r),t.circle(s,e,1.9*h),t.fill(l),t.circle(s,e,1.8*h);else for(let g=0;g<a;g++){let p=map(g,0,a-1,0,1),x=lerp(.95*h,h/a,p);t.fill(lerpColor(r,l,g%2)),t.circle(s,e,2*x)}}else for(let o=0;o<a;o++){let f=map(o,0,a-1,0,1),c=lerp(.95*h,h/a,f);t.fill(lerpColor(r,l,o%2)),t.circle(s,e,2*c)}}drawHempLeaves(t,s,e,i,$,h){let _=.5*h,l=.6*h;for(let r of this.hexps){let a=r.x,g=r.y;t.line(s,e,s+a*_,e+g*_)}for(let p of this.hexps2){let x=p.x,o=p.y;t.line(s,e,s+x*l,e+o*l)}}drawDottedWaves(t,s,e,i,$,h){t.noStroke(),t.fill(palettes.getBg(1)),t.circle(s,e,2*h),t.stroke(palettes.getBg(0));for(let _=0;_<8;_++){let l=map(_,0,7,0,1);drawDottedArc(t,s,e,.6*TWO_PI,.9*TWO_PI,lerp(.95*h,h/8,l),3)}}drawHexWeave2(t,s,e,i){let $=.1*i,h=.2*i,_=.225*i;for(let l=0;l<6;l+=2){let r=l,a=(l+1)%6,g=(l+5)%6,p=this.hexps[r].x,x=this.hexps[r].y,o=(this.hexps[r].t+10*TWO_PI)%TWO_PI/TWO_PI,f=this.hexps[a].x,c=this.hexps[a].y,n=(this.hexps[a].t+10*TWO_PI)%TWO_PI/TWO_PI,d=this.hexps[g].x,y=this.hexps[g].y,b=(this.hexps[g].t+10*TWO_PI)%TWO_PI/TWO_PI;t.stroke(palettes.getIri(o,50)),drawDottedLine(t,s,e,s+p*h*3,e+x*h*3,3,$),t.stroke(palettes.getIri(n,50)),drawDottedLine(t,s+f*_,e+c*_,s+f*_+p*_*2,e+c*_+x*_*2,3,$),t.stroke(palettes.getIri(b,50)),drawDottedLine(t,s+d*_,e+y*_,s+d*_+p*_*2,e+y*_+x*_*2,3,$)}}drawHempLeaves2(t,s,e,i,$,h){let _=1*h,l=.6*h;t.noStroke();for(let r=0;r<6;r++){let a=map(getNoise(s,e,.0025),.25,.75,.8,1,!0),g=map(r,0,6,a,1),p=this.hexps[r].x*_,x=this.hexps[r].y*_,o=this.hexps2[r].x*l,f=this.hexps2[r].y*l;t.strokeWeight(.25),t.stroke(palettes.getBg(1)),t.fill(palettes.getBg(.5*g)),t.beginShape(),t.vertex(s,e),t.vertex(s+p,e+x),t.vertex(s+o,e+f),t.endShape(CLOSE)}}drawSquareWeave(t,s,e,i,$,h){let _=.1*h,l=.25*h,r=.025*h;for(let a=0;a<4;a++){let g=a,p=(a+1)%4,x=this.gridps[g].x*l,o=this.gridps[g].y*l,f=this.gridps[p].x*l,c=this.gridps[p].y*l,n=f-x,d=c-o;$%2==1?drawDottedLine(t,s+(x=f-n*r),e+(o=c-d*r),s+f,e+c,2,_):(f=x+n*r,c=o+d*r,drawDottedLine(t,s+x,e+o,s+f,e+c,4,_))}t.circle(s,e,5)}drawSquareCircles(t,s,e,i,$,h){t.noFill(),t.strokeWeight(.5),t.circle(s,e,1*h),t.circle(s,e,.7*h)}}class Palettes{constructor(){this.fgPalettes=[],this.bgPalettes=[],this.loadPalettes(),this.numPalettes=this.fgPalettes.length,this.id=R.random_int(0,this.numPalettes-1),this.fgcs=[],this.bgcs=[],this.irics=[],this.createColors(this.id)}loadPalettes(){append(this.bgPalettes,[15,15,15,35,35,35]),append(this.fgPalettes,[33,72,106,51,130,18,254,221,210,235,163,177]),append(this.bgPalettes,[15,15,15,45,45,45]),append(this.fgPalettes,[5,5,5,15,15,15,25,25,25,35,35,35]),append(this.bgPalettes,[44,50,130,64,70,150]),append(this.fgPalettes,[49,19,140,33,51,151,112,91,78,168,150,144]),append(this.bgPalettes,[55,63,68,95,103,108]),append(this.fgPalettes,[142,61,39,176,145,112,117,131,141,204,213,218]),append(this.bgPalettes,[117,1,39,157,21,59]),append(this.fgPalettes,[75,75,75,100,88,88,205,111,111,225,144,111]),append(this.bgPalettes,[13,26,40,33,46,60]),append(this.fgPalettes,[23,37,51,68,87,99,206,199,187,142,174,196]),append(this.bgPalettes,[15,26,15,35,46,35]),append(this.fgPalettes,[17,33,14,59,73,63,116,142,121,174,210,213]),append(this.bgPalettes,[20,30,73,40,50,93]),append(this.fgPalettes,[25,36,84,219,68,73,232,203,172,235,143,108]),append(this.bgPalettes,[200,200,200,255,255,255]),append(this.fgPalettes,[0,0,0,10,10,10,25,25,25,55,55,55]),append(this.bgPalettes,[18,44,65,30,50,80]),append(this.fgPalettes,[48,74,95,205,62,62,18,44,65,48,74,95]),append(this.bgPalettes,[15,15,15,45,45,45]),append(this.fgPalettes,[255,255,255,225,225,225,200,200,200,180,180,180]),append(this.bgPalettes,[65,45,25,85,65,45]),append(this.fgPalettes,[75,55,35,165,85,105,95,75,55,185,105,125]),append(this.bgPalettes,[254,55,19,253,29,0]),append(this.fgPalettes,[255,80,50,0,37,189,0,52,221,0,92,255]),append(this.bgPalettes,[0,75,28,0,48,16]),append(this.fgPalettes,[0,221,90,255,210,0,0,244,130,255,198,0])}createColors(t){let s=this.bgPalettes[t],e=this.fgPalettes[t];this.fgcs=[];for(let i=0;i<4;i++){let $=3*i,h=e[$+0],_,l=color(h,e[$+1],e[$+2]);append(this.fgcs,l)}this.bgcs=[];for(let r=0;r<2;r++){let a=3*r,g=s[a+0],p,x=color(g,s[a+1],s[a+2]);append(this.bgcs,x)}this.irics=[],append(this.irics,color(255,150,255)),append(this.irics,color(150,150,255)),append(this.irics,color(150,255,255)),append(this.irics,color(150,255,150)),append(this.irics,color(255,255,150))}getFg(t,s){let e,i;for(let $=0;$<3;$++)if(t<=($+1)*.3334){e=map(t,.3334*$,($+1)*.3334,0,1),i=lerpColor(this.fgcs[$],this.fgcs[$+1],e);break}return void 0!==s?color(red(i),green(i),blue(i),s):i}getBg(t,s){let e=lerpColor(this.bgcs[0],this.bgcs[1],t);return void 0!==s?color(red(e),green(e),blue(e),s):e}getIri(t,s){let e,i;for(let $=0;$<4;$++)if(t<=($+1)*.25){e=map(t,.25*$,($+1)*.25,0,1),i=lerpColor(this.irics[$],this.irics[$+1],e);break}return void 0!==s?color(red(i),green(i),blue(i),s):i}getRandom(){return color(R.random_num(25,255),R.random_num(25,255),R.random_num(25,255))}}