class Random{constructor(){this.useA=!1;let e=function(e){let o=parseInt(e.substring(0,8),16),t=parseInt(e.substring(8,16),16),g=parseInt(e.substring(16,24),16),n=parseInt(e.substring(24,32),16);return function(){g|=0;let e=((o|=0)+(t|=0)|0)+(n|=0)|0;return n=n+1|0,o=t^t>>>9,t=g+(g<<3)|0,g=(g=g<<21|g>>>11)+e|0,(e>>>0)/4294967296}};this.prngA=new e(tokenData.hash.substring(2,34)),this.prngB=new e(tokenData.hash.substring(34,66));for(let o=0;o<1e6;o+=2)this.prngA(),this.prngB()}random_dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}random_num(e,o){return e+(o-e)*this.random_dec()}random_int(e,o){return Math.floor(this.random_num(e,o+1))}random_bool(e){return this.random_dec()<e}random_choice(e){return e[this.random_int(0,e.length-1)]}}let R=new Random,canvasWidth=1800,canvasHeight=2700,borderOffset=72,palette1=[hexToRgb("#505050"),hexToRgb("#363636"),hexToRgb("#292929"),hexToRgb("#0A0A0A"),hexToRgb("#282828"),hexToRgb("#9DA2AB"),hexToRgb("#E7E5DF"),hexToRgb("#DDE2C6")],palette2=[[hexToRgb("#D0DB97"),hexToRgb("#69B578"),hexToRgb("#3A7D44"),hexToRgb("#181D27"),hexToRgb("#254D32")],[hexToRgb("#D65A31"),hexToRgb("#393E46"),hexToRgb("#E2C2C6"),hexToRgb("#222831"),hexToRgb("#AFA98D")],[hexToRgb("#A3B4A2"),hexToRgb("#EEF7FB"),hexToRgb("#CDC6AE"),hexToRgb("#152728"),hexToRgb("#99CEEB")],[hexToRgb("#F4F4F4"),hexToRgb("#F0A500"),hexToRgb("#CF7500"),hexToRgb("#1A1C20"),hexToRgb("#666666")],[hexToRgb("#856084"),hexToRgb("#d8cbc7"),hexToRgb("#f55d3e"),hexToRgb("#161925"),hexToRgb("#077187")],[hexToRgb("#d8e2dc"),hexToRgb("#ffffff"),hexToRgb("#546A7B"),hexToRgb("#050B10"),hexToRgb("#F57266")],[hexToRgb("#F46036"),hexToRgb("#D8C8E5"),hexToRgb("#414770"),hexToRgb("#120D1C"),hexToRgb("#5B85AA")],[hexToRgb("#F2F7F2"),hexToRgb("#D6D6D6"),hexToRgb("#087E8B"),hexToRgb("#000000"),hexToRgb("#AC7B84")],[hexToRgb("#E1A3AD"),hexToRgb("#FBFEF9"),hexToRgb("#ED7B84"),hexToRgb("#000000"),hexToRgb("#A6BEC9")],[hexToRgb("#505050"),hexToRgb("#363636"),hexToRgb("#292929"),hexToRgb("#080808"),hexToRgb("#282828")],[hexToRgb("#E8DDCB"),hexToRgb("#036564"),hexToRgb("#033649"),hexToRgb("#021027"),hexToRgb("#CDB380")],[hexToRgb("#99B2B7"),hexToRgb("#948C75"),hexToRgb("#D5DED9"),hexToRgb("#251F18"),hexToRgb("#D9CEB2")],[hexToRgb("#FFB6B9"),hexToRgb("#F68787"),hexToRgb("#FCF6BD"),hexToRgb("#162C3B"),hexToRgb("#D67373")],[hexToRgb("#FFEBA1"),hexToRgb("#FFC857"),hexToRgb("#DB3A34"),hexToRgb("#071013"),hexToRgb("#08415C")],[hexToRgb("#EF7B6C"),hexToRgb("#F4F1BB"),hexToRgb("#9BC1BC"),hexToRgb("#1E1C22"),hexToRgb("#E6EBE0")],[hexToRgb("#CAD2C5"),hexToRgb("#52796F"),hexToRgb("#354F52"),hexToRgb("#182025"),hexToRgb("#84A98C")],[hexToRgb("#F5E0E7"),hexToRgb("#F55D3E"),hexToRgb("#D8CBC7"),hexToRgb("#161925"),hexToRgb("#077187")],[hexToRgb("#6B9AC4"),hexToRgb("#F4B942"),hexToRgb("#EFF2F1"),hexToRgb("#161F3C"),hexToRgb("#97D8C4")],[hexToRgb("#C2948A"),hexToRgb("#F6F0ED"),hexToRgb("#7EA8BE"),hexToRgb("#11232D"),hexToRgb("#BBB193")],[hexToRgb("#E1E3DE"),hexToRgb("#9BC4BC"),hexToRgb("#D3FFE9"),hexToRgb("#090909"),hexToRgb("#8DDBE0")],[hexToRgb("#FF571F"),hexToRgb("#FAAA8D"),hexToRgb("#FEEFDD"),hexToRgb("#201E1F"),hexToRgb("#50B2C0")],[hexToRgb("#4B3F72"),hexToRgb("#FFC857"),hexToRgb("#119DA4"),hexToRgb("#0C0E1D"),hexToRgb("#99D6EB")],[hexToRgb("#F04848"),hexToRgb("#FDBD28"),hexToRgb("#F7E092"),hexToRgb("#14142A"),hexToRgb("#37AD86")],[hexToRgb("#F1F7ED"),hexToRgb("#91C7B1"),hexToRgb("#B33951"),hexToRgb("#372F31"),hexToRgb("#E3D081")],[hexToRgb("#A3C4BC"),hexToRgb("#BFD7B5"),hexToRgb("#E7EFC5"),hexToRgb("#2D293D"),hexToRgb("#F2DDA4")],[hexToRgb("#D36135"),hexToRgb("#7FB069"),hexToRgb("#ECE4B7"),hexToRgb("#02020B"),hexToRgb("#E6AA68")],],noiseScale=.003,gridOptions=[2,3,4,5],gridCount=R.random_choice(gridOptions),angles=[30,45,60,-30,-45,-60],randomAngle=R.random_choice(angles),selectedPalette=R.random_choice(palette2),numberOfTrees=R.random_int(3,6),sunColorChance=R.random_dec(),bgStrokeIndex=R.random_int(0,palette1.length-1),waveScale=.005,numLdiv=R.random_num(5,10),sunX=R.random_num(180,1620),sunY=R.random_num(270,810),sunD=R.random_num(150,500);function setup(){noiseSeed(parseInt(tokenData.hash.substring(2,10),16)),createCanvas(canvasWidth,canvasHeight),pixelDensity(1),noLoop()}function draw(){background(palette1[bgStrokeIndex][0],palette1[bgStrokeIndex][1],palette1[bgStrokeIndex][2],palette1[bgStrokeIndex][3],palette1[bgStrokeIndex][4],palette1[bgStrokeIndex][6]),loadPixels();for(let e=borderOffset;e<height-borderOffset;e++)for(let o=borderOffset;o<width-borderOffset;o++){let t=noise(o*noiseScale+sin(3*e*waveScale),e*noiseScale+sin(o*waveScale)),g=.5*noise(o*noiseScale*.5+sin(e*waveScale),e*noiseScale*.5+sin(o*waveScale)),n=floor(map(t+g,0,2,0,palette1.length)),b=palette1[n=constrain(n,0,palette1.length-1)];set(o,e,color(b[0],b[1],b[2]))}updatePixels(),filter(BLUR,1),drawHatchingPattern(0,0,width,height),drawSun(sunX,sunY,sunD),push(),translate(width/2,height);let r;do r=R.random_int(0,palette1.length-1);while(3===r);for(let h=0;h<numberOfTrees;h++)drawTree(R.random_num(-540,540),R.random_num(270,360),R.random_num(270,540),PI,R.random_num(27,45),r),drawTree(R.random_num(-540,540),R.random_num(270,360),R.random_num(540,810),PI,R.random_num(27,45),r);pop();let x=(width-2*borderOffset)/gridCount,$=(height-2*borderOffset)/gridCount,T=gridCount-1,_=[...Array(gridCount)].map(()=>Array(gridCount).fill(!1));for(let a=0;a<T;a++){let d=R.random_int(0,gridCount-1),l=R.random_int(0,gridCount-1);if(_[d][l]){a--;continue}loadPixels();for(let s=l*$;s<(l+1)*$;s++)for(let i=d*x;i<(d+1)*x;i++){let u=i+borderOffset,f=s+borderOffset,F=get(u,f),m=getNearestColorIndex(F,palette1);if(m>=0&&m<selectedPalette.length){let C=selectedPalette[m];set(u,f,color(C[0],C[1],C[2]))}}updatePixels(),_[d][l]=!0}filter(BLUR,1),stroke(palette1[bgStrokeIndex][0],palette1[bgStrokeIndex][1],palette1[bgStrokeIndex][2],palette1[bgStrokeIndex][3],palette1[bgStrokeIndex][4],palette1[bgStrokeIndex][6]),strokeWeight(12-gridCount);for(let c=0;c<=gridCount;c++)line(borderOffset+c*x,borderOffset,borderOffset+c*x,height-borderOffset),line(borderOffset,borderOffset+c*$,width-borderOffset,borderOffset+c*$);noStroke(),push(),noStroke(),fill(palette1[bgStrokeIndex][0],palette1[bgStrokeIndex][1],palette1[bgStrokeIndex][2],palette1[bgStrokeIndex][3],palette1[bgStrokeIndex][4],palette1[bgStrokeIndex][6]),rect(0,canvasHeight-borderOffset,canvasWidth,borderOffset),pop()}function getNearestColorIndex(e,o){let t=1/0,g=-1;for(let n=0;n<o.length;n++){let b=euclideanDist(e,o[n]);b<t&&(t=b,g=n)}return g}function euclideanDist(e,o){let t=red(e)-o[0],g=green(e)-o[1],n=blue(e)-o[2];return sqrt(t*t+g*g+n*n)}function hexToRgb(e){let o=parseInt(e.slice(1,3),16),t=parseInt(e.slice(3,5),16),g=parseInt(e.slice(5,7),16);return[o,t,g]}function drawTree(e,o,t,g,n,b){if(t<2){let r=palette1[b];stroke(r[0],r[1],r[2]);for(let h=0;h<R.random_int(2,5);h++)line(e,o,e+R.random_num(-5,5),o+R.random_num(-5,5));return}let x=e+t*sin(g),$=o+t*cos(g);strokeWeight(n),stroke(5),line(e,o,x,$);let T=.75*n;T=constrain(T,1,40),drawTree(x,$,t*R.random_num(.6,.8),g+R.random_num(-PI/6,PI/6),T,b),drawTree(x,$,t*R.random_num(.6,.8),g+R.random_num(-PI/6,PI/6),T,b)}function drawSun(e,o,t){push();let g;fill(g=sunColorChance<.5?hexToRgb("#efc613"):sunColorChance<.9?hexToRgb("#F7F0F0"):hexToRgb("#9A031E")),noStroke(),ellipse(e,o,t),pop()}function drawHatchingPattern(e,o,t,g){push(),stroke(palette1[bgStrokeIndex][0],palette1[bgStrokeIndex][1],palette1[bgStrokeIndex][2],palette1[bgStrokeIndex][4]);let n=sqrt(t*t+g*g),b=n/numLdiv,r=randomAngle*PI/180;translate(e+t/2,o+g/2),rotate(r);for(let h=0;h<b;h++){let x=-n/2+20*h;strokeWeight(3*noise(.1*h)),line(-n/2,x,n/2,x)}pop()}function keyPressed(){("s"==key||"S"==key)&&saveCanvas("Fenestra","png")}