0x122cdf09…f8b5sent to0xc74ec888…009f·#18,685,461·view on Etherscan
let DEBUG=!1,SAVEFRAMES=!1,myWidth=900,myHeight=1600,halfWidth=myWidth/2,halfHeight=myHeight/2,imgScale=2,imgWidth=myWidth/imgScale,imgHeight=myHeight/imgScale,drawWidth,drawHeight,currentHash="",buffer,numCanvases=6,canvases=[],img,gfx,palettes,numPalettes,palette_id,fgPalettes=[],bgPalettes=[],fgcs=[],bgcs=[],iris=[],PALETTE,poisson,fabric,sakuraPs=[],embSakuraPs=[],mumPs=[],shx=1,shy=.5,roads=[],spawns=[],flowers=[],currentFrame=0,maxFrameCount=3e3,MAX_GEN=15,nOffsetX,nOffsetY,MAIN_RAND,IS_ANGLE_LOCKED,ANGLE_LOCK_GEN,BACKGROUND_ID,BACKGROUND_SPACING,SPAWN_ID,ZONE_ID,PRIMARY_CURVATURE,SECONDARY_CURVATURE,IS_TRADITIONAL,BG_DETAIL,numStripes,renderGridRes=1,prefillDotRadius,prefillGridXCount,prefillGridYCount,prefillRad0,prefillRad1,prefillRad2;class Random{constructor(){this.useA=!1;let t=function(t){let e=parseInt(t.substr(0,8),16),i=parseInt(t.substr(8,8),16),$=parseInt(t.substr(16,8),16),s=parseInt(t.substr(24,8),16);return function(){$|=0;let t=((e|=0)+(i|=0)|0)+(s|=0)|0;return s=s+1|0,e=i^i>>>9,i=$+($<<3)|0,$=($=$<<21|$>>>11)+t|0,(t>>>0)/4294967296}};this.prngA=new t(tokenData.hash.substr(2,32)),this.prngB=new t(tokenData.hash.substr(34,32));for(let e=0;e<1e6;e+=2)this.prngA(),this.prngB()}random_dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}random_num(t,e){return t+(e-t)*this.random_dec()}random_int(t,e){return Math.floor(this.random_num(t,e+1))}random_bool(t){return this.random_dec()<t}random_choice(t){return t[this.random_int(0,t.length-1)]}}function readColor(t,e){let i=4*(e*imgWidth+t);if(i>=img.pixels.length-3)return print("index out of range"),color(255,0,0,255);{let $=img.pixels[i+0],s;return color($,img.pixels[i+1],img.pixels[i+2],255)}}function writeColor(t,e,i,$,s){let r=4*(e*imgWidth+t);img.pixels[r+0]=i,img.pixels[r+1]=$,img.pixels[r+2]=s,img.pixels[r+3]=255}function writeCircle(t,e,i,$){gfx.clear(),gfx.fill($),gfx.ellipse(gfx.width/2,gfx.height/2,100,100),img.copy(gfx,0,0,gfx.width,gfx.height,t-i,e-i,2*i,2*i)}function writeRect(t,e,i,$,s){gfx.clear(),gfx.fill(s),gfx.rect(0,0,100,100),img.copy(gfx,0,0,gfx.width,gfx.height,t,e,i,$)}function getNoise(t,e,i){let $;return map(noise(t*i+nOffsetX,e*i+nOffsetY),.1,.9,0,1,!0)}function createGridSpawn(t,e,i,$,s){for(let r=0;r<t;r++)for(let h=0;h<e;h++){let a=map(r,-.5,t-.5,0,1),l=map(h,-.5,e-.5,0,1),n;addRoad(a*myWidth+i,l*myHeight+a*myHeight*.5+$,s,0,0)}}function createCircleSpawn(t,e,i,$,s){for(let r=0;r<$;r++){let h=map(r,0,$,0,TWO_PI),a=cos(h)*i,l=sin(h)*i;addRoad(t+a,e+l,h+s,0,0)}}function createWavySpawn(t,e,i){for(let $=0;$<t;$++){let s=$*myHeight*.05,r=.45*$;for(let h=0;h<e;h++){let a=map(h,0,e,0,1),l=myWidth*a,n=i+80*sin(a*PI*2+r+.05*i)+s+a*myHeight*.5;addRoad(l,n,HALF_PI,0,0)}}}function addRoad(t,e,i,$){let s=new Road(t,e,i,$);roads.push(s)}function addSpawn(t,e,i,$){let s=new Spawn(t,e,i,$);spawns.push(s)}function drawEmbroideredRing(t,e,i,$,s,r){for(let h=i-$;h<i+$;h+=r){let a=e-sqrt(sq($)-sq(h-i)),l=e+sqrt(sq($)-sq(h-i));if(a>=e-$&&l<=e+$){let n=e-sqrt(sq(s)-sq(h-i)),d=e+sqrt(sq(s)-sq(h-i));h>i-s&&h<i+s?(t.line(a,h,n,h),t.line(d,h,l,h)):t.line(a,h,l,h)}}}function drawDottedLine(t,e,i,$,s,r,h){let a=dist(e,i,$,s),l=(a-h*r)/r;for(let n=0;n<r;n++){let d=.5*h+n*(l+h),o=lerp(e,$,d/a),g=lerp(i,s,d/a),m=lerp(e,$,(l+d)/a),f=lerp(i,s,(l+d)/a);t.line(o,g,m,f)}}function drawDottedHex(t,e,i,$,s){for(let r=0;r<6;r++){let h=r,a=(r+1)%6,l=e[h].x*s,n=e[h].y*s,d;drawDottedLine(t,i+l,$+n,i+e[a].x*s,$+e[a].y*s,2,3)}}function drawDottedArc(t,e,i,$,s,r,h){let a=floor((s-$)*r/h),l=(s-$)/a;for(let n=0;n<=a;n++){let d=$+n*l,o=e+r*cos(d),g=i+r*sin(d);t.point(o,g)}}function drawStitchedCircle(t,e,i,$,s,r,h,a){let l=h+a,n=TWO_PI*r,d=n/l;t.stroke($),t.strokeWeight(s);for(let o=0;o<d;o++){let g=o*l/n*TWO_PI,m=g+h/n*TWO_PI,f=e+r*cos(g),c=i+r*sin(g),u=e+r*cos(m),p=i+r*sin(m);t.line(f,c,u,p)}}function drawStitchedLine(t,e,i,$,s,r,h,a,l){let n=dist(e,i,$,s),d=a+l,o=n/d;t.stroke(r),t.strokeWeight(h);for(let g=0;g<o;g++){let m=g*d/n,f=(g*d+a)/n;f=min(f,1);let c=lerp(e,$,m),u=lerp(i,s,m),p=lerp(e,$,f),y=lerp(i,s,f);t.line(c,u,p,y)}}function drawStitch(t,e,i,$,s,r,h,a,l,n,d){t.strokeWeight(a),t.stroke(palettes.getBg(0)),t.line($+shx,s+shy,r+shx,h+shy),e.strokeWeight(.25*a),e.stroke(d),e.line($,s,r,h);let o=.5*sin(2*n)+.5;i.strokeWeight(l),i.stroke(palettes.getIri(o,255*o)),i.line($-shx,s-shy,r-shx,h-shy)}function storeSakuraPs(){sakuraPs.push({x:0,y:.05}),sakuraPs.push({x:-.3,y:.5}),sakuraPs.push({x:-.3,y:.75}),sakuraPs.push({x:-.1,y:1}),sakuraPs.push({x:0,y:.9}),sakuraPs.push({x:.1,y:1}),sakuraPs.push({x:.3,y:.75}),sakuraPs.push({x:.3,y:.5}),sakuraPs.push({x:0,y:.05})}function storeEmbSakuraPs(){TWO_PI;let t=75;for(let e=0;e<t;e++){let i=map(e%15,0,15,0,1),$=pow(sin(i*PI),25),s=map(e,0,t,0,TWO_PI),r=map(e,0,t,0,5*PI),h=cos(s),a=sin(s),l=pow(abs(sin(r)),.25),n=h*(l-=.125*$),d=a*l;embSakuraPs.push({x:n,y:d,theta:s})}}function storeMumPs(){TWO_PI;for(let t=0;t<16;t++){let e=map(t,0,16,0,TWO_PI),i=cos(e),$=sin(e);mumPs.push({x:i,y:$})}}function sign(t){return t>0?1:t<0?-1:0}function roundAngle(t,e,i){let $=TWO_PI/e;return round(t/$)*$+i}function preload(){for(let t=0;t<numCanvases;t++){let e=createGraphics(myWidth,myHeight);e.noStroke(),append(canvases,e)}windowResized()}function prefillImg(t){(img=createImage(imgWidth,imgHeight)).loadPixels();for(let e=0;e<imgWidth;e++)for(let i=0;i<imgHeight;i++)img.set(e,i,color(0,0,0));if(img.updatePixels(),1==t){prefillDotRadius=R.random_num(10,30),prefillGridXCount=R.random_int(2,4),prefillGridYCount=R.random_int(2,6);let $=prefillDotRadius,s=2*$,r=prefillGridXCount,h=prefillGridYCount,a=color(15,15,15);for(let l=0;l<r;l++)for(let n=0;n<h;n++){let d=map(l,-.5,r-.5,0,1),o=map(n,-.5,h-.5,0,1),g=d*imgWidth,m=o*imgHeight+d*imgHeight*.5;writeCircle(g,m,s,a),g>imgWidth-$?writeCircle(g-=imgWidth,m,s,a):g<$&&writeCircle(g+=imgWidth,m,s,a),m>imgHeight-$?writeCircle(g,m-=imgHeight,s,a):m<$&&writeCircle(g,m+=imgHeight,s,a)}}else if(2==t){prefillRad0=R.random_num(100,250),prefillRad1=R.random_num(50,150),prefillRad2=R.random_num(20,70);let f=.5*imgWidth,c=.5*imgHeight,u=color(15,0,0);writeCircle(f,c,prefillRad0,u),writeCircle(f,c,prefillRad1,u=color(0,15,0)),writeCircle(f,c,prefillRad2,u=color(0,0,15))}else if(3==t){numStripes=R.random_int(2,4);let p=color(10,10,10),y=imgWidth/(2*numStripes),_=imgHeight;for(let w=0;w<numStripes;w++){let S=map(w,.5,numStripes-.5,0,1);writeRect(imgWidth*S,0,y,_,p)}}else if(4==t){let x=color(10,10,10);numStripes=R.random_int(2,7);for(let C=0;C<numStripes;C++){let W=map(C,.5,numStripes-.5,0,1);writeRect(0,imgHeight*W,imgWidth,imgHeight/(2*numStripes),x)}}}function windowResized(){dim=windowWidth<windowHeight?windowWidth:windowHeight,resizeCanvas(windowWidth,windowHeight);let t=myWidth/myHeight;width/height<t?(drawWidth=width,drawHeight=width/t):(drawHeight=height,drawWidth=height*t)}function keyTyped(){"s"==key?saveImage():"d"==key?DEBUG=!DEBUG:"r"==key?RESET=!0:"1"==key?renderGridRes=1:"2"==key?renderGridRes=2:"3"==key?renderGridRes=4:"4"==key&&(renderGridRes=8)}function saveImage(){let t=createGraphics(myWidth,myHeight);t.image(canvases[0],0,0);let e=2;for(let i=0;i<e;i++){let $=map(i,0,e,0,1),s=myWidth/e;for(let r=0;r<=e;r++){let h=myWidth*$,a=map(r,0,e,0,1),l=myHeight/e,n=myHeight*a;i%2==1&&(n-=l/2),t.image(canvases[1],h,n,s,l),t.image(canvases[2],h,n,s,l)}}e=renderGridRes;for(let d=0;d<e;d++){let o=map(d,0,e,0,1),g=myWidth/e;for(let m=0;m<=e;m++){let f=myWidth*o,c=map(m,0,e,0,1),u=myHeight/e,p=myHeight*c;d%2==1&&(p-=u/2);for(let y=1;y<numCanvases;y++)t.image(canvases[y],f,p,g,u)}}save(t,currentHash,"png")}function setupFeatures(){palettes=new Palettes,MAX_GEN=8,MAIN_RAND=R.random_dec(),IS_ANGLE_LOCKED=R.random_bool(.2),ANGLE_LOCK_GEN=R.random_int(0,1),BACKGROUND_ID=R.random_int(0,4),BACKGROUND_SPACING=20,SPAWN_ID=R.random_int(0,6),ZONE_ID=R.random_int(0,4),IS_TRADITIONAL=R.random_bool(.9),BG_DETAIL=R.random_bool(.2),PRIMARY_CURVATURE=R.random_num(1,2),SECONDARY_CURVATURE=R.random_num(.5,2),print("Palette = "+palettes.id),print("Spawn Id = "+SPAWN_ID),print("Background Id = "+BACKGROUND_ID),print("Zone Id = "+ZONE_ID),print("Is Angle Locked = "+IS_ANGLE_LOCKED),print("Angle Lock Gen = "+ANGLE_LOCK_GEN)}function reset(){for(let t of(print("Growth v3"),print(tokenData.hash),print("------------------------------------------------------------------------------"),R=new Random,noiseDetail(5,.5),noiseSeed(R.random_dec()),nOffsetX=R.random_num(150,1300),nOffsetY=R.random_num(150,1300),randomSeed(R.random_dec()),pixelDensity(2),smooth(),saveFrame=!1,currentFrame=0,setupFeatures(),buffer=createCanvas(windowWidth,windowHeight),img=createImage(imgWidth,imgHeight),(gfx=createGraphics(100,100)).noStroke(),prefillImg(ZONE_ID),canvases))t.clear(),t.strokeCap(ROUND),t.background(0,0,0,0);roads=[],spawns=[],flowers=[],storeSakuraPs(),storeEmbSakuraPs(),storeMumPs(),(poisson=new FastPoisson).solve(BACKGROUND_ID),(fabric=new Fabric(BACKGROUND_SPACING,BACKGROUND_ID)).drawFabric(canvases[0]),initialSpawn(),stitchZones(ZONE_ID)}function setup(){windowResized(),reset()}function initialSpawn(){if(0==SPAWN_ID)createWavySpawn(2,75,.25*myHeight),createWavySpawn(2,75,.75*myHeight);else if(1==SPAWN_ID)createGridSpawn(3,4,0,0,0),createGridSpawn(3,4,30,-10,PI);else if(2==SPAWN_ID)createCircleSpawn(halfWidth,halfHeight,.55*myWidth,70,HALF_PI),createCircleSpawn(halfWidth,halfHeight,.35*myWidth,50,PI),createCircleSpawn(halfWidth,halfHeight,.2*myWidth,30,-HALF_PI);else if(3==SPAWN_ID)createCircleSpawn(halfWidth,halfHeight,.55*myHeight,70,HALF_PI),createCircleSpawn(halfWidth,halfHeight,.35*myHeight,50,PI),createCircleSpawn(halfWidth,halfHeight,.2*myHeight,30,-HALF_PI);else if(4==SPAWN_ID)for(let t=0;t<3;t++)for(let e=0;e<4;e++){let i=map(t,-.5,2.5,0,1),$=map(e,-.5,3.5,0,1),s;createCircleSpawn(i*myWidth,$*myHeight+i*myHeight*.5,20,12,0)}else 5==SPAWN_ID?createGridSpawn(3,5,0,0,0):6==SPAWN_ID&&(createCircleSpawn(halfWidth,halfHeight,.35*myHeight,150,PI),createCircleSpawn(halfWidth,halfHeight,.15*myHeight,75,0))}function stitchZones(t){let e=canvases[numCanvases-1],i=palettes.getBg(0),$=palettes.getFg(0);if(1==t){let s=2*prefillDotRadius,r=2*s,h=prefillGridXCount,a=prefillGridYCount;for(let l=0;l<h;l++)for(let n=0;n<a;n++){let d=map(l,-.5,h-.5,0,1),o=map(n,-.5,a-.5,0,1),g=d*myWidth,m=o*myHeight+d*myHeight*.5;drawStitchedCircle(e,g,m,i,8,r,8,4),drawStitchedCircle(e,g,m,$,1.5,r,8,4),g>myWidth-s?(drawStitchedCircle(e,g-=myWidth,m,i,8,r,8,4),drawStitchedCircle(e,g,m,$,1.5,r,8,4)):g<s&&(drawStitchedCircle(e,g+=myWidth,m,i,8,r,8,4),drawStitchedCircle(e,g,m,$,1.5,r,8,4)),m>myHeight-s?(drawStitchedCircle(e,g,m-=myHeight,i,8,r,8,4),drawStitchedCircle(e,g,m,$,1.5,r,8,4)):m<s&&(drawStitchedCircle(e,g,m+=myHeight,i,8,r,8,4),drawStitchedCircle(e,g,m,$,1.5,r,8,4))}}else if(2==t){let f=.5*myWidth,c=.5*myHeight;drawStitchedCircle(e,f,c,i,8,2*prefillRad0,8,4),drawStitchedCircle(e,f,c,$,1.5,2*prefillRad0,8,4),drawStitchedCircle(e,f,c,i,8,2*prefillRad1,8,4),drawStitchedCircle(e,f,c,$,1.5,2*prefillRad1,8,4),drawStitchedCircle(e,f,c,i,8,2*prefillRad2,8,4),drawStitchedCircle(e,f,c,$,1.5,2*prefillRad2,8,4)}else if(3==t){let u=myHeight;for(let p=0;p<numStripes;p++){let y=map(p,.5,numStripes-.5,0,1),_=myWidth*y;drawStitchedLine(e,_,0,_,u,i,8,8,4),drawStitchedLine(e,_,0,_,u,$,1.5,8,4),drawStitchedLine(e,_+=myWidth/(2*numStripes),0,_,u,i,8,8,4),drawStitchedLine(e,_,0,_,u,$,1.5,8,4)}}else if(4==t){let w=myWidth;for(let S=0;S<numStripes;S++){let x=map(S,.5,numStripes-.5,0,1),C=myHeight*x;drawStitchedLine(e,0,C,w,C,i,8,8,4),drawStitchedLine(e,0,C,w,C,$,1.5,8,4),drawStitchedLine(e,0,C+=myHeight/(2*numStripes),w,C,i,8,8,4),drawStitchedLine(e,0,C,w,C,$,1.5,8,4)}}}function update(){if(currentFrame>0){for(let t of(img.loadPixels(),roads))t.update();for(let e of spawns)e.update();for(let i of roads)i.render();img.updatePixels()}}function draw(){if(currentFrame<maxFrameCount){if(update(),currentFrame>0)for(let t of roads)t.drawRoad();cleanUp()}if(image(canvases[0],0,0,drawWidth,drawHeight),BG_DETAIL)for(let e=0;e<3;e++){let i=map(e,0,3,0,1),$=drawWidth/3;for(let s=0;s<=3;s++){let r=drawWidth*i,h=map(s,0,3,0,1),a=drawHeight/3,l=drawHeight*h;e%2==1&&(l-=a/2),image(canvases[1],r,l,$,a)}}gr=renderGridRes;for(let n=0;n<gr;n++){let d=map(n,0,gr,0,1),o=drawWidth/gr;for(let g=0;g<=gr;g++){let m=drawWidth*d,f=map(g,0,gr,0,1),c=drawHeight/gr,u=drawHeight*f;n%2==1&&(u-=c/2);for(let p=2;p<numCanvases;p++)image(canvases[p],m,u,o,c)}}currentFrame++,DEBUG&&image(img,0,0,drawWidth,drawHeight)}function cleanUp(){for(let t=0;t<roads.length;t++)roads[t].isDead()&&roads.splice(t,1);for(let e=0;e<spawns.length;e++)spawns[e].isDead()&&spawns.splice(e,1)}function drawCherryBlossom(t,e,i,$,s,r,h){0==h?plainCherryBlossom(t,e,i,$,s,r):1==h?embroideredCherryBlossom(t,e,i,$,s,r):2==h&&embroideredCherryBlossomOutline(t,e,i,$,s,r)}function plainCherryBlossom(t,e,i,$,s,r){let h=TWO_PI/5;t.fill(s),t.stroke(palettes.getBg(0)),t.strokeWeight(.5),t.push(),t.translate(e,i),t.rotate(r);for(let a=0;a<5;a++){for(let l of(t.rotate(h),t.beginShape(),sakuraPs)){let n=l.x*$,d=l.y*$;t.curveVertex(n,d)}t.endShape(CLOSE)}t.pop()}function embroideredCherryBlossom(t,e,i,$,s,r){for(let h of(TWO_PI,t.push(),t.translate(e,i),t.rotate(r),t.strokeWeight(6),t.stroke(palettes.getBg(0)),embSakuraPs)){let a=h.x*$*.2,l=h.y*$*.2,n=h.x*$,d=h.y*$;t.line(a,l,n,d)}for(let o of(t.strokeWeight(1.5),t.stroke(color(0,20)),embSakuraPs)){let g=o.x*$*.2,m=o.y*$*.2,f=o.x*$,c=o.y*$;t.line(g+shx,m+shy,f+shx,c+shy)}for(let u of(t.strokeWeight(1),t.stroke(s),embSakuraPs)){let p=u.x*$*.2,y=u.y*$*.2,_=u.x*$,w=u.y*$;t.line(p,y,_,w)}for(let S of(t.strokeWeight(.3),embSakuraPs)){let x=S.x*$*.2,C=S.y*$*.2,W=S.x*$,H=S.y*$,A=.5*sin(2*S.theta)+.5;t.stroke(palettes.getIri(A,100*A)),t.line(x-shx,C-shy,W-shx,H-shy)}t.fill(palettes.getBg(1)),t.strokeWeight(1),t.stroke(palettes.getFg(0));for(let k=0;k<15;k++){let P=map(k,0,15,0,1),I=P*TWO_PI,D=$*R.random_num(.35,.4),v=cos(I),N=sin(I),G=v*$*.1,E=N*$*.1,B=v*D,L=N*D;t.fill(palettes.getIri(P,50)),t.line(G,E,B,L),t.circle(B,L,.075*$)}t.pop()}function embroideredCherryBlossomOutline(t,e,i,$,s,r){for(let h of(TWO_PI,t.push(),t.translate(e,i),t.rotate(r),t.fill(palettes.getBg(.5)),t.strokeWeight(.035*$),t.stroke(palettes.getFg(1)),t.beginShape(),embSakuraPs)){h.x,h.y;let a=h.x*$,l=h.y*$;t.vertex(a,l)}t.endShape(CLOSE);for(let n=0;n<15;n++){let d=map(n,0,15,0,1),o=d*TWO_PI,g=$*R.random_num(.35,.4),m=cos(o),f=sin(o),c=m*$*.1,u=f*$*.1,p=m*g,y=f*g;t.fill(palettes.getIri(d,250)),t.line(c,u,p,y),t.circle(p,y,.075*$)}t.pop()}function drawMum(t,e,i,$,s,r){plainMum(t,e,i,$,s,r)}function plainMum(t,e,i,$,s,r){t.fill(s),t.stroke(palettes.getBg(R.random_dec())),t.strokeWeight(.025*$);let h=mumPs.length;for(let a=0;a<h;a++){let l=a,n=(a+1)%h,d=mumPs[l].x,o=mumPs[l].y,g=mumPs[n].x,m=mumPs[n].y;t.beginShape(),t.curveVertex(e,i);for(let f=0;f<5;f++){let c=map(f,0,4,0,1),u=lerp(.8*$,$,sqrt(sin(c*PI))),p=e+lerp(d,g,c)*u,y=i+lerp(o,m,c)*u;t.curveVertex(p,y)}t.curveVertex(e,i),t.endShape(CLOSE)}t.fill(palettes.getBg(R.random_dec())),t.circle(e,i,.45*$)}class Spawn{constructor(t,e,i,$){this.x=t,this.y=e,this.theta=i,this.gen=$,this.age=0,this.life=250,this.dead=!1}update(){this.age++,this.age>this.life&&(addRoad(this.x,this.y,this.theta,this.gen),this.dead=!0)}isDead(){return this.dead}}class Road{constructor(t,e,i,$){this.x=t,this.y=e,this.theta=i,this.gen=$,this.genPer=map(this.gen,0,6,0,1),this.cd=palettes.getFg(fract(this.genPer+R.random_num(0,.05))),this.genPer=map(this.gen,0,3,0,1,!0),this.myRand=R.random_dec(),this.trajThresh=1.3,this.sw=1,this.sw2=3,this.swPer=0,this.ink=palettes.getRandom();let s=constrain(this.x,0,myWidth-1),r=constrain(this.y,0,myHeight-1),h=int(s/imgScale),a=int(r/imgScale);this.bg=readColor(h,a),this.speed=.5,this.xv=cos(this.theta)*this.speed,this.yv=sin(this.theta)*this.speed,this.px=t-this.xv,this.py=e-this.yv,this.age=0,this.life=1e3,this.agePer=this.age/this.life,this.dead=!1;let l=getNoise(this.x,this.y,.005),n=getNoise(this.y,this.x,.005);this.delta=map(l,0,1,-.015,.0075,!0),this.delta2=map(n,0,1,-.001,.001,!0),0==this.gen&&(this.delta=map(MAIN_RAND,0,1,-.01,-.04),this.delta2=15e-5),this.spawnIter=3,this.fillThresh=25,this.stitch=0,this.stitchInterval=7,this.stitchLength=.35*this.stitchInterval,this.stitchCount=0,this.isFlowering=!1}update(){this.dead||(this.updatePosition(),this.checkOverlap(),this.updateTrajectory(),this.updateAge(),this.createSpawn(),this.wrapBorder())}updatePosition(){let t=360;this.gen>=ANGLE_LOCK_GEN&&IS_ANGLE_LOCKED&&(t=6);let e=this.theta;e=roundAngle(this.theta,t,HALF_PI),this.xv=cos(e)*this.speed,this.yv=sin(e)*this.speed,this.px=this.x,this.py=this.y,this.x+=this.xv,this.y+=this.yv}checkOverlap(){let t=constrain(this.x+4*this.xv,0,myWidth-1),e=constrain(this.y+4*this.yv,0,myHeight-1),i=int(t/imgScale),$=int(e/imgScale),s=readColor(i,$),r=brightness(s);0==this.age&&(this.bg=s),r>20?s.toString()!=this.ink.toString()&&(this.dead=!0):this.age>0&&s.toString()!=this.bg.toString()&&(this.dead=!0)}updateTrajectory(){(this.myRand<this.trajThresh||IS_TRADITIONAL)&&(this.theta+=this.delta*PRIMARY_CURVATURE,this.delta+=this.delta2*SECONDARY_CURVATURE),abs(this.delta)>.066&&(this.dead=!0)}updateAge(){this.age++,this.agePer=this.age/this.life,this.age>=this.life&&(this.dead=!0)}createSpawn(){!this.dead&&this.age%this.spawnIter==0&&this.age>this.fillThresh&&this.gen<MAX_GEN&&(currentFrame%2==0?addSpawn(this.x,this.y,this.theta-HALF_PI,this.gen+1):addSpawn(this.x,this.y,this.theta+HALF_PI,this.gen+1))}render(){if(this.age>10){let t=int(this.x/imgScale),e=int(this.y/imgScale),i=red(this.ink),$;writeColor(t,e,i,green(this.ink),blue(this.ink))}}drawRoad(t){this.swPer=map(this.age,10,45,0,1,!0),this.sw=15*pow(map(abs(this.delta),0,.0666,1,0),2)+2+11*pow(1-this.genPer,2),this.sw*=this.swPer,this.sw2=min(this.sw+1,1.2*this.sw),this.stitchLength=.1*this.sw,this.isFlowering&&this.age%49==48&¤tFrame>300&&this.createFlower(),this.age%this.stitchInterval==0&&this.age>10&&(this.drawRunningStitch(),this.stitchCount++)}createFlower(){let t=this.x,e=this.y,i=R.random_num(17,35),$=2*i,s=R.random_int(0,2);this.age%2==0?(t+=this.yv*$,e+=-this.xv*$):(t+=-this.yv*$,e+=this.xv*$);let r=palettes.getFg(this.agePer),h=R.random_num(0,TWO_PI),a=canvases[2];if(drawCherryBlossom(a,t,e,i,r,h,s),t<50?(e<halfHeight?e+=halfHeight:e-=halfHeight,drawCherryBlossom(a,t+myWidth,e,i,r,h,s)):t>myWidth-50&&(e<halfHeight?e+=halfHeight:e-=halfHeight,drawCherryBlossom(a,t-myWidth,e,i,r,h,s)),e<50?drawCherryBlossom(a,t,e+myHeight,i,r,h,s):e>myHeight-50&&drawCherryBlossom(a,t,e-myHeight,i,r,h,s),this.age>10){let l=int(this.x/imgScale),n=int(this.y/imgScale),d=red(this.ink),o;writeColor(l,n,d,green(this.ink),blue(this.ink))}}drawRunningStitch(){let t=5;this.gen>=1&&this.gen<=2?t=4:this.gen>=3&&(t=3),canvases[0];let e=canvases[1],i=canvases[3],$=canvases[4],s=canvases[5],r=this.stitchLength,h=this.x-this.xv*r,a=this.x+this.xv*r,l=this.y-this.yv*r,n=this.y+this.yv*r;e.fill(palettes.getIri(.5,30)),e.circle(this.x,this.y,3),i.strokeWeight(this.sw2),i.stroke(palettes.getBg(0)),i.line(h,l,a,n),$.strokeWeight(.25*this.sw),$.stroke(this.cd),$.line(h,l,a,n);let d=.5*sin(2*this.theta)+.5;s.strokeWeight(1*this.swPer),s.stroke(palettes.getIri(d,255*d)),s.line(h-shx,l-shy,a-shx,n-shy)}wrapBorder(){this.x<0&&(this.x+=myWidth,this.px+=myWidth,this.y<halfHeight?(this.y+=halfHeight,this.py+=halfHeight):(this.y-=halfHeight,this.py-=halfHeight)),this.x>myWidth&&(this.x-=myWidth,this.px-=myWidth,this.y<halfHeight?(this.y+=halfHeight,this.py+=halfHeight):(this.y-=halfHeight,this.py-=halfHeight)),this.y<0&&(this.y+=myHeight,this.py+=myHeight),this.y>myHeight&&(this.y-=myHeight,this.py-=myHeight)}isDead(){return this.dead}}