memoscan
← all memos

Memo 0xc6213fe4…2922ed on Ethereum

class ParticleSystem{constructor(){this.particles=[],this.forces=[],this.forcePairPs=[]}initForces(){let e=R.random_dec();e*=e;let r=int(lerp(8,35,e)),a=0,t=R.random_num(250,300);for(let e=0;e<r;e++){let r=R.random_dec(),o=R.random_num(50,t),i=R.random_num(0,6.283),s=cos(i)*o+MYHALF,p=sin(i)*o+.425*MYSIZE,n=createVector(s,p),d=0,m=0,c=!1;r<.1&&a<3&&0==SOURCE_ID?(d=15,m=0,c=!0,a++):r<.25?(d=R.random_num(-5,-1.5),m=0,0):r<.35?(d=R.random_num(.5,23),m=R.random_num(-8,8),0):(d=R.random_num(-.25,.25),m=R.random_num(1,55),R.random_bool(.5)&&(m=-m),0);let l=map(n.x,0,MYSIZE,-SCENESCALE,SCENESCALE),E=map(n.y,0,MYSIZE,-SCENESCALE,SCENESCALE),S=createVector(l,E),g=createVector(-l,E);this.addForce(e,S,d,m,c,!1),this.addForce(e+1,g,d,-m,c,!1)}if(0==a&&1!=SOURCE_ID)for(let e=0;e<1;e++){let e=R.random_num(0,.4*SCENESCALE),r=R.random_num(0,.2*SCENESCALE),a=createVector(e,r),t=createVector(-e,r),o=2,i=0,s=!0;this.addForce(0,a,o,i,s,!1),this.addForce(0,t,o,-i,s,!1)}if(1==SOURCE_ID){let e=0,r=R.random_num(0,.2*SCENESCALE),a=createVector(e,r),t=createVector(-e,r),o=2,i=0,s=!0;this.addForce(0,a,o,i,s,!1),this.addForce(0,t,o,-i,s,!1)}else if(2==SOURCE_ID)for(let e=0;e<2;e++){let e=R.random_num(.6*-SCENESCALE,.6*SCENESCALE),r=R.random_num(.4*-SCENESCALE,.6*SCENESCALE),a=createVector(e,r),t=(createVector(-e,r),2),o=0,i=!0;this.addForce(0,a,t,o,i,!1)}let o=R.random_num(.65,.75);2==SOURCE_ID&&(o=R.random_num(.9,1));for(let e=0;e<14;e++){let r=map(e,0,14,.5*PI+PI/28,1.5*PI+PI/28),a=R.random_num(.95,1.1),t=cos(r)*SCENESCALE*o*a,i=sin(r)*SCENESCALE*o*a,s=createVector(t,i),p=createVector(-t,i),n=R.random_num(14,18),d=0;this.addForce(e,s,n,d,!1,!0),this.addForce(e+1,p,n,-d,!1,!0)}this.setupForceLines()}setupForceLines(){for(let e=0;e<this.forces.length;e+=2){let r=this.forces[e],a=this.forces[e+1];if(!r.isBoundary){let e=r.pos,t=a.pos,o=map(e.x,-SCENESCALE,SCENESCALE,0,MYSIZE),i=map(e.y,-SCENESCALE,SCENESCALE,0,MYSIZE),s=map(t.x,-SCENESCALE,SCENESCALE,0,MYSIZE),p=map(t.y,-SCENESCALE,SCENESCALE,0,MYSIZE);e=createVector(o,i),t=createVector(s,p),append(this.forcePairPs,e),append(this.forcePairPs,t)}}}update(){let e=R.random_dec();for(let r=0;r<this.forces.length-1;r+=2){let a=this.forces[r+0],t=this.forces[r+1];if(frameMarkTrigger)if(a.isEmitter)a.isEmitter=!1,t.isEmitter=!1;else{let r=!1;a.force<-4&&!a.isBoundary&&(r=!0);let o=R.random_num(-6,6),i=R.random_num(-15,15);if(r&&(o=R.random_num(2,6)),a.updateForce(o,i,r),t.updateForce(o,-i,r),a.isBoundary){let r=map(e,0,1,.65,1.15);a.pos.x=a.origPos.x*r,a.pos.y=a.origPos.y*r,t.pos.x=t.origPos.x*r,t.pos.y=t.origPos.y*r}else if(R.random_bool(.7)){R.random_dec();let e=R.random_num(50,400),r=R.random_num(0,6.283),o=cos(r)*e+MYHALF,i=sin(r)*e+.425*MYSIZE,s=map(o,0,MYSIZE,-SCENESCALE,SCENESCALE),p=map(i,0,MYSIZE,-SCENESCALE,SCENESCALE);a.pos.x=s,a.pos.y=p,2==SOURCE_ID&&(s=map(o,0,MYSIZE,-SCENESCALE,SCENESCALE),p=map(i,0,MYSIZE,-SCENESCALE,SCENESCALE)),t.pos.x=-s,t.pos.y=p}}if(this.particles.length<4e3){if(a.isEmitter)for(let e=0;e<3;e++){let e=new Particle(a.pos);append(this.particles,e)}if(t.isEmitter)for(let e=0;e<3;e++){let e=new Particle(t.pos);append(this.particles,e)}}a.update(),t.update()}for(let e=0;e<this.particles.length;e++){let r=this.particles[e];r.update(this.forces),r.dead&&this.particles.splice(e,1)}}draw(e){e.stroke(color(255,255,255)),e.strokeWeight(.5),e.noFill();for(let r=0;r<this.forces.length;r++){this.forces[r].draw(e)}}drawToPaper(){for(let e=0;e<this.particles.length;e++){let r=this.particles[e],a=r.renderx,t=r.rendery,o=r.renderxo,i=r.renderyo,s=(r.radius,0),p=0;for(let e=0;e<this.forces.length;e++){let a=this.forces[e];if(a.isEmitter){let e=a.pos.x,t=a.pos.y,o=dist(e,t,r.x,r.y);s+=o=sqrt(o),p+=sin(10*o)}}let n=createVector(a-o,i-t);n.normalize();let d=p5.Vector.dot(n,createVector(0,1));if(d=map(d,-1,1,0,1),r.age>.01){let e=r.speedLerp*map(frameMarkPer,0,1,15,4);if(e+=3*cos(r.totalDist*SURFACE_VAR),e=max(e,1),e*=1-r.agePer,myFrameCount>=frameMark1&&myFrameCount<frameMark2?e*=.45:myFrameCount>=frameMark2&&(e*=.25),0==r.context){let s=lerpColor(cs[2],cs[1],map(r.totalDist,0,40,0,1,!0));drawDragLine(a,t,o,i,paperBg,cs[1],e*r.augRadius*3.5,r.age),drawDragLine(a,t,o,i,paperMg,s,e*r.augRadius*3,r.age),r.cd=s}else if(1==r.context){let s=sin(.02*pow(p+1,2)),n=cs[1],d=cs[2],m=lerpColor(d,n,s);r.cd=m,drawDragLine(a,t,o,i,paperMg,n,e*r.augRadius*2,r.age),drawDragLine(a,t,o,i,paperFg,m,e*r.augRadius*1.75,r.age)}else if(2==r.context){let s=map(r.age,0,30,1,0,!0),p=lerpColor(cs[2],cs[3],s);r.cd=p,drawDragLine(a,t,o,i,paperFg,p,e*r.augRadius*1.4,r.age)}else if(3==r.context){let s=max(d,0),p=getColor(.5*s+.5);p=lerpColor(p,cs[3],.6),r.cd=p,drawDragLine(a,t,o,i,paperFg,p,e*r.augRadius*1.4,r.age)}else if(4==r.context){let p=map(r.totalDist,0,50,.5,1),n=getColor(p),m=n,c=max(s,0,5,0,1);drawDragLine(a,t,o,i,paperFg,n,e*r.augRadius*1.5,r.age),1==OUTLOOK_ID&&(m=lerpColor(n,getIrriColor(fract(8*d)),(.6*d+.4)*c),drawDragLine(a,t,o,i,paperTg,m,e*r.augRadius*.5,r.age)),r.cd=m}else if(5==r.context){let e=pow(r.agePer,.25),s=cs[4],p=color(red(s),green(s),blue(s),80);r.cd=p,drawDragLine(a,t,o,i,paperTg,p,pow(1-r.agePer,4)*e,r.age)}}}}drawStaticToPaper(){paperBg.noStroke(),paperMg.noStroke(),paperFg.noStroke(),paperTg.noStroke();SCENESCALE;let e=paperMg;e.fill(csTrans[0]);for(let r=0;r<this.particles.length;r++){let a=this.particles[r],t=(a.speed+.5)*a.radius*.02;drawStatic(a.renderx,a.rendery,t,e,6)}(e=paperTg).fill(csTrans[1]);for(let r=0;r<this.particles.length;r++){let a=this.particles[r],t=(a.speed+.3)*a.radius*.1;drawStatic(a.renderx,a.rendery,t,e,4)}(e=paperFg).fill(csTrans[0]);for(let r=0;r<this.particles.length;r++){let a=this.particles[r],t=a.speed+.2,o=t*t*a.radius;drawStreakedStatic(a.renderx,a.rendery,o,e,6)}if(3==SOURCE_ID){let e=paperFg;e.fill(csTrans[2]);for(let r=0;r<this.particles.length;r++){let a=this.particles[r],t=a.speed+.1,o=t*t*a.radius*.15;drawStreakedStatic(a.renderx,a.rendery,o,e,3)}(e=paperTg).fill(csTrans[3]);for(let r=0;r<this.particles.length;r++){let a=this.particles[r],t=a.speed,o=t*t*a.radius*.01;drawStatic(a.renderx,a.rendery,o,e,3)}e=paperFg;for(let r=0;r<this.particles.length;r++)if(R.random_bool(.125)){let a=this.particles[r],t=a.cd,o=a.speed+.2;e.fill(color(red(t),green(t),blue(t),80));let i=o*a.radius*5;drawSplatter(a.renderx,a.rendery,i,e,3)}}(e=paperFg).fill(cs[1]);for(let r=0;r<this.particles.length;r++)if(R.random_bool(.025)){let a=this.particles[r];if(2==a.context||5==a.context){let r=a.speed+.2,t=r*r*a.radius;drawSplatter(a.renderx,a.rendery,t,e,6)}}}addParticle(e){let r=new Particle(e);append(this.particles,r)}addForce(e,r,a,t,o,i){let s=new Force(e,r,a,t,o,i);append(this.forces,s)}}function reset(e){print("edit 015"),print(tokenData.hash),print(tokenData.tokenId),windowWidth<windowHeight?dim=windowWidth:dim=windowHeight,STROKESCALE=275e-6*MYSIZE,print("dim = "+dim),dimHalf=.5*dim,buffer=createCanvas(dim,dim),pixelDensity(e),myFrameCount=0,R=new Random,setupFeatures(),createColors(PALETTE_ID),rectMode(CORNERS),img=createGraphics(MYSIZE,MYSIZE),img.rectMode(CORNERS),paperBg=createGraphics(MYSIZE,MYSIZE),paperMg=createGraphics(MYSIZE,MYSIZE),paperFg=createGraphics(MYSIZE,MYSIZE),paperTg=createGraphics(MYSIZE,MYSIZE),paperBg.imageMode(CORNERS),paperMg.imageMode(CORNERS),paperFg.imageMode(CORNERS),paperTg.imageMode(CORNERS),paperBg.rectMode(CORNERS),paperMg.rectMode(CORNERS),paperFg.rectMode(CORNERS),paperTg.rectMode(CORNERS);let r=cs[0];paperBg.background(color(red(r),green(r),blue(r),255)),paperMg.background(255,255,255,0),paperFg.background(255,255,255,0),paperTg.background(255,255,255,0),papers=[],append(papers,paperBg),append(papers,paperMg),append(papers,paperFg),append(papers,paperTg),GRAVITY=R.random_num(.03,.06),R.random_bool(.5)&&(GRAVITY=-GRAVITY),frameMark1=R.random_int(350,500),frameMark2=frameMark1+R.random_int(300,470),totalFrames=frameMark2+R.random_int(300,400),frameMarkPer=0,frameMarkTrigger=!1,print("frameMark1 = "+frameMark1),print("frameMark2 = "+frameMark2),print("totalFrames = "+totalFrames),blurryBg=new BlurryBg,0==BG_ID||1==BG_ID?blurryBg.drawMain(papers[1]):2==BG_ID?(blurryBg.drawMain(papers[1]),blurryBg.drawAnarchic(papers[1],1)):3==BG_ID?(blurryBg.drawMain(papers[1]),blurryBg.drawConcentric(papers[2])):4==BG_ID&&(blurryBg.drawMain(papers[1]),blurryBg.drawSpiritual(papers[1])),rorschach=new Rorschach,rorschachTop=new Rorschach,pSystem=new ParticleSystem,pSystem.initForces()}function setup(){reset(2)}function setupFeatures(){let e=R.random_dec(),r=int(map(pow(e,1.5),0,1,0,15));PALETTE_ID=min(r,14),R.random_dec()<.15&&(PALETTE_ID=13);let a=R.random_dec();BG_ID=a<.1?0:a<.3?1:a<.85?2:a<.95?3:4;let t=R.random_dec();SOURCE_ID=t<.8?0:t<.95?1:t<.98?2:3,BASIS_ID=0,R.random_bool(.4)&&(BASIS_ID=1),BASIS_OCTAVES=2*R.random_int(4,8),OUTLOOK_ID=0,R.random_bool(.3)&&(OUTLOOK_ID=1),SURFACE_VAR=R.random_num(.3,.8),print("palette = "+PALETTES[PALETTE_ID]),print("obstruction = "+BG_TYPES[BG_ID]),print("source = "+SOURCE_TYPES[SOURCE_ID]),print("basis = "+BASIS_TYPES[BASIS_ID]),print("octaves = "+BASIS_OCTAVES),print("outlook = "+OUTLOOK_TYPES[OUTLOOK_ID]),print("surface var = "+SURFACE_VAR)}function draw(){img.clear(),myFrameCount<=frameMark1?frameMarkPer=map(myFrameCount,0,frameMark1,0,1):myFrameCount<=frameMark2?frameMarkPer=map(myFrameCount,frameMark1,frameMark2,0,1):frameMarkPer=map(myFrameCount,frameMark2,totalFrames,0,1,!0),myFrameCount==frameMark1||myFrameCount==frameMark2?frameMarkTrigger=!0:frameMarkTrigger=!1,2==BG_ID&&myFrameCount==frameMark1&&blurryBg.drawAnarchic(papers[2],.35),myFrameCount<12&&1==BG_ID&&(rorschach.drawDarks(paperMg,1),rorschach.drawLights(paperFg,1),rorschachTop.drawDarks(paperMg,1.25),rorschachTop.drawLights(paperFg,1.25)),myFrameCount<totalFrames&&(pSystem.update(),pSystem.drawToPaper(),pSystem.drawStaticToPaper(),3==SOURCE_ID&&(myFrameCount==frameMark1?drawForceLines(pSystem.forcePairPs,cs[2]):myFrameCount==frameMark2&&drawForceLines(pSystem.forcePairPs,cs[4]))),push(),translate(dimHalf,dimHalf),FLIP_VERT&&(rotate(PI),scale(-1,1,1));for(let e=0;e<4;e++)image(papers[e],-dimHalf,-dimHalf,dim,dim);if(SHOW_FORCES&&(pSystem.draw(img),image(img,-dimHalf,-dimHalf,dim,dim)),pop(),DEBUG){let e=map(myFrameCount,0,totalFrames,0,.5*dim);noStroke(),fill(cs[0]),rect(dimHalf-e-1,0,dimHalf+e+1,3),fill(cs[3]),rect(dimHalf-e,1,dimHalf+e,2)}myFrameCount==totalFrames-1&&(DEBUG=!1),SAVE_PRINTRES&&myFrameCount==totalFrames&&(save(tokenData.hash+".png"),SAVE_PRINTRES=!1),myFrameCount++}