let spF,cols,rows,prtC,shM,resolution=20,flF=[],prt=[],mIt=5e3,cuIt=0,dmt=[];var curPr,clPr=[{nm:"fire",prCol:["#f0570b","#fc620b","#ff771e","#ff9a3f","#ff9840","#c33a00","#ff7019"],bcCo:["#bc162c"],pry:.04},{nm:"rcs",prCol:["#281933","#050615","#9ff4b5","#f647a2","#3a1868"],bcCo:["#050615"],pry:.03},{nm:"cyber",prCol:[[205,174,0],[184,0,215],[80,175,195],[215,30,185]],bcCo:[35,0,44],pry:.04},{nm:"vice",prCol:["#ff5995","#ff8a7f","#ff7f78","#ef4587","#8f0d6d","#b92c77","#b61a71"],bcCo:["#580151"],pry:.04},{nm:"WB",prCol:["#e6e9e5","#d5ccb8","#ddd4c0","#dcd2c4","#554a47","#3f3635","#292322","#c6bdab"],bcCo:["#25201f"],pry:.05},{nm:"fwoo",prCol:["#f0570b","#fc620b","#ff771e","#ff9a3f","#ff9840","#c33a00","#ff7019"],bcCo:["#21322a"],pry:.09},{nm:"party",prCol:["#e84461","#ea5972","#c12a43","#db4e66","#f05b71","#e33350","#c93e55"],bcCo:["#0e1833"],pry:.07},{nm:"brnz",prCol:["#ca4b00","#63351b","#d58954","#ff8b00","#d44600","#ed8028"],bcCo:["#400b03"],pry:.1},{nm:"cyci",prCol:["#00ffff","#00c3c2","#005f69","#003631","#00514c"],bcCo:["#1b0b1b"],pry:.1},{nm:"shGl",prCol:["#730045","#99005f","#bd0062","#ae075e","#8f035a","#680340","#47042c"],bcCo:["#050615"],pry:.06},{nm:"CuRa",prCol:"genR",bcCo:["#1c1c1c"],pry:.11},{nm:"btc",prCol:["#f47e16","#ec6216","#ec7000","#f58e00","#e87007"],bcCo:["#f7931a"],pry:.05},{nm:"CuRa2",prCol:"genR2",bcCo:[0,0,0],pry:.11},{nm:"CuRa3",prCol:"genR3",bcCo:[0,0,0],pry:.11}];function hashToSeed(e){let o=0;for(let r=0;r<e.length;r++){o=(16*o+e.charCodeAt(r))%2147483647}return o}function setup(){if(txnhash.length<60)return document.getElementById("message").style.display="block",void(document.getElementById("message").innerText=`Artwork will be generated with the hash of block ${block}`);createCanvas(1200,1200).parent("sketch-holder"),cols=floor(width/resolution),rows=floor(height/resolution),currentSeed=hashToSeed(txnhash),randomSeed(currentSeed);random(),random(),random();flF=new Array(cols*rows),dmt=new Array(rows).fill(0).map((()=>random(1,3))),shM=selMBY({showCircle:.28,showRectangle:.28,showDottedCircle:.27,showDoubleDot:.17}),apMSS(),curPr=selPB(),background(curPr.bcCo);for(let e=0;e<prtC;e++)prt[e]=new Particle(curPr,spF,globalDiameterOptions);generateflF(currentSeed)}function draw(){if(cuIt<mIt){for(let e=0;e<prt.length;e++)prt[e].follow(flF),prt[e].update(),prt[e].edges(),prt[e].show();cuIt++}}function selPB(e){const o=random();let r=0;for(const e of clPr)if(r+=e.pry,o<r)return e;return clPr[0]}function selMBY(e){let o=0;const r=random(),t=Object.keys(e),s=Object.values(e);for(let e=0;e<s.length;e++)if(o+=s[e],r<o)return t[e];return t[0]}function apMSS(){let e,o,r;switch(shM){case"showCircle":e={min:1,max:3},o=[20,40,60],r=[300,600,999],spF=1.2;break;case"showRectangle":e={min:.3,max:1},o=[20,40,60],r=[300,600,999,1500],spF=5.5,clPr=clPr.filter((e=>!(e.nm.includes("CuRa2")||e.nm.includes("btc")||e.nm.includes("fire")||e.nm.includes("cyber")||e.nm.includes("CuRa3"))));break;case"showDottedCircle":e=[{min:2,max:4},{min:3,max:7}][floor(random(2))],o=[20,40,60,80],r=[600,999],spF=1.5,clPr=clPr.filter((e=>!(e.nm.includes("WB")||e.nm.includes("vice")||e.nm.includes("fwoo")||e.nm.includes("rcs")||e.nm.includes("btc"))));break;case"showDoubleDot":e={min:2,max:5},o=[20,40],r=[300,600,999,1500],spF=3,clPr=clPr.filter((e=>!e.nm.includes("cyber")&&!e.nm.includes("rcs")&&!e.nm.includes("btc")))}resolution=random(o),prtC=random(r),dmt="showRectangle"===shM?new Array(rows).fill(0).map((()=>random(e.min,e.max))):[],globalDiameterOptions=e,curPr=selPB(),background(curPr.bcCo),console.log("Selected shM:",shM),console.log("Selected resolution:",resolution),console.log("Selected prtC:",prtC),console.log("Selected diameter range:",e),console.log("Selected color profile:",curPr.nm),console.log("Spacing Factor:",spF)}function generateflF(e){noiseSeed(e);let o=0;for(let e=0;e<rows;e++){let r=0;for(let t=0;t<cols;t++){let s=t+e*cols,l=noise(r,o),c=floor(8*l)*(PI/4),n=p5.Vector.fromAngle(c);flF[s]=n,r+=.1}o+=.1}}class Particle{constructor(e,o,r){this.pos=createVector(random(width)*o%width,random(height)*o%height),this.vel=createVector(0,0),this.acc=createVector(0,0),this.diameter=random(r.min,r.max),this.isMoving=!0,this.maxSpeed="showDoubleDot"===shM?2:"showDottedCircle"===shM||"showCircle"===shM?3:2,"genR"===e.prCol?this.color=[random(100,255),random(100,255),random(0,50)]:"genR2"===e.prCol?this.color=[random(24,130),random(15,15),random(20,25)]:"genR3"===e.prCol?this.color=[random(10,20),random(24,130),random(10,15)]:this.color=random(e.prCol)}follow(e){if(!this.isMoving)return;let o=e[floor(this.pos.x/resolution)+floor(this.pos.y/resolution)*cols];this.applyForce(o)}applyForce(e){this.acc.add(e)}update(){this.isMoving&&(this.vel.add(this.acc),this.vel.limit(this.maxSpeed),this.pos.add(this.vel),this.acc.mult(0))}show(){this[shM]()}showCircle(){fill(this.color),noStroke(),ellipse(this.pos.x,this.pos.y,this.diameter)}showRectangle(){fill(this.color),noStroke(),push(),translate(this.pos.x,this.pos.y),rotate(this.vel.heading()),rect(0,0,this.diameter,this.diameter),pop()}showLine(){stroke(this.color),strokeWeight(2),line(this.prevPos.x,this.prevPos.y,this.pos.x,this.pos.y),this.updatePrev()}showDottedCircle(){noFill(),stroke(this.color),beginShape(POINTS);for(let e=0;e<TWO_PI;e+=.7){let o=this.pos.x+cos(e)*this.diameter,r=this.pos.y+sin(e)*this.diameter;vertex(o,r)}endShape()}showDoubleDot(){stroke(this.color),strokeWeight(2),point(this.pos.x,this.pos.y);let e=p5.Vector.fromAngle(this.vel.heading()+PI/2).mult(3),o=p5.Vector.add(this.pos,e);point(o.x,o.y)}edges(){(this.pos.x>width||this.pos.x<0||this.pos.y>height||this.pos.y<0)&&(this.isMoving=!1)}}