function scaleAgnosticCanvas(t=[16,9]){let e=window.innerWidth,n=window.innerHeight;e*(t[1]/t[0])>n?createCanvas(n*(t[0]/t[1]),n):createCanvas(e,e*(t[1]/t[0]))}function keyPressed(){"p"===key&&exportSVG(width,height,svgAll),"s"===key&&save(`${tokenData.hash}.png`)}let prngCount=0;class Random{constructor(t){prngCount++,this.useA=!1;let e=function(t){let e=parseInt(t.substr(0,8),16),n=parseInt(t.substr(8,8),16),r=parseInt(t.substr(16,8),16),s=parseInt(t.substr(24,8),16);return function(){e|=0,n|=0,r|=0,s|=0;let t=(e+n|0)+s|0;return s=s+1|0,e=n^n>>>9,n=r+(r<<3)|0,r=r<<21|r>>>11,r=r+t|0,(t>>>0)/4294967296}};this.prngA=new e(t.substr(2,32)),this.prngB=new e(t.substr(34,32));for(let t=0;t<1e6;t+=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()}makeHash(){let t="0123456789abcdef",e="0x";for(let n=64;n>0;--n)e+=t[this.next(0,t.length,!0)];return e}next(t,e,n=!1){return!0!==t&&!1!==t||(t=void 0),!0!==e&&!1!==e||(e=void 0),null==t&&null==e&&(t=0,e=1),void 0!==t&&null==e&&(e=t,t=0),n?Math.floor(this.random_num(t,e)):this.random_num(t,e)}purge(t){for(let e=0;e<t;e++)this.random_num(0,1)}}let cob,colors,cob2,colors2,R=new Random(tokenData.hash);function pv(t,e,n){return new createVector(t,e,n)}function hyperIntersect(t,e,n,r){var s,o,i;return 0!==(s=(e.x-t.x)*(r.y-n.y)-(r.x-n.x)*(e.y-t.y))&&(i=((r.y-n.y)*(r.x-t.x)+(n.x-r.x)*(r.y-t.y))/s,o=((t.y-e.y)*(r.x-t.x)+(e.x-t.x)*(r.y-t.y))/s,0<i&&i<1&&0<=o&&o<=1)}function ptOfIntersection(t,e,n,r){if(t.x===e.x&&t.y===e.y||n.x===r.x&&n.y===r.y)return!1;if(denominator=(r.y-n.y)*(e.x-t.x)-(r.x-n.x)*(e.y-t.y),0===denominator)return!1;let s=((r.x-n.x)*(t.y-n.y)-(r.y-n.y)*(t.x-n.x))/denominator,o=((e.x-t.x)*(t.y-n.y)-(e.y-t.y)*(t.x-n.x))/denominator;return!(s<0||s>1||o<0||o>1)&&pv(t.x+s*(e.x-t.x),t.y+s*(e.y-t.y))}function lineIntersectsCurveBetter(t,e,{closed:n=!1}={}){let r=[];if(!1===n)for(let n=0;n<e.length-1;n++)hyperIntersect(t[0],t[1],e[n],e[n+1])&&r.push(ptOfIntersection(t[0],t[1],e[n],e[n+1]));else for(let n=0;n<e.length;n++)hyperIntersect(t[0],t[1],e[n],e[(n+1)%e.length])&&r.push(ptOfIntersection(t[0],t[1],e[n],e[(n+1)%e.length]));return r.length>0&&r}function exportSVG(t,e,n){let r=createWriter("svgfile"+tokenData.tokenId+".svg");r.write(svgBeginDocument(t/100,e/100)),r.write(svgBeginGroup("MainLayer")),n.forEach((t=>{r.write(svgCurve(t.shape,t.rgb_color,"noStroke"))})),r.write(svgEndGroup()),r.write(svgEndDocument()),r.close()}function svgBeginDocument(t,e){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+t+'in" height="'+e+'in" viewBox="0 0 '+100*t+" "+100*e+'" style="background-color:hsl(100, 0%, 100%);" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" inkscape:version="1.1.1 (c3084ef, 2021-09-22)">\n'}function svgEndDocument(){return"</svg>"}function svgBeginGroup(t,e="noFill",n="noStroke",r=0,s="square",o="miter",i="inline"){return'<g fill="'+svgParseColor(e)+'" stroke="'+svgParseColor(n)+'" display="'+i+'" stroke-width="'+r+'" stroke-linecap="'+s+'" stroke-linejoin="'+o+'" id="'+t+'" inkscape:groupmode="layer" inkscape:label="'+t+'">\n'}function svgEndGroup(){return"</g>\n"}function svgCurve(t,e="noFill",n="noStroke",r=0,s="square"){path='<polyline points="';for(let e=0;e<t.length;e++)path+=t[e].x+" "+t[e].y+" ";return e="noFill"==e?"":'fill="'+svgParseColor(e)+'" ',n="noStroke"==n?"":'stroke="'+svgParseColor(n)+'" ',r=0===r?"":'stroke-width="'+r+'" ',s="square"==s?"":'stroke-linecap="'+s+'"',path+='" '+e+n+r+s+"/>\n",path}function svgParseColor(t){return"noFill"==t||"noStroke"==t?"none":"rgb("+t[0]+","+t[1]+","+t[2]+")"}function average3(t,e,n){return pv((t.x+e.x+n.x)/3,(t.y+e.y+n.y)/3,(t.z+e.z+n.z)/3)}function motherGloveScalar(t,{motherBB:e=getCanvasAsBB(),padding:n=0}={}){let r,s=quickDist(t.p1,t.p4)/quickDist(t.p1,t.p2),o=quickDist(e.p1,e.p4)/quickDist(e.p1,e.p2);return s<=1&&o>=1?r=1:s>=1&&o<=1?r=2:(s>=1&&o>=1||s<=1&&o<=1)&&(s<=o?r=1:s>=o&&(r=2)),1===r?getScalar(t.p1,t.p2,pv(e.p1.x+n,e.p1.y),pv(e.p2.x-n,e.p2.y)):2===r&&getScalar(t.p1,t.p4,pv(e.p1.x,e.p1.y+n),pv(e.p4.x,e.p4.y-n))}function soften(t,{start:e=1,end:n=-1,loops:r=1,preserveZ:s=!1}={}){for(let o=0;o<r;o++)for(let r=e;r<t.length+n;r++){let e;e=average3(t[(r-1+t.length+t.length)%t.length],t[(r+t.length)%t.length],t[(r+1+t.length)%t.length]),s?t[(r+t.length)%t.length].set(e.x,e.y,t[(r+t.length)%t.length].z):t[(r+t.length)%t.length].set(e.x,e.y,e.z)}}function pointFrom(t,e,n){return pv(t.x-Math.sin(radians(e))*n,t.y+Math.cos(radians(e))*n)}function pointAng(t,e){let n=degrees(Math.atan2(e.y-t.y,e.x-t.x))-90,r=p5.Vector.fromAngle(radians(n));return degrees(r.heading())}function pointPerp(t,e){let n=degrees(Math.atan2(e.y-t.y,e.x-t.x)),r=p5.Vector.fromAngle(radians(n));return degrees(r.heading())}function quickDist(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}function getScalar(t,e,n,r){let s=[Math.hypot(e.x-t.x,e.y-t.y),Math.hypot(r.x-n.x,r.y-n.y)];return s[1]/s[0]}function getBB(t=[pv(0,0),pv(width,0),pv(width,height),pv(0,height)],{padding:e=0}={}){let n=99999999,r=999999999,s=-99999999,o=-99999999;for(let e=0;e<t.length;e++)n=Math.min(n,t[e].x),r=Math.min(r,t[e].y),s=Math.max(s,t[e].x),o=Math.max(o,t[e].y);return{p1:pv(n+e,r+e),p2:pv(s-e,r+e),p3:pv(s-e,o-e),p4:pv(n+e,o-e),width:s-e-(n+e),height:o-e-(r+e),mp:pv((n+s)/2,(r+o)/2)}}function makeBBofSize(t,{w:e=100,h:n=100}={}){let r=t.x-e/2,s=t.x+e/2,o=t.y-n/2,i=t.y+n/2;return{p1:pv(r,o),p2:pv(s,o),p3:pv(s,i),p4:pv(r,i),width:s-r,height:i-o,mp:pv((r+s)/2,(o+i)/2)}}function rotatePoint(t,e,n){t.sub(e.x,e.y),t.rotate(n),t.add(e.x,e.y)}function rotateShape(t,e,n){t.forEach((t=>{rotatePoint(t,e,radians(n))}))}function quickLine(t,e){line(t.x,t.y,e.x,e.y)}function drawArr(t,{closed:e=!1}={}){beginShape(),t.forEach((t=>{vertex(t.x,t.y)})),e?endShape(CLOSE):endShape()}function scaleArr(t,e,n=1,r=!1){t.forEach((t=>{"object"==typeof t&&Array.isArray(t)&&null!==t&&r?scaleArr(t,e,n,r):"object"!=typeof t||Array.isArray(t)||(t.sub(e.x,e.y),t.mult(n),t.add(e.x,e.y))}))}function translateArr(t,e,n,r=!1){t.forEach(((t,s)=>{"object"==typeof t&&Array.isArray(t)&&null!==t&&r?translateArr(t,e,n,r):"object"!=typeof t||Array.isArray(t)||(t.sub(e.x,e.y),t.add(n.x,n.y))}))}function combineBB(t){let e=99999999,n=999999999,r=-99999999,s=-99999999;for(let o=0;o<t.length;o++)e=Math.min(e,t[o].p1.x),n=Math.min(n,t[o].p1.y),r=Math.max(r,t[o].p3.x),s=Math.max(s,t[o].p3.y);return{p1:pv(e,n),p2:pv(r,n),p3:pv(r,s),p4:pv(e,s),width:r-e,height:s-n,mp:pv((e+r)/2,(n+s)/2)}}function addPointsToShapeEvenly(t,e,{start:n=0,end:r=-2}={}){for(let s=t.length+r;s>=n;s--){let n=dist(t[(s+t.length)%t.length].x,t[(s+t.length)%t.length].y,t[(s+1+t.length)%t.length].x,t[(s+1+t.length)%t.length].y);if(n>e){let r=[],o=Math.floor(n/e);for(let e=1;e<o;e++){let n=lerp(t[(s+t.length)%t.length].x,t[(s+1+t.length)%t.length].x,map(e,0,o,0,1)),i=lerp(t[(s+t.length)%t.length].y,t[(s+1+t.length)%t.length].y,map(e,0,o,0,1));r.push(pv(n,i))}t.splice(s+1,0,...r)}}-1==r&&t.push(pv(t[0].x,t[0].y,t[0].z))}function getCanvasAsArray({padding:t=0}={}){let e=[];return e.push(pv(0+t,0+t)),e.push(pv(width-t,0+t)),e.push(pv(width-t,height-t)),e.push(pv(0+t,height-t)),e}function getCanvasAsBB({padding:t=0}={}){let e={p1:pv(0+t,0+t),p2:pv(width-t,0+t),p3:pv(width-t,height-t),p4:pv(0+t,height-t)};return e.mp=pv((e.p1.x+e.p2.x)/2,(e.p2.y+e.p3.y)/2),e.width=e.p2.x-e.p1.x,e.height=e.p3.y-e.p2.y,e}function easingFunction(t,e,n=.8){switch(e){case 0:return easeInSine(t);case 1:return easeOutSine(t);case 2:return easeInOutSine(t);case 3:return easeInCubic(t);case 4:return easeOutCubic(t);case 5:return easeInOutCubic(t);case 6:return easeBellCurve(t,n);case 7:return easeBeta(t);case 8:return easeProbability(t);case 9:return easeOneLiner(t,.2);case 10:return easeOutBounce(t);case 11:return easeSemiCircle(t,n);case 12:return easeOneLiner(t,n);case 13:return easeOutBack(t)}}function easeInSine(t){return 1-Math.cos(t*Math.PI/2)}function easeOutSine(t){return Math.sin(t*Math.PI/2)}function easeInOutSine(t){return-(Math.cos(Math.PI*t)-1)/2}function easeInCubic(t){return t*t*t}function easeOutCubic(t){return 1-Math.pow(1-t,3)}function easeInOutCubic(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}function easeBellCurve(t,e){return(Math.sin(2*PI*(t-1/4))+e)/(2*e)}function easeBeta(t,e=2){return pow(2,e)*pow(t,e-1)*pow(1-t,e-1)}function easeProbability(t,e=2,n=5){return 4*pow(t,e-1)*pow(1-t,n-1)}function easeOutBack(t){const e=1.70158;return 1+2.70158*Math.pow(t-1,3)+e*Math.pow(t-1,2)}function easeOutBounce(t){const e=7.5625,n=2.75;return t<1/n?e*t*t:t<2/n?e*(t-=1.5/n)*t+.75:t<2.5/n?e*(t-=2.25/n)*t+.9375:e*(t-=2.625/n)*t+.984375}function easeSemiCircle(t,e=1){return 2/pow(PI*e,2)*sqrt(pow(e,2)-pow(t,2))}function easeOneLiner(t,e){return(1-t)*(1-Math.cos(t*e*2*Math.PI))}function findPointAlongSpline(t,e){if(1===e){let e=pv(t[t.length-1].x,t[t.length-1].y);return e.z=t.length-1,e.ang=pointAng(t[t.length-2],t[t.length-1]),e}if(0===e){let e=pv(t[0].x,t[0].y);return e.z=0,e.ang=pointAng(t[0],t[1]),e}let n=splineDist(t)*e,r=0;for(let e=1;e<t.length;e++){if(r+=quickDist(t[e-1],t[e]),r===n){let n=pv(t[e].x,t[e].y);return n.z=e,n.ang=pointAng(t[e-1],t[e]),n}if(r>n){r-=quickDist(t[e-1],t[e]);let s=(n-r)/quickDist(t[e-1],t[e]),o=pv(lerp(t[e-1].x,t[e].x,s),lerp(t[e-1].y,t[e].y,s));return o.z=e-1,o.ang=pointAng(t[e-1],t[e]),o}}return!1}function splineDist(t){let e=0;for(let n=0;n<t.length-1;n++)e+=quickDist(t[n],t[n+1]);return e}function makeRandomRect(t,{sz:e=[100,100],pointSpacing:n=0,loops:r=0,closed:s=!1,fitToBB:o=getCanvasAsBB(),rotate:i=0}={}){let a=[],l=[e[0],e[1]];a.push(pv(t.x-l[0]/2,t.y-l[1]/2)),a.push(pv(t.x+l[0]/2,t.y-l[1]/2)),a.push(pv(t.x+l[0]/2,t.y+l[1]/2)),a.push(pv(t.x-l[0]/2,t.y+l[1]/2)),!0===s&&a.push(pv(t.x-l[0]/2,t.y-l[1]/2));let h=makeBBofSize(t,{w:e[0],h:e[1]}),p=getBB(a);0!==i&&rotateShape(a,p.mp,i);let u=motherGloveScalar(p,{motherBB:h});return scaleArr(a,p.mp,u),a}class COB{constructor(t,{hue:e=R.next(0,360,!0),saturation:n=60,brightness:r=100,length:s=R.next(50,100)}={}){this.style=t,this.saturation=n,this.brightness=r,this.hue=e,this.sampleLength=s,this.paletteSize=100,this.defineColorCurves(),this.refreshColor({saturation:this.saturation,brightness:this.brightness}),this.refreshSampleLine({hue:this.hue,length:this.sampleLength})}generateBlank(){this.gb=createGraphics(360,100),this.gb.colorMode(HSB),this.gb.background(0,100,100),this.gb.pixelDensity(1),this.gb.strokeWeight(2)}defineColorCurves(){this.opacityCurve=[pv(0,100),pv(40,100),pv(40,20),pv(200,0),pv(200,100),pv(280,0),pv(320,0),pv(360,100),pv(360,100)],addPointsToShapeEvenly(this.opacityCurve,5),soften(this.opacityCurve,{loops:40})}refreshColor({saturation:t=this.saturation,brightness:e=this.brightness}={}){this.generateBlank(),this.gb.strokeWeight(3),this.gb.background(0,83,41);for(let n=40;n<200;n++)this.gb.stroke(map(n,40,200,60,190),t/2,(1-easingFunction(map(n,40,200,.5,.2),12))*e),this.gb.line(n,0,n,100);for(let n=40;n<140;n++)this.gb.stroke(30,t,e-e/4,map(n,40,140,1,0)),this.gb.line(n,0,n,100);for(let n=200;n<350;n++)this.gb.stroke(0,t/1.5,e),this.gb.line(n,0,n,100);for(let n=0;n<360;n++){let r=lineIntersectsCurveBetter([pv(n,-100),pv(n,200)],this.opacityCurve);!0===vintage||!0===bluePeriod||!0===fullSat?this.gb.stroke(n,100,100,map(r[0].y,0,100,0,1)):this.gb.stroke(n,t,e,map(r[0].y,0,100,0,1)),this.gb.line(n,0,n,100)}for(let t=0;t<50;t++)this.gb.stroke(0,0,100,easingFunction(map(t,0,50,.9,0),!0===vintage||!0===bluePeriod?0:3)),this.gb.line(0,t,360,t),this.gb.stroke(0,0,0,easingFunction(map(t+50,50,100,0,.9),!0===vintage||!0===bluePeriod?0:3)),this.gb.line(0,t+50,360,t+50);if(!0===vintage)for(let t=-2;t<=362;t++)this.gb.stroke(18,100,!0===bluePeriod?30:45,!0===bluePeriod?.53:.35),this.gb.line(t,0,t,100);if(!0===bluePeriod)for(let t=-2;t<=362;t++)this.gb.stroke(205,100,!0===vintage?40:35,!0===vintage?.2:.4),this.gb.line(t,0,t,100);if(!0===vintage&&!0===bluePeriod)for(let t=0;t<50;t++)this.gb.stroke(0,0,100,easingFunction(map(t,0,50,.35,0),0)),this.gb.line(0,t,360,t),this.gb.stroke(0,0,0,easingFunction(map(t+50,50,100,0,.35),0)),this.gb.line(0,t+50,360,t+50);this.gb.image(this.gb,0,0),this.gb.loadPixels()}refreshSampleLine({hue:t=this.hue,length:e=this.sampleLength}={}){let n=pv(t=(t+360)%360,50),r=R.next(0,90);this.sampleLine=[],this.sampleLine.push(pointFrom(n,r,e/2)),this.sampleLine.push(n),this.sampleLine.push(pointFrom(n,(r+180)%360,e/2)),this.sampleLine.forEach(((t,e)=>{t.y>100&&this.sampleLine[e].set(t.x,95),t.y<0&&this.sampleLine[e].set(t.x,5)})),this.sampleLine.push(pv(this.sampleLine[this.sampleLine.length-1].x,5)),this.sampleLine.unshift(pv(this.sampleLine[0].x,95)),addPointsToShapeEvenly(this.sampleLine,10),soften(this.sampleLine,{loops:7,start:1,end:-1})}getColorAt(t){let e=findPointAlongSpline(this.sampleLine,t);return this.getColor(e.x,e.y)}getColorCount(t){let e,n,r,s,o=[];this.saturation<50?(r="up",e=(100-this.saturation)/t):(r="down",e=this.saturation/t),this.brightness<50?(s="up",n=(100-this.brightness)/t):(s="down",n=this.brightness/t);for(let i=0;i<=t;i++){let a=this.getColorAt(map(i,0,t,0,1));o.push(a),0===this.style?("down"===r?this.saturation=this.saturation-e:"up"===r&&(this.saturation=this.saturation+e),"down"===s?this.brightness=this.brightness-n:"up"===s&&(this.brightness=this.brightness+n)):1===this.style&&("down"===r?this.saturation=this.saturation-e:"up"===r&&(this.saturation=this.saturation+e)),this.refreshColor({saturation:this.saturation,brightness:this.brightness})}return o}getColor(t,e){let n=1*(floor(e)*this.gb.width+floor(t))*4;return[this.gb.pixels[n],this.gb.pixels[n+1],this.gb.pixels[n+2],this.gb.pixels[n+3]]}displayCurves(){noFill(),stroke(0),drawArr(this.opacityCurve,{scaled:!1});let t=findPointAlongSpline(this.opacityCurve,map(mouseX,0,width,0,1));circle(t.x,t.y,5);for(let t=0;t<360;t++)t%10==0&&(fill(0),noStroke(),textSize(5),text(t,t,110),noFill(),stroke(0),strokeWeight(.5),line(t,0,t,105));noFill(),stroke(0),drawArr(this.sampleLine,{scaled:!1})}display(){image(this.gb,0,0)}}let localSpace,spireStyle,dia,newHeight,depth,face,bounds,hue,stretch,primaryColorStyle,spiralStyle,partitionStyle,warp,vintage,bluePeriod,fullSat,parts=[],svgGroup=[],colorIndex=0,cilAng=.9,svgAll=[],saveCounter=0,timeNow=0;function setup(){scaleAgnosticCanvas([6,8]),background(204,196,175),localSpace=getBB(makeRandomRect(pv(300,400),{sz:[600,800]})),noLoop(),resetVariables(),createParts(),drawTheBackground(),drawTheStack()}function draw(){}function resetVariables(){R=new Random(tokenData.hash),R.purge(1e3),svgAll=[],parts=[],spireStyle=R.next()>.95?1:0,svgGroup=[],colorIndex=0,cilAng=1===spireStyle?R.next(.2,.9):R.next()>.95?0:R.next(.2,.9),dia=localSpace.width/2,rate=R.next()>.15?1.001:R.next()>.5?1.01:1.0001,dia=localSpace.width/2,depth=1,bounds=getCanvasAsArray({padding:.01*min(width,height)}),primaryColorStyle=R.next()>.3?1:0,spiralStyle=R.next()>.8,partitionStyle=R.next()>.82,enableStepDown=R.next()>.85,warp=R.next()>.82,vintage=R.next()>.88,bluePeriod=R.next()>.92,fullSat=R.next()>.25,hue=R.next(0,360),newHeight=pv(localSpace.width/2,localSpace.height+R.next(600,-400)),stretch=R.next(30,180)}function createParts(){for(;newHeight.y>localSpace.p1.y;)[newHeight,data]=makeCylinder(newHeight,dia,depth),parts.push(data),dia/=rate,enableStepDown&&R.next()>.993&&(dia/=1.2),depth*=rate;if(!0===spiralStyle){let t=0,e=12,n=R.next(50,100),r=R.next()>.5?-1:1;parts.forEach(((s,o)=>{for(let i in s)translateArr(s[i],pv(0,0),pv(sin(radians(t))*easingFunction(map(o,0,parts.length,0,1),e)*n*r,cos(radians(t))*easingFunction(map(o,0,parts.length,0,1),e)*n*cilAng*r));t+=3}))}if(!0===partitionStyle){let t=Math.floor(parts.length/8),e=Math.floor(parts.length/4),n=!1;for(let r=Math.floor(t/2);r<Math.floor(parts.length-t/2);r++){n=r%e>=0&&r%e<t;for(let t in parts[r])translateArr(parts[r][t],pv(0,0),pv(!0===n?70:-70,0))}}if(!0===warp){let t=R.next()>.5?1:-1;parts.forEach(((e,n)=>{for(let r in e)rotateShape(e[r],pv(localSpace.mp.x,localSpace.p3.y),map(n,0,parts.length,40*t,10*t))}))}let t=[];parts.forEach((e=>{t.push(getBB(e.fullStack)),t.push(getBB(e.fullCap))})),t=combineBB(t);let e,n,r=motherGloveScalar(t,{mother:getCanvasAsBB(),padding:.05*width});parts.forEach(((e,n)=>{for(let n in e)scaleArr(e[n],t.mp,r),translateArr(e[n],t.mp,pv(width/2,height/2)),rotateShape(e[n],pv(width/2,height/2),map(cilAng,0,1,0,0))}));let s=!0===fullSat?0:R.next(0,4,!0);if(0===s?(e=0,n=49):1===s?(e=49,n=49):2===s&&(e=99,n=49),cob=new COB(0,{hue:hue,saturation:n,brightness:e,length:stretch}),0===primaryColorStyle){let t=R.next(2,5,!0);colors=cob.getColorCount(Math.floor(parts.length/t))}else 1===primaryColorStyle&&(colors=cob.getColorCount(parts.length+2));colors.reverse(),cob2=new COB(0,{hue:hue,saturation:n,brightness:e,length:stretch/4}),colors2=cob2.getColorCount(R.next(10,10,!0)),colors2.reverse(),colorIndex=R.next(0,colors.length,!0)}function drawTheBackground(){noStroke(),svgAll.push({shape:getCanvasAsArray(),rgb_color:[204,196,175]}),fill(colors2[(0+colorIndex)%colors2.length]),drawArr(bounds),svgAll.push({shape:bounds,rgb_color:colors2[(0+colorIndex)%colors2.length]});let t=getBB(parts[0].fullCap),e=[pv(bounds[0].x,min(height-height/3,t.p1.y)),pv(bounds[1].x,min(height-height/3,t.p1.y)),bounds[2],bounds[3]];fill(colors2[(1+colorIndex)%colors2.length]),drawArr(e),svgAll.push({shape:e,rgb_color:colors2[(1+colorIndex)%colors2.length]})}function drawTheStack(){noStroke(),parts.forEach(((t,e)=>{if(0===spireStyle){let n=[colors[(e+2+colorIndex)%colors.length][0]-10,colors[(e+2+colorIndex)%colors.length][1]-10,colors[(e+2+colorIndex)%colors.length][2]-10];fill(n),drawArr(t.fullStack),svgAll.push({shape:t.fullStack,rgb_color:n}),n=colors[(e+2+colorIndex)%colors.length],fill(n),drawArr(t.fullCap),svgAll.push({shape:t.fullCap,rgb_color:n})}else if(1===spireStyle){let n=[colors[(e+2+colorIndex)%colors.length][0]-10,colors[(e+2+colorIndex)%colors.length][1]-10,colors[(e+2+colorIndex)%colors.length][2]-10];fill(n),drawArr(t.halfStack),svgAll.push({shape:t.halfStack,rgb_color:n}),n=colors[(e+2+colorIndex)%colors.length],fill(n),drawArr(t.halfCap),svgAll.push({shape:t.halfCap,rgb_color:n}),n=[colors[(e+2+colorIndex)%colors.length][0]-10,colors[(e+2+colorIndex)%colors.length][1]-20,colors[(e+2+colorIndex)%colors.length][2]-20],fill(n),drawArr(t.halfStackFace),svgAll.push({shape:t.halfStackFace,rgb_color:n})}}))}function makeCylinder(t,e,n){let r=e*cilAng,s=[];for(let n=270;n<=450;n+=2)s.push(pv(t.x+sin(radians(n))*e,t.y+cos(radians(n))*r));s.push(pv(s[s.length-1].x,s[s.length-1].y-n)),s.unshift(pv(s[0].x,s[0].y-n));for(let o=450;o>=270;o-=2)s.push(pv(t.x+sin(radians(o))*e,t.y-n+cos(radians(o))*r));let o=[];for(let s=0;s<=360;s+=2)o.push(pv(t.x+sin(radians(s))*e,t.y-n+cos(radians(s))*r));let i=[];for(let n=30;n<=90;n+=2)i.push(pv(t.x+sin(radians(n))*e,t.y+cos(radians(n))*r));for(let s=90;s>=30;s-=2)i.push(pv(t.x+sin(radians(s))*e,t.y-n+cos(radians(s))*r));i.unshift(pv(i[0].x,i[0].y-n)),halfStackFace=[pv(i[0].x,i[0].y),pv(i[1].x,i[1].y)],halfStackFace.push(pv(t.x+sin(radians(210))*e,t.y+cos(radians(210))*r)),halfStackFace.push(pv(t.x+sin(radians(210))*e,t.y-n+cos(radians(210))*r));let a=[];for(let s=30;s<=210;s+=2)a.push(pv(t.x+sin(radians(s))*e,t.y-n+cos(radians(s))*r));let l={fullStack:s,fullCap:o,halfStack:i,halfStackFace:halfStackFace,halfCap:a};return[pv(t.x,t.y-n),l]}
↓ show full (19,360 bytes)