0xa5d9…5604

All memos sent from and to 0xa5d9…5604.

/** * [js-sha3]{@link https://github.com/emn178/author Chen, Yi-Cyuan [ t(t,e,r){this.blocks=[],`Count=1600-(t<<1)>>53;for(var n=0;n<50;++n)`Xd type",n="obje!f{};i.JS_SHA3_NO_WINDOW&&(n!2.node?i=global:o ArrayBuffer,f="0123456789abc ,".split(""),c=[4,1024,262144,67108864],h=[0,8,16,2 56,384,512],l!r@56],y=["hex","bat%S row new Err%t o=y[i];t[o]=e( 2!O=[{name:"keccak", N.push(H),z[H] !>>2]|=n<<h[3&r++]:n<2048?( Index=r,r>=%v@S`(t+΅d i=(e-r%e)%e%O,s,u,f,c,h,d,l,y,b,v,A,g,B,_0C,x,m,O,z,N,J,M,j,E,H,I,R,F,U,D,V,W,Y,K,q,G,L,P,Q,T,X,Z,$,t%0%!" t,it,ot,at,st,u+overflow: hidden absolute m!c visibilit!-a","Chris Lasch mZO >0)/4294967</[^a-zA-Z0-9]/g,F:16777215,edge:0},incotta:8929589,pink 0k:2171945,grey:6909033 56,royalB % :2243701,ul)["NONE","#384& @
M_THREADS/2);j++){threadingGrid[>M.var.NUM_SHAFTS-1){let flag=0;=Math.floor(rand()*=@F Choice([-1,1])}offsetPattern(g"checkSequentialRuns(8-3,@)omRules=()=>Array.from(!userData.myInfo=" nqq TableSnipp Jr| (min=0,maxNg s(gridName,pat,
carletRed","lightPink"]},{name:"Cool",p:1,arr:["tenderGreen 1]}]};const chairModels={fouquet: spacingTypes=["StandarA=w.M=M;scopeF2();function {M. 1 ={zoom:30,c! ve`i :new THREE.`15658734),background`@],maxGen:2,NUM_SHAFTS:8`passedLengthTest:trueD:2038564,showBothCanvases:' *1`};M.seed=tokenData.hash;sReload.,x,y,w,h,ox,oy){this.@ eadling.activeqgeometry=new THREE.P; myInfo={type:"@SA@P SHAFTS-1){`&=@" Choice([-1,/
** * [js-sha3]{@link https://github.com/emn178/author Chen, Yi-Cyuan [ t(t,e,r){this.blocks=[],`Count=1600-(t<<1)>>53;for(var n=0;n<50;++n)`Xd type",n="obje!f{};i.JS_SHA3_NO_WINDOW&&(n!2.node?i=global:o ArrayBuffer,f="0123456789abc ,".split(""),c=[4,1024,262144,67108864],h=[0,8,16,2 56,384,512],l!r@56],y=["hex","bat%S row new Err%t o=y[i];t[o]=e( 2!O=[{name:"keccak", N.push(H),z[H] !>>2]|=n<<h[3&r++]:n<2048?( Index=r,r>=%v@S`(t+΅d i=(e-r%e)%e%O,s,u,f,c,h,d,l,y,b,v,A,g,B,_0C,x,m,O,z,N,J,M,j,E,H,I,R,F,U,D,V,W,Y,K,q,G,L,P,Q,T,X,Z,$,t%0%!" t,it,ot,at,st,u+overflow: hidden absolute m!c visibilit!-a","Chris Lasch mZO >0)/4294967</[^a-zA-Z0-9]/g,F:16777215,edge:0},incotta:8929589,pink 0k:2171945,grey:6909033 56,royalB % :2243701,ul)["NONE","#384& @
ize(new THREE.Vector3);let bboxCy=Math.min(weaveCanvas.cli )Height);renderer.set@n=tokenData.hash,B i=1;i<=6;i++){!M.var[`C${i}`]!=="NONE" 1 rand(min=0,max=1){return ` shuffleArray(a@" tyleSquareDiv(
/** * [js-sha3]{@link https://github.com/emn178/author Chen, Yi-Cyuan [ t(t,e,r){this.blocks=[],`Count=1600-(t<<1)>>53;for(var n=0;n<50;++n)`Xd type",n="obje!f{};i.JS_SHA3_NO_WINDOW&&(n!2.node?i=global:o ArrayBuffer,f="0123456789abc ,".split(""),c=[4,1024,262144,67108864],h=[0,8,16,2 56,384,512],l!r@56],y=["hex","bat%S row new Err%t o=y[i];t[o]=e( 2!O=[{name:"keccak", N.push(H),z[H] !>>2]|=n<<h[3&r++]:n<2048?( Index=r,r>=%v@S`(t+΅d i=(e-r%e)%e%O,s,u,f,c,h,d,l,y,b,v,A,g,B,_0C,x,m,O,z,N,J,M,j,E,H,I,R,F,U,D,V,W,Y,K,q,G,L,P,Q,T,X,Z,$,t%0%!" t,it,ot,at,st,u+overflow: hidden absolute m!c visibilit!-a","Chris Lasch mZO >0)/4294967</[^a-zA-Z0-9]/g,F:16777215,edge:0},incotta:8929589,pink 0k:2171945,grey:6909033 56,royalB % :2243701,ul)["NONE","#384& @ 2,NUM_SHAFTS:8`passedL6a thTest:trueD:2038564,showBothCanvases:' 2Z`};M.seed=tokenData.hash;sReload.name,x,y,w,h,ox,oy){this.@
ENLACE is a groundbreaking collection of one-of-a-kind generative chairs presented by TRAME in collaboration with Aranda\Lasch and Maison Louis Drucker. Reimagining the iconic Parisian café chair, the project weaves together algorithmic design and French heritage craftsmanship. At its core is a custom algorithm developed by Aranda\Lasch, which generates unique digital patterns that are handwoven by Maison Drucker’s master artisans. By merging computational creativity with traditional cane weaving, ENLACE exemplifies TRAME’s mission to explore the intersections of craft and technology—offering a fresh, contemporary take on a timeless cultural symbol.
hreadingPattern?this.twillPattern(this.threading):"triWave"==M.var.threadingPattern?this.triWavePattern(this.threading):"vPattern"==M.var.threadingPattern?this.vPattern(this.threading):"rand"==M.var.threadingPattern&&this.randPattern(this.threading),"twill"==M.var.treadlingPattern?this.twillPattern(this.treadling):"triWave"==M.var.treadlingPattern?this.triWavePattern(this.treadling):"vPattern"==M.var.treadlingPattern?this.vPattern(this.treadling):"rand"==M.var.treadlingPattern&&this.randPattern(this.treadling)}resetPattern(e){const r=e.size.x,t=e.size.y;let a=[];for(let e=0;e<r;e++){let e=[];for(let r=0;r<t;r++)e.push(0);a.push(e)}e.pattern=a,e.mesh=[...a]}getColorGridS(e=M.var.colorWarpCount,r=M.var.colorWeftCount,t=M.var.colorPalette,a="eng"){this.colorWarp.palette=[],this.colorWarp.pattern=[],this.colorWarp.count=e,this.colorWeft.palette=[],this.colorWeft.pattern=[],this.colorWeft.count=r;let o=druckerSatinColors,l=[],i=e+r;l=this.pickSelectedColors(o,i),console.log("selectedColors",l);let n,s=0;for(let e=0;e<this.colorWarp.count;e++)n=l[s],this.colorWarp.palette.push(n.color),M.var.colorWarpNames.push(colorNames[n.name][a]),s++;for(let e=0;e<this.colorWeft.count;e++)n=l[s],this.colorWeft.palette.push(n.color),M.var.colorWeftNames.push(colorNames[n.name][a]),s++;M.var.colorWarp=this.colorWarp.palette,M.var.colorWeft=this.colorWeft.palette;let d=0;for(let e=0;e<this.colorWarp.length;e++)this.colorWarp.pattern.push(this.colorWarp.palette[d]),d++,d==this.colorWarp.palette.length&&(d=0);let c=0;for(let e=0;e<this.colorWeft.length;e++)this.colorWeft.pattern.push(this.colorWeft.palette[c]),c++,c==this.colorWeft.palette.length&&(c=0)}getGoodDisplayColors(){let e=0,r=!0;for(;r;)if(this.getdisplayColors(),r=this.checkDisplayColors(),e++,e>1e3){r=!1;break}}checkDisplayColors(){for(let e=0;e<colorCull.length;e++)if(colorCull[e].includes(getColorFromLang(displayColors.solidName))&&colorCull[e].includes(getColorFromLang(displayColors.groundName)))return!0;return!1}getdisplayColors(){if("Original"==M.var.displayMode)displayColors.treadling.active.cell=M.var.activeColor,displayColors.treadling.active.edge=M.var.activeColor,displayColors.treadling.inactive.cell=M.var.inactiveColor,displayColors.treadling.inactive.edge=M.var.activeColor,displayColors.tieUp.active.cell=M.var.activeColor,displayColors.tieUp.active.edge=M.var.activeColor,displayColors.tieUp.inactive.cell=M.var.inactiveColor,displayColors.tieUp.inactive.edge=M.var.activeColor,displayColors.threading.active.cell=M.var.activeColor,displayColors.threading.active.edge=M.var.activeColor,displayColors.threading.inactive.cell=M.var.inactiveColor,displayColors.threading.inactive.edge=M.var.activeColor,displayColors.background=M.var.backgroundColor,displayColors.solid=M.var.activeColor,displayColors.ground=M.var.inactiveColor;else if("Inverse"==M.var.displayMode){let e,r,t=16711935,a=16711680;1==this.colorWeft.palette.length&&this.colorWarp.palette.length>=2?(r=0,e=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),t=this.colorWarp.palette[r],a=this.colorWeft.palette[e],displayColors.backgroundName=M.var.colorWarpNames[r],displayColors.solidName=M.var.colorWarpNames[r],displayColors.groundName=M.var.colorWeftNames[e]):(r=0,e=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),t=this.colorWeft.palette[r],a=this.colorWarp.palette[e],displayColors.backgroundName=M.var.colorWeftNames[r],displayColors.solidName=M.var.colorWeftNames[r],displayColors.groundName=M.var.colorWarpNames[e]),displayColors.treadling.active.cell=a,displayColors.treadling.active.edge=!1,displayColors.treadling.inactive.cell=t,displayColors.treadling.inactive.edge=!1,displayColors.tieUp.active.cell=a,displayColors.tieUp.active.edge=!1,displayColors.tieUp.inactive.cell=t,displayColors.tieUp.inactive.edge=!1,displayColors.threading.active.cell=a,displayColors.threading.active.edge=!1,displayColors.threading.inactive.cell=t,displayColors.threading.inactive.edge=!1,displayColors.background=t,displayColors.solid=t,displayColors.ground=a}else if("Grid"==M.var.displayMode){let e,r,t=16711935,a=16711680;1==this.colorWeft.palette.length&&this.colorWarp.palette.length>=2?(r=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),t=this.colorWarp.palette[r],a=this.colorWeft.palette[e],displayColors.backgroundName=M.var.colorWarpNames[r],displayColors.solidName=M.var.colorWarpNames[r],displayColors.groundName=M.var.colorWeftNames[e]):(r=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),t=this.colorWeft.palette[r],a=this.colorWarp.palette[e],displayColors.backgroundName=M.var.colorWeftNames[r],displayColors.solidName=M.var.colorWeftNames[r],displayColors.groundName=M.var.colorWarpNames[e]),displayColors.treadling.active.cell=t,displayColors.treadling.active.edge=t,displayColors.treadling.inactive.cell=a,displayColors.treadling.inactive.edge=t,displayColors.tieUp.active.cell=t,displayColors.tieUp.active.edge=t,displayColors.tieUp.inactive.cell=a,displayColors.tieUp.inactive.edge=t,displayColors.threading.active.cell=t,displayColors.threading.active.edge=t,displayColors.threading.inactive.cell=a,displayColors.threading.inactive.edge=t,displayColors.background=t,displayColors.solid=t,displayColors.ground=a}else if("Weave Colors"==M.var.displayMode){let e,r,t=16711935,a=16711680;1==this.colorWeft.palette.length&&this.colorWarp.palette.length>=2?(r=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),t=this.colorWarp.palette[r],a=this.colorWeft.palette[e],displayColors.backgroundName=M.var.colorWarpNames[r],displayColors.solidName=M.var.colorWarpNames[r],displayColors.groundName=M.var.colorWeftNames[e]):(r=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),t=this.colorWeft.palette[r],a=this.colorWarp.palette[e],displayColors.backgroundName=M.var.colorWeftNames[r],displayColors.solidName=M.var.colorWeftNames[r],displayColors.groundName=M.var.colorWarpNames[e]);let o=this.colorWarp.palette,l=this.colorWeft.palette;displayColors.treadling.active.cell=l,displayColors.treadling.active.edge=!1,displayColors.treadling.inactive.cell=t,displayColors.treadling.inactive.edge=!1,displayColors.tieUp.active.cell=t,displayColors.tieUp.active.edge=!1,displayColors.tieUp.inactive.cell=a,displayColors.tieUp.inactive.edge=!1,displayColors.threading.active.cell=o,displayColors.threading.active.edge=!1,displayColors.threading.inactive.cell=t,displayColors.threading.inactive.edge=!1,displayColors.background=t,displayColors.solid=t,displayColors.ground=a}renderer.setClearColor(displayColors.background)}visualizeColorGrids(){let e=new THREE.PlaneGeometry(M.var.cellSize,M.var.cellSize);for(let r=0;r<this.colorWarp.length;r++){const t=new THREE.MeshBasicMaterial({color:this.colorWarp.pattern[r]});let a=new THREE.Mesh(e,t);a.position.fromArray(this.colorWarp.posOffset[0][r]),a.userData.myInfo={type:"cell",deleteFlag:this.colorWarp.name},this.colorWarp.mesh[r]=a,a.visible=M.var.colorWarpVisible,scene.add(a)}for(let r=0;r<this.colorWeft.length;r++){const t=new THREE.MeshBasicMaterial({color:this.colorWeft.pattern[r]});let a=new THREE.Mesh(e,t);a.position.fromArray(this.colorWeft.posOffset[r][0]),a.userData.myInfo={type:"cell",deleteFlag:this.colorWeft.name},this.colorWeft.mesh[r]=a,a.visible=M.var.colorWeftVisible,scene.add(a),r>this.colorWeft.length/this.colorWeft.offSet.y&&(a.visible=!1)}}pickSelectedColors(e,r){let t=[],a=[];for(let e=0;e<palettes[r].length;e++)M.var.colorSelectName==palettes[r][e].name&&(t.push(e),a.push(palettes[r][e].p));let o=rWeightedItems(t,a),l=palettes[r][o].name,i=palettes[r][o].arr,n=[];for(let t=0;t<r;t++)n.push({color:new THREE.Color(e[i[t]]),name:i[t]});return shuffleArray(n),M.var.colorGroupName=l,n}twillPattern(e=this.threading,r=M.var.twillSlope,t=M.var.twillOff,a){this.threading.pattern,this.treadling.pattern;if(e==this.threading){let e=M.var.threadingSlope,r=(M.var.threadingOffset,M.var.threadingTranslate),t=this.threading.size.x,a=this.threading.size.y+1,o=this.threading.pattern;for(let l=0;l<a-1;l++){let a=Math.floor((e*l+r)%t);o[a][l]=1}}else if(e==this.treadling){let e=M.var.treadlingSlope,r=(M.var.treadlingOffset,M.var.treadlingTranslate),t=this.treadling.size.y,a=this.treadling.size.x+1,o=this.treadling.pattern;for(let l=0;l<a-1;l++){let a=Math.floor((e*l+r)%t);o[l][a]=1}}}vPattern(e=this.threading){let r=this.threading.pattern,t=this.treadling.pattern;if(e==this.threading){let e=1,t=(M.var.threadingOffset,0);for(let a=0;a<M.var.NUM_THREADS;a++)r[t][a]=1,t+=e,t==M.var.NUM_SHAFTS-1&&(e*=-1),0==t&&a>0&&(e*=-1)}else if(e==this.treadling){let e=1,r=(M.var.treadlingOffset,0);for(let a=0;a<M.var.NUM_PICKS;a++)t[a][r]=1,r+=e, r==M.var.NUM_TREADLES-1&&(e*=-1),0==r&&a>0&&(e*=-1)}}triWavePattern(e=this.threading){this.threading.pattern,this.treadling.pattern;if(e==this.threading){let e=M.var.threadingSlope,r=(M.var.threadingOffset,M.var.threadingTranslate),t=this.threading.size.x,a=this.threading.size.y+1,o=this.threading.pattern;for(let l=0;l<a-1;l++){let a=Math.abs(Math.floor(triangleWave(l,e,t,r)));o[a][l]=1}}else if(e==this.treadling){let e=M.var.treadlingSlope,r=(M.var.treadlingOffset,M.var.treadlingTranslate),t=this.treadling.size.y,a=this.treadling.size.x+1,o=this.treadling.pattern;for(let l=0;l<a-1;l++){let a=Math.abs(Math.floor(triangleWave(l,e,t,r)));o[l][a]=1}}}randPattern(e=this.threading){let r=this.threading.pattern,t=this.treadling.pattern;if(e==this.threading){let e=Math.floor(rand()*M.var.NUM_SHAFTS),t=randChoice([-1,1]),a=0;a=e;for(let o=0;o<Math.floor(M.var.NUM_THREADS/2);o++){if(r[a][o]=1,a+=t,a>M.var.NUM_SHAFTS-1){let r=0;for(;0==r;)e=Math.floor(rand()*M.var.NUM_SHAFTS),e!=M.var.NUM_SHAFTS-1&&(r=1);t=randChoice([-1,1]),a=e}if(a<0){let r=0;for(;0==r;)e=Math.floor(rand()*M.var.NUM_SHAFTS),0!=e&&(r=1);t=randChoice([-1,1]),a=e}}for(let e=Math.floor(M.var.NUM_THREADS/2);e<M.var.NUM_THREADS;e++)for(let t=0;t<M.var.NUM_SHAFTS;t++)r[t][e]=r[t][e-Math.floor(M.var.NUM_THREADS/2)]}else if(e==this.treadling)for(let e=0;e<M.var.NUM_PICKS;e++)for(let a=0;a<M.var.NUM_TREADLES;a++)t[e][a]=r[a][e]}offsetPattern(e){const r=e.size.x,t=e.size.y;let a;a="treadling"==e.name||"colorWeft"==e.name||"drawdownWarp"==e.name||"drawdownWeft"==e.name?(M.var.verticalSpacing-1)/2:0;let o=[];for(let l=0;l<r;l++){let r=[];for(let o=0;o<t;o++){let t=[o*M.var.cellSize*e.offSet.x+e.position.x+(1-e.offSet.y)/2+a,-l*M.var.cellSize*e.offSet.y+e.position.y+(1-e.offSet.y)/2,0];r.push(t)}o.push(r)}e.posOffset=o}caTieUpGrid(){let e=0,r=!1;for(;(!r||e<1e3)&&(this.makeCA(this),r=this.checkSequentialRuns(5,this.tieUp.pattern,!1),!r);)e++;e>=1e3&&console.error("CA tie up count",e)}makeCA(){const e=()=>Array.from({length:14},()=>Math.round(rand()));let r=!0;for(;r;){let t=0;this.theRules=e(),myCa=new CA(this.theRules,M.var.NUM_SHAFTS,M.var.NUM_TREADLES,scene),myCa.randomSeed(1),myCa.restart();for(let e=0;e<12;e++)myCa.generate();this.tieUp.pattern=myCa.oldBoard;let a=0;for(let e=0;e<this.tieUp.pattern.length;e++)for(let r=0;r<this.tieUp.pattern[e].length;r++)1==this.tieUp.pattern[e][r]&&a++;t++,a>M.var.NUM_SHAFTS*M.var.NUM_SHAFTS*.2&&a<M.var.NUM_SHAFTS*M.var.NUM_SHAFTS*.8?r=!1:t>100&&(r=!1)}}visualizeGrid(e){let r=e.pattern,t=e.name,a=new THREE.PlaneGeometry(M.var.cellSize,M.var.cellSize);for(let o=0;o<r.length;o++)for(let l=0;l<r[o].length;l++){let i=fetchColors(t,r,o,l);const n=new THREE.MeshBasicMaterial({color:i.cell});let s=new THREE.Mesh(a,n);if(s.position.fromArray(e.posOffset[o][l]),s.userData.myInfo={myGrid:r,myCol:l,myRow:o,type:"cell",deleteFlag:t},scene.add(s),0!=i.edge){const a=new THREE.EdgesGeometry(s.geometry),n=new THREE.LineSegments(a,new THREE.LineBasicMaterial({color:i.edge}));n.position.fromArray(e.posOffset[o][l]),n.position.z=10,n.userData.myInfo={myGrid:r,myCol:l,myRow:o,type:"gridline",deleteFlag:t},scene.add(n),o>r.length/e.offSet.y&&(n.visible=!1)}o>r.length/e.offSet.y&&(s.visible=!1)}}computeDrawdown(e=this.threading.pattern,r=this.tieUp.pattern,t=this.treadling.pattern){let a=[],o=0;for(let l of t){let t=new Array(M.var.NUM_THREADS).fill(0),i=[];for(let e=0;e<l.length;e++)if(1===l[e])for(let t=0;t<r[e].length;t++)1===r[e][t]&&i.push(t);for(let r=0;r<M.var.NUM_THREADS;r++)for(let a of i)if(1===e[a][r]){t[r]=1;break}a.push(t);let n,s=0;if(o<=M.var.NUM_TREADLES){1==t[0]?(wPat+=" U ",wPat_print+=" U ",n=1):(wPat+=" O ",wPat_print+=" O ",n=0);for(let e=0;e<M.var.NUM_SHAFTS;e++)1==n&&1==t[e]||0==n&&0==t[e]||(1==n&&0==t[e]?(wPat=wPat+s+" O ",wPat_print=wPat_print+s+" O ",n=0,s=0):0==n&&1==t[e]&&(wPat=wPat+s+" U ",wPat_print=wPat_print+s+" U ",n=1,s=0)),s++;wPat=wPat+s+" REPEAT",wPat="<div>"+wPat+"</div>\n",wPat_print=wPat_print+s+" REPEAT\n"}o++}wPat+="REPEAT",wPat_print+="REPEAT",this.drawdownWarp.pattern=a,this.drawdownWeft.pattern=a;let l=this.checkSequentialRuns(10),i=100;l?this.drawdownCheckCount=0:this.drawdownCheckCount<i?(this.resetPattern(this.tieUp),this.caTieUpGrid(),this.computeDrawdown(),this.drawdownCheckCount++):console.warn(`reached Maximum drawdown check of ${i}`)}visualizeDrawdown(e=this.drawdownWarp){let r=e.pattern,t=(e.position.x,e.position.y,0),a=new THREE.PlaneBufferGeometry(M.var.cellSize,M.var.cellSize),o=.9999;a=new THREE.PlaneBufferGeometry(M.var.cellSize*this.drawdownWarp.offSet.x,M.var.cellSize*this.drawdownWarp.offSet.y);for(let e=0;e<r.length;e++)for(let l=0;l<M.var.NUM_THREADS;l++){let i,n;i=this.colorWarp.pattern[l],t=this.drawdownWarp.pattern[e][l];let s=Math.round(220*i.r),d=Math.round(220*i.g),c=Math.round(220*i.b);n=new THREE.Color(`rgb(${s}, ${d}, ${c})`);const h=new THREE.MeshBasicMaterial({color:i}),p=new THREE.Mesh(a,h);let g,v;if(p.position.fromArray(this.drawdownWarp.posOffset[e][l]),p.position.z=2*t,scene.add(p),M.var.drawEdges){const t=p.geometry.attributes.position.array;let a=t[1]+M.var.verticalSpacing;0!=e&&e!=Math.ceil((r.length-1)/M.var.verticalSpacing)||(a=.5);const i=new THREE.Vector3(t[0]*o,+a,t[2]).add(p.position),s=new THREE.Vector3(t[3]*o,+a,t[5]).add(p.position),d=new THREE.Vector3(t[6]*o,-a,t[8]).add(p.position),c=new THREE.Vector3(t[9]*o,-a,t[11]).add(p.position);1===r[e][l]&&(g=new THREE.Line((new THREE.BufferGeometry).setFromPoints([i,d]),new THREE.LineBasicMaterial({color:n})),v=new THREE.Line((new THREE.BufferGeometry).setFromPoints([c,s]),new THREE.LineBasicMaterial({color:n})),scene.add(g),scene.add(v))}e>r.length/this.drawdownWeft.offSet.y&&(p.visible=!1,M.var.drawEdges&&(g&&(g.visible=!1),v&&(v.visible=!1)))}a=new THREE.PlaneBufferGeometry(M.var.cellSize,M.var.cellSize);for(let e=0;e<r.length;e++)for(let o=0;o<M.var.NUM_THREADS;o++){let l,i;l=this.colorWeft.pattern[o],t=this.drawdownWeft.pattern[e][o];let n=Math.round(220*l.r),s=Math.round(220*l.g),d=Math.round(220*l.b);i=new THREE.Color(`rgb(${n}, ${s}, ${d})`);const c=new THREE.MeshBasicMaterial({color:l}),h=new THREE.Mesh(a,c);let p,g;if(h.position.fromArray(this.drawdownWeft.posOffset[o][e]),h.position.z=t,scene.add(h),M.var.drawEdges){const t=h.geometry.attributes.position.array,a=new THREE.Vector3(t[0],t[1],t[2]).add(h.position),l=new THREE.Vector3(t[3],t[4],t[5]).add(h.position),n=new THREE.Vector3(t[6],t[7],t[8]).add(h.position),s=new THREE.Vector3(t[9],t[10],t[11]).add(h.position);if(10===r[e][o]){}else p=new THREE.Line((new THREE.BufferGeometry).setFromPoints([a,l]),new THREE.LineBasicMaterial({color:i})),g=new THREE.Line((new THREE.BufferGeometry).setFromPoints([n,s]),new THREE.LineBasicMaterial({color:i})),scene.add(p),scene.add(g)}o>r.length/this.drawdownWeft.offSet.y&&(h.visible=!1,M.var.drawEdges&&(p&&(p.visible=!1),g&&(g.visible=!1)))}}removeDrawdown(){let e=[...scene.children];for(let r=0;r<e.length;r++){let t=e[r];void 0===t.userData.myInfo&&scene.remove(t)}}removeGrid(e=["none"]){Array.isArray(e)||(e=[e]);let r=[...scene.children];for(let t=0;t<r.length;t++){let a=r[t];try{e.includes(a.userData.myInfo.deleteFlag)&&scene.remove(a)}catch{}}console.log("removed grid")}addDrawdownText(){const e=document.createElement("div");e.id="drawdownText",e.innerHTML=wPat;const r=document.querySelector("canvas");r?r.insertAdjacentElement("afterend",e):console.error("Canvas not found. Make sure this function is called after the canvas has been added to the DOM.")}checkSequentialRuns(e=M.var.maxRun,r=this.drawdownWarp.pattern,t=!0){const a=r.length,o=r[0].length;for(let l=0;l<a;l++){let a=1;for(let i=1;i<o;i++)if(r[l][i]===r[l][i-1]){if(a++,a>=e)return t&&this.sequenceRepair(!1),!1}else a=1}for(let l=0;l<o;l++){let o=1;for(let i=1;i<a;i++)if(r[i][l]===r[i-1][l]){if(o++,o>=e)return t&&this.sequenceRepair(!1),!1}else o=1}return t&&this.sequenceRepair(!0),!0}sequenceRepair(e){e?(renderer.setClearColor(displayColors.background),M.var.passedLengthTest=!0):M.var.passedLengthTest=!1}}class CA{constructor(e,r,t,a){this.oldBoard=[],this.newBoard=[],this.on=[],this.genCount=0,this.gens=M.var.maxGen+1,this.seeds=[],this.COLS=t,this.ROWS=r,this.rule=e,this.scene=a,this.oldBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.newBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.seeds=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0))}reset(){this.oldBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.genCount=0}restart(){this.genCount=0,this.oldBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.newBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0));for(let e=0;e<this.ROWS;e++)for(let r=0;r<this.COLS;r++)1==this.seeds[e][r]&&(this.oldBoard[e][r]=1);this.seeds=Array(this.ROWS).fill(Array(this.COLS).fill(0)),this.genCount++}randomSeed(e){this.on[this.genCount]=[];let r=Math.floor(this.ROWS/2),t=Math.floor(this.COLS/2);this.seeds[r][t]=1,this.seeds[r+2][t+2]=1,this.seeds[r-2][t-2]=1;let a=rand();if(a<=.33)for(let a=0;a<e;a++){let e=Math.round(.33*this.ROWS),a=Math.floor(rand()*(2*e+1))-e+r,o=Math.floor(rand()*(2*e+1))-e+t;a<0||o<0||a>this.ROWS-1||o>this.COLS-1||(this.seeds[a][o]=1)}this.genCount++}generate(){this.on[this.genCount]=[];for(let e=0;e<this.ROWS;e++)for(let r=0;r<this.COLS;r++){let t=0;const a=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]];for(let o=0;o<a.length;o++){const[l,i]=a[o],n=e+l,s=r+i;n>=0&&n<this.ROWS&&s>=0&&s<this.COLS&&1===this.oldBoard[n][s]&&t++}1==this.oldBoard[e][r]&&(0==t&&(this.newBoard[e][r]=this.rule[0]),1==t&&(this.newBoard[e][r]=this.rule[1]),2==t&&(this.newBoard[e][r]=this.rule[2]),3==t&&(this.newBoard[e][r]=this.rule[3]),4==t&&(this.newBoard[e][r]=this.rule[4]),5==t&&(this.newBoard[e][r]=this.rule[5]),6==t&&(this.newBoard[e][r]=this.rule[6])),0==this.oldBoard[e][r]&&(0==t&&(this.newBoard[e][r]=this.rule[7]),1==t&&(this.newBoard[e][r]=this.rule[8]),2==t&&(this.newBoard[e][r]=this.rule[9]),3==t&&(this.newBoard[e][r]=this.rule[10]),4==t&&(this.newBoard[e][r]=this.rule[11]),5==t&&(this.newBoard[e][r]=this.rule[12]),6==t&&(this.newBoard[e][r]=this.rule[13]))}let e=this.oldBoard;this.oldBoard=this.newBoard,this.newBoard=e,this.genCount++}}init(),render(),document.addEventListener("keypress",function(e){"s"===e.key||"S"==e.key?saveLargeCanvas("Enlace",2400):"t"!==e.key&&"T"!=e.key||(M.var.textVisible=!M.var.textVisible,toggleText())});
///////////////////////////////////////////// // Enlace ///////////////////////////////////////////// // Aranda\Lasch // Jesse Bassett // Chris Lasch // 2/5/2024 function getColorFromLang(e){for(let r in colorNames)if(colorNames[r].eng===e)return r}function init(){scene=new THREE.Scene,renderer=new THREE.WebGLRenderer({antialias:!1}),renderer.setPixelRatio(devicePixelRatio);let e=document.getElementById("container");renderer.setClearColor(displayColors.background),e.appendChild(renderer.domElement),renderer.domElement.style.zIndex="-1",camera=new THREE.OrthographicCamera(-M.var.zoom,M.var.zoom,M.var.zoom,-M.var.zoom,1,1e3),camera.position.set(0,0,35),camera.lookAt(0,0,0),raycaster=new THREE.Raycaster,mouse=new THREE.Vector2,weave=new weavedraft,updateCamera(),createTableSnippet(formatTextforTable(),displayColors.ground),console.log(weave),onWindowResize(),window.addEventListener("resize",onWindowResize,!1)}function animate(){requestAnimationFrame(animate),render()}function render(){renderer.render(scene,camera)}function onWindowResize(){updateCamera(),styleSquareDiv(),styleTextUpdate(),render()}function updateCamera(){let e=new THREE.Box3,r=e.getSize(new THREE.Vector3),t=e.getCenter(new THREE.Vector3);r=new THREE.Vector3(58,59,10),t=new THREE.Vector3(1.5,-9,5),DIM.x=DIM.y=Math.min(window.innerWidth,window.innerHeight),renderer.setSize(DIM.x,DIM.y);let a,o=DIM.x/DIM.y,l=r.x/r.y,i=1.4;l>o?(a=r.x/i,camera.right=a,camera.top=a/o,camera.bottom=-a/o):(a=r.y/i,camera.top=a,camera.bottom=-a,camera.left=-a*o,camera.right=a*o),camera.position.set(t.x,t.y,35),camera.lookAt(t),camera.updateProjectionMatrix()}function saveCanvas(e=M.seed){let r=e+".png",t=renderer.domElement.toDataURL(),a=document.createElement("a");a.href=t,a.download=r,a.target="_blank",document.body.appendChild(a),a.click(),document.body.removeChild(a),console.log("saved Canvas")}function saveLargeCanvas(e,r=2400){let t=document.createElement("canvas");t.width=r,t.height=r;let a=new THREE.WebGLRenderer({canvas:t,antialias:!1});a.setPixelRatio(devicePixelRatio),a.setPixelRatio(2),a.setSize(r,r),a.setClearColor(displayColors.background),a.render(scene,camera);let o=t.toDataURL("image/png"),l=document.createElement("a");l.href=o,l.download=e+".png",l.target="_blank",document.body.appendChild(l),l.click(),document.body.removeChild(l),a.dispose(),console.log("Saved large canvas")}function saveText(e=M.seed){var r=wPat_print,t=new Blob([r],{type:"text/plain"}),a=URL.createObjectURL(t),o=document.createElement("a");o.href=a,o.download=e+".txt",document.body.appendChild(o),o.click(),document.body.removeChild(o),console.log("Saved Image ")}function createText(){const e=document.querySelector("canvas"),r=e.parentElement;let t=document.getElementById("overlay");t||(t=document.createElement("div"),t.id="overlay",t.style.position="absolute",t.style.top=e.offsetTop+"px",t.style.left=e.offsetLeft+"px",t.style.width=e.offsetWidth+"px",t.style.height=e.offsetHeight+"px",r.appendChild(t));const a=document.createElement("div");a.id="table-wrapper";let o=["Pattern:","Colors:","Palette:","Bindings:","Spacing:","Instructions:"],l=0;const i=document.createElement("table");for(let e=0;e<3;e++){const e=document.createElement("tr");for(let r=0;r<2;r++){const r=document.createElement("td");r.textContent=`${o[l]} ${l}`,e.appendChild(r),l++}i.appendChild(e)}i.style.width="100%",i.style.height="100%",i.style.borderCollapse="collapse",a.appendChild(i),t.appendChild(a)}function formatJson(){delete M.var.warpColors,delete M.var.weftColors,delete M.var.theRules,delete M.var.activeColor,delete M.var.inactiveColor}function saveJson(e=M.seed){let r=e+".json",t=M;downloadFile(t,r),console.log("saved Json!")}function downloadFile(e,r){var t=r.split("."),a=t[t.length-1],o="json"==a?new Blob([JSON.stringify(e,null,2).replace(/\\n/g,"\n").replace(/\\"/g,'"')],{type:"application/json"}):new Blob([Papa.unparse(e)],{type:"text/plain"}),l=document.createElement("a");document.body.appendChild(l),l.download=r,l.href=window.URL.createObjectURL(o),l.click(),l.parentNode.removeChild(l)}function addGUI(){}function rand(e=0,r=1){return e+(r-e)*R.random_dec()}function rInt(e,r){return e<r?Math.floor(rand(e,r+1)):Math.floor(rand(r,e+1))}function randChoice(e){return e[rInt(0,e.length-1)]}function rWeightedItems(e,r){let t={select:rand(),index:null,sum:0,mode:null,tempMin:0,tempMax:0};for(let e=0;e<r.length;e++)t.sum+=r[e];for(let a=0;a<e.length;a++)t.tempMax=r[a]/t.sum+t.tempMin,t.tempMin<=t.select&&t.select<t.tempMax&&0!=r[a]&&(t.index=a),t.tempMin+=r[a]/t.sum;return e[t.index]}function genTokenData(e=0){let r={},t="0x";for(var a=0;a<64;a++)t+=Math.floor(16*seedRand()).toString(16);return r.hash=t,r.tokenId=(1e6*e+Math.floor(1e3*seedRand())).toString(),r}function sfc32(e,r,t,a){return function(){e>>>=0,r>>>=0,t>>>=0,a>>>=0;var o=e+r|0;return e=r^r>>>9,r=t+(t<<3)|0,t=t<<21|t>>>11,a=a+1|0,o=o+a|0,t=t+o|0,(o>>>0)/4294967296}}function cyrb128(e){let r=1779033703,t=3144134277,a=1013904242,o=2773480762;for(let l,i=0;i<e.length;i++)l=e.charCodeAt(i),r=t^Math.imul(r^l,597399067),t=a^Math.imul(t^l,2869860233),a=o^Math.imul(a^l,951274213),o=r^Math.imul(o^l,2716044179);return r=Math.imul(a^r>>>18,597399067),t=Math.imul(o^t>>>22,2869860233),a=Math.imul(r^a>>>17,951274213),o=Math.imul(t^o>>>19,2716044179),[(r^t^a^o)>>>0,(t^r)>>>0,(a^r)>>>0,(o^r)>>>0]}function triangleWave(e,r,t,a){if(t<=0)throw new Error("Height must be positive");const o=(e+a)*r,l=2*t-2,i=o%l;return t%2==0?i<t?i:i<l-t?t-1:i-l:i<t?i:l-i}function shuffleArray(e){for(let r=e.length-1;r>0;r--){const t=Math.floor(rand(0,r)),a=e[r];e[r]=e[t],e[t]=a}return e}function shuffleArrayRandom(e){for(let r=e.length-1;r>0;r--){const t=Math.floor(Math.random()*r),a=e[r];e[r]=e[t],e[t]=a}return e}function fetchColors(e,r,t,a){let o,l,i=M.var.displayMode;if("Original"==i)o=1===r[t][a]?M.var.activeColor:M.var.inactiveColor,l=M.var.activeColor;else if("Inverse"==i||"Grid"==i)1===r[t][a]?(o=displayColors[e].active.cell,l=displayColors[e].active.edge):(o=displayColors[e].inactive.cell,l=displayColors[e].inactive.edge);else if("Weave Colors"==i)if("tieUp"==e)1===r[t][a]?(o=displayColors[e].active.cell,l=displayColors[e].active.edge):(o=displayColors[e].inactive.cell,l=displayColors[e].inactive.edge);else{let i;"threading"==e?i=a%displayColors[e].active.cell.length:"treadling"==e&&(i=t%displayColors[e].active.cell.length);let n=displayColors[e].active.cell[i];1===r[t][a]?(o=n,l=n==displayColors.background&&displayColors.tieUp.inactive.cell):(o=displayColors[e].inactive.cell,l=displayColors[e].inactive.edge)}return{cell:o,edge:l}}function toggleText(){"block"==squareDiv.style.display?squareDiv.style.display="none":squareDiv.style.display="block"}function styleSquareDiv(){let e=DIM.x;M.var.textVisible?squareDiv.style.display="block":squareDiv.style.display="none",squareDiv.style.position="absolute",squareDiv.style.height=e+"px",squareDiv.style.width=e+"px",squareDiv.style.left="50%",squareDiv.style.top="50%",squareDiv.style.transform="translate(-50%, -50%)",styleInnerDiv()}function styleInnerDiv(){innerDiv.style.position="absolute",innerDiv.style.bottom="0",innerDiv.style.width="68.5%",innerDiv.style.height="14.8%",innerDiv.style.left="50%",innerDiv.style.transform="translateX(-50%)",innerDiv.style.zIndex="5"}function createTableSnippet(e=["","","","",""],r="black",t=innerDiv){let a=["Pattern: ","Warp Colors: ","Palette: ","Weft Colors: ","Spacing: ","Bindings: "];for(let r=0;r<e.length;r++)a[r]+=e[r];r instanceof THREE.Color&&(r=r.getHexString());let o=document.createElement("table"),l=document.createElement("tbody");o.appendChild(l),o.style.width="100%",o.style.tableLayout="fixed",o.style.zIndex="5";var i=[[a[0],a[1]],[a[2],a[3]],[a[4],a[5]]];i.forEach(function(e,t){let a=document.createElement("tr");e.forEach(function(e){let t=document.createElement("td");t.innerText=e,t.style.color="#"+r,t.style.whiteSpace="nowrap",a.appendChild(t),tabelCells.push(t)}),l.appendChild(a)}),t?t.appendChild(o):console.error("Parent element not found.")}function styleTextUpdate(){let e;e=DIM.x>1e3?"18px":DIM.x>600?"16px":DIM.x>450?"14px":"12px",tabelCells.forEach(function(r){r.style.fontSize=e,DIM.x<300?r.style.display="none":r.style.display="table-cell"})}function formatTextforTable(){M.var.colorWarpNames,M.var.colorWeftNames;let e="",r="",t=[];for(let r of M.var.colorWarpNames)e+=`${r}, `;e=e.slice(0,-1),e=e.slice(0,-1);for(let e of M.var.colorWeftNames)r+=`${e}, `;return r=r.slice(0,-1),r=r.slice(0,-1),t[0]=M.var.preset,t[1]=e,t[2]=M.var.colorSelectName,t[3]=r,t[4]=M.var.verticalSpacingType,t[5]=displayColors.backgroundName,t}let credits=shuffleArrayRandom(["Benjamin Aranda","Chris Lasch","Jesse Bassett","Joaquin Bonifaz"]);console.log("Enlace by ArandaLasch"),console.log(`${credits[0]}, ${credits[1]}, ${credits[2]}, ${credits[3]}`),console.log("In collaboration with Trame and Maison Louis Drucker "),console.log("");class Random{constructor(){this.useA=!1;let e=function(e){let r=parseInt(e.substr(0,8),16),t=parseInt(e.substr(8,8),16),a=parseInt(e.substr(16,8),16),o=parseInt(e.substr(24,8),16);return function(){r|=0,t|=0,a|=0,o|=0;let e=(r+t|0)+o|0;return o=o+1|0,r=t^t>>>9,t=a+(a<<3)|0,a=a<<21|a>>>11,a=a+e|0,(e>>>0)/4294967296}};this.prngA=new e(tokenData.hash.substr(2,32)),this.prngB=new e(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_bool(e){return this.random_dec()<e}random_num(e,r){return e+(r-e)*this.random_dec()}random_int(e,r){return Math.floor(this.random_num(e,r+1))}}R=new Random;let gui,newDiv=document.createElement("div");newDiv.id="container",newDiv.style.display="inline-block",newDiv.style.margin="0",newDiv.style.width="100%",newDiv.style.height="100%",document.body.appendChild(newDiv),document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden";let renderer,camera,scene,raycaster,mouse,myCa,devicePixelRatio=window.devicePixelRatio||1,wPat="",wPat_print="",DIM={x:Math.min(window.innerWidth,window.innerHeight)};DIM.y=DIM.x;let tabelCells=[],squareDiv=document.createElement("div"),innerDiv=document.createElement("div");squareDiv.appendChild(innerDiv),newDiv.appendChild(squareDiv);let weave,displayColors={treadling:{active:{cell:16777215,edge:0},inactive:{cell:16777215,edge:0}},tieUp:{active:{cell:16777215,edge:0},inactive:{cell:16777215,edge:0}},threading:{active:{cell:16777215,edge:0},inactive:{cell:16777215,edge:0}},background:0,backgroundName:"White"},druckerSatinColors={oliveGreen:3686464,tenderGreen:5335383,appleGreen:10141309,emeraldGreen:1206126,purpleMaroon:4859707,carminRed:6041134,scarletRed:10625597,rubyRed:5975353,terracotta:8929589,pink:10966369,lightPink:12019057,black:2171945,grey:6909033,blueGrey:12566711,white:14870756,royalBlue:2243701,ultraMarine:1648699,lavenderBlue:3489100,lagoonBlue:30409,softBlue:5604238,waterGreen:10663343,chocolate:3880760,weatheredGold:6246469,beige:10060646,taupe:10390910,ivory:14339747,orange:13128752,peach:14527854,yellowTumeric:13080618,brightYellow:14660864},colorNames={oliveGreen:{eng:"Olive Green",fr:"Vert Olive"},tenderGreen:{eng:"Tender Green",fr:"Vert Tendre"},appleGreen:{eng:"Apple Green",fr:"Vert Pomme"},emeraldGreen:{eng:"Emerald Green",fr:"Vert Emeraude"},purpleMaroon:{eng:"Purple Maroon",fr:"Bordeaux Violet"},carminRed:{eng:"Carmin Red",fr:"Rouge Carmin"},scarletRed:{eng:"Scarlet Red",fr:"Rouge Ecarlate"},rubyRed:{eng:"Ruby Red",fr:"Rouge Rubis"},terracotta:{eng:"Terracotta",fr:"Terracotta"},pink:{eng:"Pink",fr:"Rose"},lightPink:{eng:"Light Pink",fr:"Rose Pastel"},black:{eng:"Black",fr:"Noir"},grey:{eng:"Grey",fr:"Gris"},blueGrey:{eng:"Blue Grey",fr:"Gris Bleute"},white:{eng:"White",fr:"Blanc"},royalBlue:{eng:"Royal Blue",fr:"Bleu Royal"},ultraMarine:{eng:"Ultra Marine",fr:"Bleu Outrener"},lavenderBlue:{eng:"Lavender Blue",fr:"Bleu Lavande"},lagoonBlue:{eng:"Lagoon Blue",fr:"Bleu Lagon"},softBlue:{eng:"Soft Blue",fr:"Bleu Doux"},waterGreen:{eng:"Water Green",fr:"Vert D'Eau"},chocolate:{eng:"Chocolate",fr:"Chocolat"},weatheredGold:{eng:"Weathered Gold",fr:"Or Patine"},beige:{eng:"Beige",fr:"Beige"},taupe:{eng:"Taupe",fr:"Taupe"},ivory:{eng:"Ivory",fr:"Ivoire"},orange:{eng:"Orange",fr:"Orange"},peach:{eng:"Peach",fr:"Peche"},yellowTumeric:{eng:"Yellow Tumeric",fr:"Jaune Curcuma"},brightYellow:{eng:"BrightYellow",fr:"Jaune Vif"}},colorCull=[["peach","brightYellow"],["rubyRed","purpleMaroon"],["tenderGreen","weatheredGold"],["royalBlue","lavenderBlue"],["oliveGreen","lavenderBlue"],["chocolate","oliveGreen"],["carminRed","rubyRed"]],palettes={2:[{name:"Light",p:1,arr:["white","scarletRed"]},{name:"Dark",p:1,arr:["black","purpleMaroon"]},{name:"Warm",p:1,arr:["yellowTumeric","lagoonBlue"]},{name:"Warm",p:1,arr:["scarletRed","softBlue"]},{name:"Warm",p:1,arr:["terracotta","beige"]},{name:"Cool",p:1,arr:["waterGreen","black"]},{name:"Cool",p:1,arr:["waterGreen","royalBlue"]},{name:"Cool",p:1,arr:["emeraldGreen","waterGreen"]},{name:"Mix",p:1,arr:["oliveGreen","taupe"]},{name:"Mix",p:1,arr:["white","black"]},{name:"Mix",p:1,arr:["softBlue","rubyRed"]},{name:"Cool",p:1,arr:["tenderGreen","white"]},{name:"Mix",p:1,arr:["black","ivory"]},{name:"Mix",p:1,arr:["ultraMarine","ivory"]},{name:"Dark",p:1,arr:["black","weatheredGold"]},{name:"Mix",p:1,arr:["oliveGreen","lightPink"]},{name:"Warm",p:1,arr:["orange","peach"]},{name:"Cool",p:1,arr:["lagoonBlue","orange"]},{name:"Cool",p:1,arr:["waterGreen","softBlue"]},{name:"Light",p:1,arr:["grey","ivory"]},{name:"Light",p:1,arr:["pink","ivory"]},{name:"Light",p:1,arr:["white","grey"]}],3:[{name:"Light",p:1,arr:["white","weatheredGold","grey"]},{name:"Dark",p:1,arr:["carminRed","lavenderBlue","emeraldGreen"]},{name:"Warm",p:1,arr:["brightYellow","waterGreen","black"]},{name:"Warm",p:1,arr:["ultraMarine","orange","tenderGreen"]},{name:"Cool",p:1,arr:["royalBlue","taupe","blueGrey"]},{name:"Mix",p:1,arr:["terracotta","appleGreen","black"]},{name:"Mix",p:1,arr:["taupe","pink","emeraldGreen"]},{name:"Mix",p:1,arr:["oliveGreen","ivory","grey"]},{name:"Mix",p:1,arr:["oliveGreen","lightPink","appleGreen"]},{name:"Warm",p:1,arr:["oliveGreen","yellowTumeric","beige"]}],4:[{name:"Light",p:1,arr:["white","softBlue","emeraldGreen","scarletRed"]},{name:"Light",p:1,arr:["lagoonBlue","royalBlue","orange","white"]},{name:"Light",p:1,arr:["terracotta","ultraMarine","lightPink","lagoonBlue"]},{name:"Dark",p:1,arr:["weatheredGold","rubyRed","ultraMarine","lagoonBlue"]},{name:"Warm",p:1,arr:["ivory","taupe","blueGrey","appleGreen"]},{name:"Warm",p:1,arr:["scarletRed","rubyRed","purpleMaroon","white"]},{name:"Cool",p:1,arr:["waterGreen","tenderGreen","lightPink","purpleMaroon"]},{name:"Cool",p:1,arr:["lagoonBlue","ivory","brightYellow","purpleMaroon"]},{name:"Mix",p:1,arr:["black","weatheredGold","grey","appleGreen"]},{name:"Mix",p:1,arr:["emeraldGreen","scarletRed","taupe","chocolate"]},{name:"Mix",p:1,arr:["oliveGreen","waterGreen","beige","scarletRed"]},{name:"Mix",p:1,arr:["grey","carminRed","rubyRed","peach"]},{name:"Cool",p:1,arr:["tenderGreen","ivory","weatheredGold","oliveGreen"]},{name:"Warm",p:1,arr:["rubyRed","terracotta","yellowTumeric","peach"]},{name:"Mix",p:1,arr:["tenderGreen","terracotta","ivory","taupe"]}],5:[{name:"Light",p:1,arr:["waterGreen","white","beige","terracotta","ultraMarine"]},{name:"Dark",p:1,arr:["chocolate","grey","blueGrey","ivory","weatheredGold"]},{name:"Warm",p:1,arr:["peach","orange","tenderGreen","scarletRed","waterGreen"]},{name:"Warm",p:1,arr:["terracotta","pink","scarletRed","ivory","grey"]},{name:"Red",p:1,arr:["grey","orange","beige","ultraMarine","weatheredGold"]},{name:"Cool",p:1,arr:["royalBlue","ultraMarine","lavenderBlue","softBlue","waterGreen"]},{name:"Mix",p:1,arr:["emeraldGreen","scarletRed","taupe","chocolate","oliveGreen"]},{name:"Mix",p:1,arr:["oliveGreen","waterGreen","beige","scarletRed","lightPink"]},{name:"Cool",p:1,arr:["tenderGreen","ivory","weatheredGold","oliveGreen","lavenderBlue"]},{name:"Warm",p:1,arr:["rubyRed","terracotta","yellowTumeric","peach","pink"]},{name:"Mix",p:1,arr:["tenderGreen","terracotta","ivory","taupe","weatheredGold"]}]},spacingTypes=["Standard","Tight","Close"],threadingPatternTypes=["twill","triWave","vPattern","rand"],treadlingPatternTypes=["twill","triWave","vPattern","rand"],colorPalettes=["random","analogous","fromArray","fromSelected"],presetTypes=["None","Duochrome","Figure","Linear","Field"],colorArrayNames=["Red","Yellow","Blue","Mix","Light","Dark"],colorSelectNames=["Warm","Cool","Mix","Light","Dark"],layouts=["Original","Tight"],displayModes=["Original","Inverse","Grid","Weave Colors"],M={var:{}};if(M.var={zoom:30,cellSize:1,activeColor:new THREE.Color(9803157),inactiveColor:new THREE.Color(15658734),backgroundColor:new THREE.Color(15658734),warpColors:[],weftColors:[],theRules:[0,0,0,0,0,0,0,0,1,0,0,0,0,0],maxGen:2,NUM_SHAFTS:8,NUM_THREADS:50,NUM_TREADLES:0,NUM_PICKS:0,startX:-27,startY:22,verticalSpacingType:rWeightedItems(spacingTypes,[1,2,0]),verticalSpacing:rWeightedItems([1.25,1,1],[1,2,0]),threadingPattern:rWeightedItems(threadingPatternTypes,[1,1,0,.1]),threadingSlope:rWeightedItems([.5,1,2],[1,1,1]),threadingOffset:1,threadingTranslate:0,threadingMirrorPattern:!1,threadingMirrorColor:!1,treadlingPattern:rWeightedItems(treadlingPatternTypes,[1,1,0,.1]),treadlingSlope:rWeightedItems([.5,1,2],[1,1,1]),treadlingOffset:1,treadlingTranslate:0,treadlingMirrorPattern:!1,treadlingMirrorColor:!1,colorSelectName:rWeightedItems(colorSelectNames,[1,1,1,1,1]),colorArrayName:rWeightedItems(colorArrayNames,[1,1,1,1,1,1]),colorPalette:rWeightedItems(colorPalettes,[0,0,0,1]),colorWeftCount:rWeightedItems([1,2,3],[1,1,1]),colorWarpCount:rWeightedItems([1,2,3],[1,1,1]),colorWarp:[],colorWeft:[],colorWarpNames:[],colorWeftNames:[],colorMaterial:rWeightedItems(["Satin","Glossy"],[1,0]),drawEdges:!1,passedLengthTest:!0,maxRun:8,preset:rWeightedItems(presetTypes,[0,30,15,20,35]),displayMode:rWeightedItems(displayModes,[0,35,55,10]),layout:rWeightedItems(layouts,[0,1]),threadingPosX:0,threadingPosY:0,tieUpPosX:0,tieUpPosY:0,treadlingPosX:0,treadlingPosY:0,colorWarpPosX:0,colorWarpPosY:0,colorWeftPosX:0,colorWeftPosY:0,drawdownPosX:0,drawdownPosY:0,colorWarpVisible:!0,colorWeftVisible:!1,textVisible:!1},M.var.NUM_TREADLES=M.var.NUM_SHAFTS,M.var.NUM_PICKS=M.var.NUM_THREADS,"Duochrome"==M.var.preset?(M.var.colorWeftCount=1,M.var.colorWarpCount=1):"Figure"==M.var.preset?(R.random_bool(-1)?(M.var.colorWeftCount=1,M.var.colorWarpCount=rWeightedItems([2,3],[1.25,1])):(M.var.colorWeftCount=rWeightedItems([2,3],[1,0]),M.var.colorWarpCount=1),M.var.threadingPattern=rWeightedItems(["twill","triWave"],[1,3]),M.var.threadingSlope=rWeightedItems([.5,1],[1.5,.8]),M.var.treadlingPattern=rWeightedItems(["twill","triWave"],[1,3]),M.var.treadlingSlope=rWeightedItems([.5,1],[1.5,.8])):"Linear"==M.var.preset?R.random_bool(-1)?(M.var.colorWeftCount=1,M.var.colorWarpCount=rWeightedItems([2,3],[1.25,1]),M.var.treadlingPattern=rWeightedItems(["twill","triWave"],[1,1]),M.var.treadlingSlope=rWeightedItems([1,2],[.5,1.5]),M.var.verticalSpacingType=rWeightedItems(spacingTypes,[1.1,.5,0])):(M.var.colorWeftCount=rWeightedItems([2,3],[1,1.5]),M.var.colorWarpCount=1,M.var.verticalSpacingType=rWeightedItems(spacingTypes,[1.2,.5,0]),M.var.threadingPattern=rWeightedItems(["twill","triWave"],[1,1]),M.var.threadingSlope=2,M.var.treadlingPattern=rWeightedItems(["twill","triWave"],[1,1]),M.var.treadlingSlope=rWeightedItems([1,2],[.5,1.5])):"Field"==M.var.preset&&(M.var.colorWarpCount=rWeightedItems([2,3],[1.25,1]),M.var.colorWeftCount=rWeightedItems([2,3],[1.25,1]),M.var.threadingPattern=rWeightedItems(["twill","triWave","rand"],[1,1,1]),M.var.threadingSlope=rWeightedItems([.5,1,2],[1,1,1]),M.var.treadlingPattern=rWeightedItems(["twill","triWave","rand"],[1,1,1]),M.var.treadlingSlope=rWeightedItems([.5,1,2],[1,1,1]),M.var.colorWarpCount+M.var.colorWeftCount==6&&M.var.colorWeftCount--),"Close"==M.var.verticalSpacingType?M.var.verticalSpacing=1:"Tight"==M.var.verticalSpacingType?M.var.verticalSpacing=1.25:"Standard"==M.var.verticalSpacingType&&(M.var.verticalSpacing=1.5),"Original"==M.var.layout)M.var.threadingPosX=0,M.var.threadingPosY=0,M.var.tieUpPosX=0,M.var.tieUpPosY=0,M.var.treadlingPosX=0,M.var.treadlingPosY=0,M.var.colorWarpPosX=0,M.var.colorWarpPosY=0,M.var.colorWeftPosX=0,M.var.colorWeftPosY=0,M.var.drawdownPosX=0,M.var.drawdownPosY=0,M.var.colorWarpVisible=!0,M.var.colorWeftVisible=!0;else if("Tight"==M.var.layout){let e=2,r=0;M.var.threadingPosX=0,M.var.threadingPosY=-e,M.var.tieUpPosX=-e,M.var.tieUpPosY=-e,M.var.treadlingPosX=-e+r,M.var.treadlingPosY=0,M.var.colorWarpPosX=0,M.var.colorWarpPosY=-e-1,M.var.colorWeftPosX=-e-2+r,M.var.colorWeftPosY=0,M.var.drawdownPosX=r,M.var.drawdownPosY=0,M.var.colorWarpVisible=!1,M.var.colorWeftVisible=!1}console.log("M",M);class squareGrid{constructor(e,r,t,a,o,l,i){this.name=e,this.position=new THREE.Vector2(r,t),this.size=new THREE.Vector2(a,o),this.length=a*o,this.pattern=[[]],this.mesh=[[]],this.posOffset=[[]],this.offSet={x:l,y:i}}}class weavedraft{constructor(){this.threading=new squareGrid("threading",M.var.startX+M.var.threadingPosX,M.var.startY+M.var.threadingPosY,M.var.NUM_SHAFTS,M.var.NUM_THREADS,1,1),this.tieUp=new squareGrid("tieUp",M.var.NUM_THREADS*M.var.cellSize+2+M.var.startX+M.var.tieUpPosX,M.var.startY+M.var.tieUpPosY,M.var.NUM_SHAFTS,M.var.NUM_TREADLES,1,1),this.treadling=new squareGrid("treadling",M.var.NUM_THREADS*M.var.cellSize+2+M.var.startX+M.var.treadlingPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.treadlingPosY,M.var.NUM_PICKS,M.var.NUM_TREADLES,1,M.var.verticalSpacing),this.colorWarp=new squareGrid("colorWarp",M.var.startX+M.var.colorWarpPosX,M.var.startY+2+M.var.colorWarpPosY,1,M.var.NUM_THREADS,1,1),this.colorWeft=new squareGrid("colorWeft",M.var.NUM_THREADS+2+M.var.NUM_TREADLES+2+M.var.startX+M.var.colorWeftPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.colorWeftPosY,M.var.NUM_PICKS,1,1,M.var.verticalSpacing),this.drawdownWarp=new squareGrid("drawdownWarp",M.var.startX+M.var.drawdownPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.drawdownPosY,M.var.NUM_PICKS,M.var.NUM_PICKS,1,M.var.verticalSpacing),this.drawdownWeft=new squareGrid("drawdownWeft",M.var.startX+M.var.drawdownPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.drawdownPosY,M.var.NUM_PICKS,M.var.NUM_PICKS,1,M.var.verticalSpacing),this.drawdownCheckCount=0,this.resetPattern(this.threading),this.resetPattern(this.tieUp),this.resetPattern(this.treadling),this.managePattern(),this.getColorGridS(),this.getGoodDisplayColors(),this.offsetPattern(this.threading),this.offsetPattern(this.tieUp),this.offsetPattern(this.treadling),this.offsetPattern(this.colorWarp),this.offsetPattern(this.colorWeft),this.offsetPattern(this.drawdownWarp),this.offsetPattern(this.drawdownWeft),this.theRules=M.var.theRules,this.caTieUpGrid(),this.visualizeGrid(this.threading),this.visualizeGrid(this.tieUp),this.visualizeGrid(this.treadling),this.visualizeColorGrids(),this.computeDrawdown(),this.visualizeDrawdown()}managePattern(){"twill"==M.var.t
Enlace merges digital art with traditional cane weaving to craft physical objects from generative outputs. Each generative token is a piece of digital art and a set of instructions which can be used by the collector to create a unique chair or a woven canvas by Maison Louis Drucker, the historic Parisian chair manufacturer. The term "Enlace" denotes linking or intertwining in English and an embrace in French, emphasizing the project's aim to unite algorithmic code with the timeless human craft of weaving. Visually expressed through the format of the weaving draft, Enlace reduces its visual language, offering minimal instructions for creating woven pieces. It encodes potential rather than final product, providing the necessary instructions for crafting a woven chair or canvas, blending contemporary technology with traditional craftsmanship. By Aranda\Lasch in collaboration with Trame and Maison Louis Drucker. 's' to save image 't' to display text
ng),this.visualizeColorGrids(),this.computeDrawdown(),this.visualizeDrawdown()}managePattern(){"twill"==M.var.threadingPattern?this.twillPattern(this.threading):"triWave"==M.var.threadingPattern?this.triWavePattern(this.threading):"vPattern"==M.var.threadingPattern?this.vPattern(this.threading):"rand"==M.var.threadingPattern&&this.randPattern(this.threading),"twill"==M.var.treadlingPattern?this.twillPattern(this.treadling):"triWave"==M.var.treadlingPattern?this.triWavePattern(this.treadling):"vPattern"==M.var.treadlingPattern?this.vPattern(this.treadling):"rand"==M.var.treadlingPattern&&this.randPattern(this.treadling)}resetPattern(e){const r=e.size.x,t=e.size.y;let a=[];for(let e=0;e<r;e++){let e=[];for(let r=0;r<t;r++)e.push(0);a.push(e)}e.pattern=a,e.mesh=[...a]}getColorGridS(e=M.var.colorWarpCount,r=M.var.colorWeftCount,t=M.var.colorPalette,a="eng"){this.colorWarp.palette=[],this.colorWarp.pattern=[],this.colorWarp.count=e,this.colorWeft.palette=[],this.colorWeft.pattern=[],this.colorWeft.count=r;let o=druckerSatinColors,l=[],i=e+r;l=this.pickSelectedColors(o,i),console.log("selectedColors",l);let n,s=0;for(let e=0;e<this.colorWarp.count;e++)n=l[s],this.colorWarp.palette.push(n.color),M.var.colorWarpNames.push(colorNames[n.name][a]),s++;for(let e=0;e<this.colorWeft.count;e++)n=l[s],this.colorWeft.palette.push(n.color),M.var.colorWeftNames.push(colorNames[n.name][a]),s++;M.var.colorWarp=this.colorWarp.palette,M.var.colorWeft=this.colorWeft.palette;let d=0;for(let e=0;e<this.colorWarp.length;e++)this.colorWarp.pattern.push(this.colorWarp.palette[d]),d++,d==this.colorWarp.palette.length&&(d=0);let c=0;for(let e=0;e<this.colorWeft.length;e++)this.colorWeft.pattern.push(this.colorWeft.palette[c]),c++,c==this.colorWeft.palette.length&&(c=0)}getdisplayColors(){if("Original"==M.var.displayMode)displayColors.treadling.active.cell=M.var.activeColor,displayColors.treadling.active.edge=M.var.activeColor,displayColors.treadling.inactive.cell=M.var.inactiveColor,displayColors.treadling.inactive.edge=M.var.activeColor,displayColors.tieUp.active.cell=M.var.activeColor,displayColors.tieUp.active.edge=M.var.activeColor,displayColors.tieUp.inactive.cell=M.var.inactiveColor,displayColors.tieUp.inactive.edge=M.var.activeColor,displayColors.threading.active.cell=M.var.activeColor,displayColors.threading.active.edge=M.var.activeColor,displayColors.threading.inactive.cell=M.var.inactiveColor,displayColors.threading.inactive.edge=M.var.activeColor,displayColors.background=M.var.backgroundColor,displayColors.solid=M.var.activeColor,displayColors.ground=M.var.inactiveColor;else if("Inverse"==M.var.displayMode){let e,r,t=16711935,a=16711680;1==this.colorWeft.palette.length&&this.colorWarp.palette.length>=2?(r=0,e=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),t=this.colorWarp.palette[r],a=this.colorWeft.palette[e],displayColors.backgroundName=M.var.colorWarpNames[r]):(r=0,e=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),t=this.colorWeft.palette[r],a=this.colorWarp.palette[e],displayColors.backgroundName=M.var.colorWeftNames[r]),displayColors.treadling.active.cell=a,displayColors.treadling.active.edge=!1,displayColors.treadling.inactive.cell=t,displayColors.treadling.inactive.edge=!1,displayColors.tieUp.active.cell=a,displayColors.tieUp.active.edge=!1,displayColors.tieUp.inactive.cell=t,displayColors.tieUp.inactive.edge=!1,displayColors.threading.active.cell=a,displayColors.threading.active.edge=!1,displayColors.threading.inactive.cell=t,displayColors.threading.inactive.edge=!1,displayColors.background=t,displayColors.solid=t,displayColors.ground=a}else if("Grid"==M.var.displayMode){let e,r,t=16711935,a=16711680;1==this.colorWeft.palette.length&&this.colorWarp.palette.length>=2?(r=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),t=this.colorWarp.palette[r],a=this.colorWeft.palette[e],displayColors.backgroundName=M.var.colorWarpNames[r]):(r=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),t=this.colorWeft.palette[r],a=this.colorWarp.palette[e],displayColors.backgroundName=M.var.colorWeftNames[r]),displayColors.treadling.active.cell=t,displayColors.treadling.active.edge=t,displayColors.treadling.inactive.cell=a,displayColors.treadling.inactive.edge=t,displayColors.tieUp.active.cell=t,displayColors.tieUp.active.edge=t,displayColors.tieUp.inactive.cell=a,displayColors.tieUp.inactive.edge=t,displayColors.threading.active.cell=t,displayColors.threading.active.edge=t,displayColors.threading.inactive.cell=a,displayColors.threading.inactive.edge=t,displayColors.background=t,displayColors.solid=t,displayColors.ground=a}else if("Weave Colors"==M.var.displayMode){let e,r,t=16711935,a=16711680;1==this.colorWeft.palette.length&&this.colorWarp.palette.length>=2?(r=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),t=this.colorWarp.palette[r],a=this.colorWeft.palette[e],displayColors.backgroundName=M.var.colorWarpNames[r]):(r=randChoice(Array.from({length:this.colorWeft.palette.length},(e,r)=>r)),e=randChoice(Array.from({length:this.colorWarp.palette.length},(e,r)=>r)),t=this.colorWeft.palette[r],a=this.colorWarp.palette[e],displayColors.backgroundName=M.var.colorWeftNames[r]);let o=this.colorWarp.palette,l=this.colorWeft.palette;displayColors.treadling.active.cell=l,displayColors.treadling.active.edge=!1,displayColors.treadling.inactive.cell=t,displayColors.treadling.inactive.edge=!1,displayColors.tieUp.active.cell=t,displayColors.tieUp.active.edge=!1,displayColors.tieUp.inactive.cell=a,displayColors.tieUp.inactive.edge=!1,displayColors.threading.active.cell=o,displayColors.threading.active.edge=!1,displayColors.threading.inactive.cell=t,displayColors.threading.inactive.edge=!1,displayColors.background=t,displayColors.solid=t,displayColors.ground=a}renderer.setClearColor(displayColors.background)}visualizeColorGrids(){let e=new THREE.PlaneGeometry(M.var.cellSize,M.var.cellSize);for(let r=0;r<this.colorWarp.length;r++){const t=new THREE.MeshBasicMaterial({color:this.colorWarp.pattern[r]});let a=new THREE.Mesh(e,t);a.position.fromArray(this.colorWarp.posOffset[0][r]),a.userData.myInfo={type:"cell",deleteFlag:this.colorWarp.name},this.colorWarp.mesh[r]=a,a.visible=M.var.colorWarpVisible,scene.add(a)}for(let r=0;r<this.colorWeft.length;r++){const t=new THREE.MeshBasicMaterial({color:this.colorWeft.pattern[r]});let a=new THREE.Mesh(e,t);a.position.fromArray(this.colorWeft.posOffset[r][0]),a.userData.myInfo={type:"cell",deleteFlag:this.colorWeft.name},this.colorWeft.mesh[r]=a,a.visible=M.var.colorWeftVisible,scene.add(a),r>this.colorWeft.length/this.colorWeft.offSet.y&&(a.visible=!1)}}pickSelectedColors(e,r){let t=[],a=[];for(let e=0;e<palettes[r].length;e++)M.var.colorSelectName==palettes[r][e].name&&(t.push(e),a.push(palettes[r][e].p));let o=rWeightedItems(t,a),l=palettes[r][o].name,i=palettes[r][o].arr,n=[];for(let t=0;t<r;t++)n.push({color:new THREE.Color(e[i[t]]),name:i[t]});return shuffleArray(n),M.var.colorGroupName=l,n}twillPattern(e=this.threading,r=M.var.twillSlope,t=M.var.twillOff,a){this.threading.pattern,this.treadling.pattern;if(e==this.threading){let e=M.var.threadingSlope,r=(M.var.threadingOffset,M.var.threadingTranslate),t=this.threading.size.x,a=this.threading.size.y+1,o=this.threading.pattern;for(let l=0;l<a-1;l++){let a=Math.floor((e*l+r)%t);o[a][l]=1}}else if(e==this.treadling){let e=M.var.treadlingSlope,r=(M.var.treadlingOffset,M.var.treadlingTranslate),t=this.treadling.size.y,a=this.treadling.size.x+1,o=this.treadling.pattern;for(let l=0;l<a-1;l++){let a=Math.floor((e*l+r)%t);o[l][a]=1}}}vPattern(e=this.threading){let r=this.threading.pattern,t=this.treadling.pattern;if(e==this.threading){let e=1,t=(M.var.threadingOffset,0);for(let a=0;a<M.var.NUM_THREADS;a++)r[t][a]=1,t+=e,t==M.var.NUM_SHAFTS-1&&(e*=-1),0==t&&a>0&&(e*=-1)}else if(e==this.treadling){let e=1,r=(M.var.treadlingOffset,0);for(let a=0;a<M.var.NUM_PICKS;a++)t[a][r]=1,r+=e,r==M.var.NUM_TREADLES-1&&(e*=-1),0==r&&a>0&&(e*=-1)}}triWavePattern(e=this.threading){this.threading.pattern,this.treadling.pattern;if(e==this.threading){let e=M.var.threadingSlope,r=(M.var.threadingOffset,M.var.threadingTranslate),t=this.threading.size.x,a=this.threading.size.y+1,o=this.threading.pattern;for(let l=0;l<a-1;l++){let a=Math.abs(Math.floor(triangleWave(l,e,t,r)));o[a][l]=1}}else if(e==this.treadling){let e=M.var.treadlingSlope,r=(M.var.treadlingOffset,M.var.treadlingTranslate),t=this.treadling.size.y,a=this.treadling.size.x+1,o=this.treadling.pattern;for(let l=0;l<a-1;l++){let a=Math.abs(Math.floor(triangleWave(l,e,t,r)));o[l][a]=1}}}randPattern(e=this.threading){let r=this.threading.pattern,t=this.treadling.pattern;if(e==this.threading){let e=Math.floor(rand()*M.var.NUM_SHAFTS),t=randChoice([-1,1]),a=0;a=e ;for(let o=0;o<Math.floor(M.var.NUM_THREADS/2);o++){if(r[a][o]=1,a+=t,a>M.var.NUM_SHAFTS-1){let r=0;for(;0==r;)e=Math.floor(rand()*M.var.NUM_SHAFTS),e!=M.var.NUM_SHAFTS-1&&(r=1);t=randChoice([-1,1]),a=e}if(a<0){let r=0;for(;0==r;)e=Math.floor(rand()*M.var.NUM_SHAFTS),0!=e&&(r=1);t=randChoice([-1,1]),a=e}}for(let e=Math.floor(M.var.NUM_THREADS/2);e<M.var.NUM_THREADS;e++)for(let t=0;t<M.var.NUM_SHAFTS;t++)r[t][e]=r[t][e-Math.floor(M.var.NUM_THREADS/2)]}else if(e==this.treadling)for(let e=0;e<M.var.NUM_PICKS;e++)for(let a=0;a<M.var.NUM_TREADLES;a++)t[e][a]=r[a][e]}offsetPattern(e){const r=e.size.x,t=e.size.y;let a;a="treadling"==e.name||"colorWeft"==e.name||"drawdownWarp"==e.name||"drawdownWeft"==e.name?(M.var.verticalSpacing-1)/2:0;let o=[];for(let l=0;l<r;l++){let r=[];for(let o=0;o<t;o++){let t=[o*M.var.cellSize*e.offSet.x+e.position.x+(1-e.offSet.y)/2+a,-l*M.var.cellSize*e.offSet.y+e.position.y+(1-e.offSet.y)/2,0];r.push(t)}o.push(r)}e.posOffset=o}caTieUpGrid(){let e=0,r=!1;for(;(!r||e<1e3)&&(this.makeCA(this),r=this.checkSequentialRuns(5,this.tieUp.pattern,!1),!r);)e++;if(e>=1e3)console.error("CA tie up count",e);else{}}makeCA(){const e=()=>Array.from({length:14},()=>Math.round(rand()));let r=!0;for(;r;){let t=0;this.theRules=e(),myCa=new CA(this.theRules,M.var.NUM_SHAFTS,M.var.NUM_TREADLES,scene),myCa.randomSeed(1),myCa.restart();for(let e=0;e<12;e++)myCa.generate();this.tieUp.pattern=myCa.oldBoard;let a=0;for(let e=0;e<this.tieUp.pattern.length;e++)for(let r=0;r<this.tieUp.pattern[e].length;r++)1==this.tieUp.pattern[e][r]&&a++;t++,a>M.var.NUM_SHAFTS*M.var.NUM_SHAFTS*.2&&a<M.var.NUM_SHAFTS*M.var.NUM_SHAFTS*.8?r=!1:t>100&&(r=!1)}}visualizeGrid(e){let r=e.pattern,t=e.name,a=new THREE.PlaneGeometry(M.var.cellSize,M.var.cellSize);for(let o=0;o<r.length;o++)for(let l=0;l<r[o].length;l++){let i=fetchColors(t,r,o,l);const n=new THREE.MeshBasicMaterial({color:i.cell});let s=new THREE.Mesh(a,n);if(s.position.fromArray(e.posOffset[o][l]),s.userData.myInfo={myGrid:r,myCol:l,myRow:o,type:"cell",deleteFlag:t},scene.add(s),0!=i.edge){const a=new THREE.EdgesGeometry(s.geometry),n=new THREE.LineSegments(a,new THREE.LineBasicMaterial({color:i.edge}));n.position.fromArray(e.posOffset[o][l]),n.position.z=10,n.userData.myInfo={myGrid:r,myCol:l,myRow:o,type:"gridline",deleteFlag:t},scene.add(n),o>r.length/e.offSet.y&&(n.visible=!1)}o>r.length/e.offSet.y&&(s.visible=!1)}}computeDrawdown(e=this.threading.pattern,r=this.tieUp.pattern,t=this.treadling.pattern){let a=[],o=0;for(let l of t){let t=new Array(M.var.NUM_THREADS).fill(0),i=[];for(let e=0;e<l.length;e++)if(1===l[e])for(let t=0;t<r[e].length;t++)1===r[e][t]&&i.push(t);for(let r=0;r<M.var.NUM_THREADS;r++)for(let a of i)if(1===e[a][r]){t[r]=1;break}a.push(t);let n,s=0;if(o<=M.var.NUM_TREADLES){1==t[0]?(wPat+=" U ",wPat_print+=" U ",n=1):(wPat+=" O ",wPat_print+=" O ",n=0);for(let e=0;e<M.var.NUM_SHAFTS;e++)1==n&&1==t[e]||0==n&&0==t[e]||(1==n&&0==t[e]?(wPat=wPat+s+" O ",wPat_print=wPat_print+s+" O ",n=0,s=0):0==n&&1==t[e]&&(wPat=wPat+s+" U ",wPat_print=wPat_print+s+" U ",n=1,s=0)),s++;wPat=wPat+s+" REPEAT",wPat="<div>"+wPat+"</div>\n",wPat_print=wPat_print+s+" REPEAT\n"}o++}wPat+="REPEAT",wPat_print+="REPEAT",this.drawdownWarp.pattern=a,this.drawdownWeft.pattern=a;let l=this.checkSequentialRuns(10),i=100;l?this.drawdownCheckCount=0:this.drawdownCheckCount<i?(this.resetPattern(this.tieUp),this.caTieUpGrid(),this.computeDrawdown(),this.drawdownCheckCount++):console.warn(`reached Maximum drawdown check of ${i}`)}visualizeDrawdown(e=this.drawdownWarp){let r=e.pattern,t=(e.position.x,e.position.y,0),a=new THREE.PlaneBufferGeometry(M.var.cellSize,M.var.cellSize),o=.9999;a=new THREE.PlaneBufferGeometry(M.var.cellSize*this.drawdownWarp.offSet.x,M.var.cellSize*this.drawdownWarp.offSet.y);for(let e=0;e<r.length;e++)for(let l=0;l<M.var.NUM_THREADS;l++){let i,n;i=this.colorWarp.pattern[l],t=this.drawdownWarp.pattern[e][l];let s=Math.round(220*i.r),d=Math.round(220*i.g),c=Math.round(220*i.b);n=new THREE.Color(`rgb(${s}, ${d}, ${c})`);const h=new THREE.MeshBasicMaterial({color:i}),p=new THREE.Mesh(a,h);let g,v;if(p.position.fromArray(this.drawdownWarp.posOffset[e][l]),p.position.z=2*t,scene.add(p),M.var.drawEdges){const t=p.geometry.attributes.position.array;let a=t[1]+M.var.verticalSpacing;0!=e&&e!=Math.ceil((r.length-1)/M.var.verticalSpacing)||(a=.5);const i=new THREE.Vector3(t[0]*o,+a,t[2]).add(p.position),s=new THREE.Vector3(t[3]*o,+a,t[5]).add(p.position),d=new THREE.Vector3(t[6]*o,-a,t[8]).add(p.position),c=new THREE.Vector3(t[9]*o,-a,t[11]).add(p.position);1===r[e][l]&&(g=new THREE.Line((new THREE.BufferGeometry).setFromPoints([i,d]),new THREE.LineBasicMaterial({color:n})),v=new THREE.Line((new THREE.BufferGeometry).setFromPoints([c,s]),new THREE.LineBasicMaterial({color:n})),scene.add(g),scene.add(v))}e>r.length/this.drawdownWeft.offSet.y&&(p.visible=!1,M.var.drawEdges&&(g&&(g.visible=!1),v&&(v.visible=!1)))}a=new THREE.PlaneBufferGeometry(M.var.cellSize,M.var.cellSize);for(let e=0;e<r.length;e++)for(let o=0;o<M.var.NUM_THREADS;o++){let l,i;l=this.colorWeft.pattern[o],t=this.drawdownWeft.pattern[e][o];let n=Math.round(220*l.r),s=Math.round(220*l.g),d=Math.round(220*l.b);i=new THREE.Color(`rgb(${n}, ${s}, ${d})`);const c=new THREE.MeshBasicMaterial({color:l}),h=new THREE.Mesh(a,c);let p,g;if(h.position.fromArray(this.drawdownWeft.posOffset[o][e]),h.position.z=t,scene.add(h),M.var.drawEdges){const t=h.geometry.attributes.position.array,a=new THREE.Vector3(t[0],t[1],t[2]).add(h.position),l=new THREE.Vector3(t[3],t[4],t[5]).add(h.position),n=new THREE.Vector3(t[6],t[7],t[8]).add(h.position),s=new THREE.Vector3(t[9],t[10],t[11]).add(h.position);if(10===r[e][o]){}else p=new THREE.Line((new THREE.BufferGeometry).setFromPoints([a,l]),new THREE.LineBasicMaterial({color:i})),g=new THREE.Line((new THREE.BufferGeometry).setFromPoints([n,s]),new THREE.LineBasicMaterial({color:i})),scene.add(p),scene.add(g)}o>r.length/this.drawdownWeft.offSet.y&&(h.visible=!1,M.var.drawEdges&&(p&&(p.visible=!1),g&&(g.visible=!1)))}}removeDrawdown(){let e=[...scene.children];for(let r=0;r<e.length;r++){let t=e[r];void 0===t.userData.myInfo&&scene.remove(t)}}removeGrid(e=["none"]){Array.isArray(e)||(e=[e]);let r=[...scene.children];for(let t=0;t<r.length;t++){let a=r[t];try{e.includes(a.userData.myInfo.deleteFlag)&&scene.remove(a)}catch{}}console.log("removed grid")}addDrawdownText(){const e=document.createElement("div");e.id="drawdownText",e.innerHTML=wPat;const r=document.querySelector("canvas");r?r.insertAdjacentElement("afterend",e):console.error("Canvas not found. Make sure this function is called after the canvas has been added to the DOM.")}checkSequentialRuns(e=M.var.maxRun,r=this.drawdownWarp.pattern,t=!0){const a=r.length,o=r[0].length;for(let l=0;l<a;l++){let a=1;for(let i=1;i<o;i++)if(r[l][i]===r[l][i-1]){if(a++,a>=e)return t&&this.sequenceRepair(!1),!1}else a=1}for(let l=0;l<o;l++){let o=1;for(let i=1;i<a;i++)if(r[i][l]===r[i-1][l]){if(o++,o>=e)return t&&this.sequenceRepair(!1),!1}else o=1}return t&&this.sequenceRepair(!0),!0}sequenceRepair(e){e?(renderer.setClearColor(displayColors.background),M.var.passedLengthTest=!0):M.var.passedLengthTest=!1}}class CA{constructor(e,r,t,a){this.oldBoard=[],this.newBoard=[],this.on=[],this.genCount=0,this.gens=M.var.maxGen+1,this.seeds=[],this.COLS=t,this.ROWS=r,this.rule=e,this.scene=a,this.oldBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.newBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.seeds=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0))}reset(){this.oldBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.genCount=0}restart(){this.genCount=0,this.oldBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0)),this.newBoard=Array.from({length:this.ROWS},()=>Array(this.COLS).fill(0));for(let e=0;e<this.ROWS;e++)for(let r=0;r<this.COLS;r++)1==this.seeds[e][r]&&(this.oldBoard[e][r]=1);this.seeds=Array(this.ROWS).fill(Array(this.COLS).fill(0)),this.genCount++}randomSeed(e){this.on[this.genCount]=[];let r=Math.floor(this.ROWS/2),t=Math.floor(this.COLS/2);this.seeds[r][t]=1,this.seeds[r+2][t+2]=1,this.seeds[r-2][t-2]=1;let a=rand();if(a<=.33)for(let a=0;a<e;a++){let e=Math.round(.33*this.ROWS),a=Math.floor(rand()*(2*e+1))-e+r,o=Math.floor(rand()*(2*e+1))-e+t;a<0||o<0||a>this.ROWS-1||o>this.COLS-1||(this.seeds[a][o]=1)}this.genCount++}generate(){this.on[this.genCount]=[];for(let e=0;e<this.ROWS;e++)for(let r=0;r<this.COLS;r++){let t=0;const a=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]];for(let o=0;o<a.length;o++){const[l,i]=a[o],n=e+l,s=r+i;n>=0&&n<this.ROWS&&s>=0&&s<this.COLS&&1===this.oldBoard[n][s]&&t++}1==this.oldBoard[e][r]&&(0==t&&(this.newBoard[e][r]=this.rule[0]),1==t&&(this.newBoard[e][r]=this.rule[1]),2==t&&(this.newBoard[e][r]=this.rule[2]),3==t&&(this.newBoard[e][r]=this.rule[3]),4==t&&(this.newBoard[e][r]=this.rule[4]),5==t&&(this.newBoard[e][r]=this.rule[5]),6==t&&(this.newBoard[e][r]=this.rule[6])),0==this.oldBoard[e][r]&&(0==t&&(this.newBoard[e][r]=this.rule[7]),1==t&&(this.newBoard[e][r]=this.rule[8]),2==t&&(this.newBoard[e][r]=this.rule[9]),3==t&&(this.newBoard[e][r]=this.rule[10]),4==t&&(this.newBoard[e][r]=this.rule[11]),5==t&&(this.newBoard[e][r]=this.rule[12]),6==t&&(this.newBoard[e][r]=this.rule[13]))}let e=this.oldBoard;this.oldBoard=this.newBoard,this.newBoard=e,this.genCount++}}init(),render(),document.addEventListener("keypress",function(e){"s"===e.key||"S"==e.key?saveLargeCanvas("Draft",2400):"t"!==e.key&&"T"!=e.key||(M.var.textVisible=!M.var.textVisible,toggleText())});
function init(){scene=new THREE.Scene,renderer=new THREE.WebGLRenderer({antialias:!1}),renderer.setPixelRatio(devicePixelRatio);let e=document.getElementById("container");renderer.setClearColor(displayColors.background),e.appendChild(renderer.domElement),renderer.domElement.style.zIndex="-1",camera=new THREE.OrthographicCamera(-M.var.zoom,M.var.zoom,M.var.zoom,-M.var.zoom,1,1e3),camera.position.set(0,0,35),camera.lookAt(0,0,0),raycaster=new THREE.Raycaster,mouse=new THREE.Vector2,weave=new weavedraft,updateCamera(),createTableSnippet(formatTextforTable(),displayColors.ground),console.log(weave),onWindowResize(),window.addEventListener("resize",onWindowResize,!1)}function animate(){requestAnimationFrame(animate),render()}function render(){renderer.render(scene,camera)}function onWindowResize(){updateCamera(),styleSquareDiv(),styleTextUpdate(),render()}function updateCamera(){let e=new THREE.Box3,r=e.getSize(new THREE.Vector3),t=e.getCenter(new THREE.Vector3);r=new THREE.Vector3(58,59,10),t=new THREE.Vector3(1.5,-9,5),DIM.x=DIM.y=Math.min(window.innerWidth,window.innerHeight),renderer.setSize(DIM.x,DIM.y);let a,o=DIM.x/DIM.y,l=r.x/r.y,i=1.4;l>o?(a=r.x/i,camera.right=a,camera.top=a/o,camera.bottom=-a/o):(a=r.y/i,camera.top=a,camera.bottom=-a,camera.left=-a*o,camera.right=a*o),camera.position.set(t.x,t.y,35),camera.lookAt(t),camera.updateProjectionMatrix()}function saveCanvas(e=M.seed){let r=e+".png",t=renderer.domElement.toDataURL(),a=document.createElement("a");a.href=t,a.download=r,a.target="_blank",document.body.appendChild(a),a.click(),document.body.removeChild(a),console.log("saved Canvas")}function saveLargeCanvas(e,r){let t=document.createElement("canvas");t.width=r,t.height=r;let a=new THREE.WebGLRenderer({canvas:t,antialias:!1});a.setPixelRatio(devicePixelRatio),a.setPixelRatio(2),a.setSize(r,r),a.setClearColor(displayColors.background),a.render(scene,camera);let o=t.toDataURL("image/png"),l=document.createElement("a");l.href=o,l.download=e+".png",l.target="_blank",document.body.appendChild(l),l.click(),document.body.removeChild(l),a.dispose(),console.log("Saved large canvas")}function saveText(e=M.seed){var r=wPat_print,t=new Blob([r],{type:"text/plain"}),a=URL.createObjectURL(t),o=document.createElement("a");o.href=a,o.download=e+".txt",document.body.appendChild(o),o.click(),document.body.removeChild(o),console.log("Saved Image ")}function createText(){const e=document.querySelector("canvas"),r=e.parentElement;let t=document.getElementById("overlay");t||(t=document.createElement("div"),t.id="overlay",t.style.position="absolute",t.style.top=e.offsetTop+"px",t.style.left=e.offsetLeft+"px",t.style.width=e.offsetWidth+"px",t.style.height=e.offsetHeight+"px",r.appendChild(t));const a=document.createElement("div");a.id="table-wrapper";let o=["Pattern:","Colors:","Palette:","Bindings:","Spacing:","Instructions:"],l=0;const i=document.createElement("table");for(let e=0;e<3;e++){const e=document.createElement("tr");for(let r=0;r<2;r++){const r=document.createElement("td");r.textContent=`${o[l]} ${l}`,e.appendChild(r),l++}i.appendChild(e)}i.style.width="100%",i.style.height="100%",i.style.borderCollapse="collapse",a.appendChild(i),t.appendChild(a)}function formatJson(){delete M.var.warpColors,delete M.var.weftColors,delete M.var.theRules;for(let e=0;e<M.var.colorWarp.length;e++)M.var.colorWarp[e]="0x"+M.var.colorWarp[e].getHexString();for(let e=0;e<M.var.colorWeft.length;e++)M.var.colorWeft[e]="0x"+M.var.colorWeft[e].getHexString();M.var.activeColor=M.var.activeColor.getHexString(),M.var.inactiveColor=M.var.inactiveColor.getHexString(),M.var.backgroundColor=M.var.backgroundColor.getHexString(),delete M.var.activeColor,delete M.var.inactiveColor}function saveJson(e=M.seed){let r=e+".json",t=M;downloadFile(t,r),console.log("saved Json!")}function downloadFile(e,r){var t=r.split("."),a=t[t.length-1],o="json"==a?new Blob([JSON.stringify(e,null,2).replace(/\\n/g,"\n").replace(/\\"/g,'"')],{type:"application/json"}):new Blob([Papa.unparse(e)],{type:"text/plain"}),l=document.createElement("a");document.body.appendChild(l),l.download=r,l.href=window.URL.createObjectURL(o),l.click(),l.parentNode.removeChild(l)}function addGUI(){}function rand(e=0,r=1){return e+(r-e)*R.random_dec()}function rInt(e,r){return e<r?Math.floor(rand(e,r+1)):Math.floor(rand(r,e+1))}function randChoice(e){return e[rInt(0,e.length-1)]}function rWeightedItems(e,r){let t={select:rand(),index:null,sum:0,mode:null,tempMin:0,tempMax:0};for(let e=0;e<r.length;e++)t.sum+=r[e];for(let a=0;a<e.length;a++)t.tempMax=r[a]/t.sum+t.tempMin,t.tempMin<=t.select&&t.select<t.tempMax&&0!=r[a]&&(t.index=a),t.tempMin+=r[a]/t.sum;return e[t.index]}function genTokenData(e=0){let r={},t="0x";for(var a=0;a<64;a++)t+=Math.floor(16*seedRand()).toString(16);return r.hash=t,r.tokenId=(1e6*e+Math.floor(1e3*seedRand())).toString(),r}function sfc32(e,r,t,a){return function(){e>>>=0,r>>>=0,t>>>=0,a>>>=0;var o=e+r|0;return e=r^r>>>9,r=t+(t<<3)|0,t=t<<21|t>>>11,a=a+1|0,o=o+a|0,t=t+o|0,(o>>>0)/4294967296}}function cyrb128(e){let r=1779033703,t=3144134277,a=1013904242,o=2773480762;for(let l,i=0;i<e.length;i++)l=e.charCodeAt(i),r=t^Math.imul(r^l,597399067),t=a^Math.imul(t^l,2869860233),a=o^Math.imul(a^l,951274213),o=r^Math.imul(o^l,2716044179);return r=Math.imul(a^r>>>18,597399067),t=Math.imul(o^t>>>22,2869860233),a=Math.imul(r^a>>>17,951274213),o=Math.imul(t^o>>>19,2716044179),[(r^t^a^o)>>>0,(t^r)>>>0,(a^r)>>>0,(o^r)>>>0]}function triangleWave(e,r,t,a){if(t<=0)throw new Error("Height must be positive");const o=(e+a)*r,l=2*t-2,i=o%l;return t%2==0?i<t?i:i<l-t?t-1:i-l:i<t?i:l-i}function shuffleArray(e){for(let r=e.length-1;r>0;r--){const t=Math.floor(rand(0,r)),a=e[r];e[r]=e[t],e[t]=a}return e}function shuffleArrayRandom(e){for(let r=e.length-1;r>0;r--){const t=Math.floor(Math.random()*r),a=e[r];e[r]=e[t],e[t]=a}return e}function fetchColors(e,r,t,a){let o,l,i=M.var.displayMode;if("Original"==i)o=1===r[t][a]?M.var.activeColor:M.var.inactiveColor,l=M.var.activeColor;else if("Inverse"==i||"Grid"==i)1===r[t][a]?(o=displayColors[e].active.cell,l=displayColors[e].active.edge):(o=displayColors[e].inactive.cell,l=displayColors[e].inactive.edge);else if("Weave Colors"==i)if("tieUp"==e)1===r[t][a]?(o=displayColors[e].active.cell,l=displayColors[e].active.edge):(o=displayColors[e].inactive.cell,l=displayColors[e].inactive.edge);else{let i;"threading"==e?i=a%displayColors[e].active.cell.length:"treadling"==e&&(i=t%displayColors[e].active.cell.length);let n=displayColors[e].active.cell[i];1===r[t][a]?(o=n,l=n==displayColors.background&&displayColors.tieUp.inactive.cell):(o=displayColors[e].inactive.cell,l=displayColors[e].inactive.edge)}return{cell:o,edge:l}}function toggleText(){"block"==squareDiv.style.display?squareDiv.style.display="none":squareDiv.style.display="block"}function styleSquareDiv(){let e=DIM.x;M.var.textVisible?squareDiv.style.display="block":squareDiv.style.display="none",squareDiv.style.position="absolute",squareDiv.style.height=e+"px",squareDiv.style.width=e+"px",squareDiv.style.left="50%",squareDiv.style.top="50%",squareDiv.style.transform="translate(-50%, -50%)",styleInnerDiv()}function styleInnerDiv(){innerDiv.style.position="absolute",innerDiv.style.bottom="0",innerDiv.style.width="68.5%",innerDiv.style.height="14.8%",innerDiv.style.left="50%",innerDiv.style.transform="translateX(-50%)",innerDiv.style.zIndex="5"}function createTableSnippet(e=["","","","",""],r="black",t=innerDiv){let a=["Pattern: ","Warp Colors: ","Palette: ","Weft Colors: ","Spacing: ","Bindings: "];for(let r=0;r<e.length;r++)a[r]+=e[r];r instanceof THREE.Color&&(r=r.getHexString());let o=document.createElement("table"),l=document.createElement("tbody");o.appendChild(l),o.style.width="100%",o.style.tableLayout="fixed",o.style.zIndex="5";var i=[[a[0],a[1]],[a[2],a[3]],[a[4],a[5]]];i.forEach(function(e,t){let a=document.createElement("tr");e.forEach(function(e){let t=document.createElement("td");t.innerText=e,t.style.color="#"+r,t.style.whiteSpace="nowrap",a.appendChild(t),tabelCells.push(t)}),l.appendChild(a)}),t?t.appendChild(o):console.error("Parent element not found.")}function styleTextUpdate(){let e;e=DIM.x>1e3?"18px":DIM.x>600?"16px":DIM.x>450?"14px":"12px",tabelCells.forEach(function(r){r.style.fontSize=e,DIM.x<300?r.style.display="none":r.style.display="table-cell"})}function formatTextforTable(){M.var.colorWarpNames,M.var.colorWeftNames;let e="",r="",t=[];for(let r of M.var.colorWarpNames)e+=`${r}, `;e=e.slice(0,-1),e=e.slice(0,-1);for(let e of M.var.colorWeftNames)r+=`${e}, `;return r=r.slice(0,-1),r=r.slice(0,-1),t[0]=M.var.preset,t[1]=e,t[2]=M.var.colorSelectName,t[3]=r,t[4]=M.var.verticalSpacingType,t[5]=displayColors.backgroundName,t}let credits=shuffleArrayRandom(["Benjamin Aranda","Chris Lasch","Jesse Bassett","Joaquin Bonifaz"]);console.log("Drafting by ArandaLasch"),console.log(`${credits[0]}, ${credits[1]}, ${credits[2]}, ${credits[3]}`),console.log("");class Random{constructor(){this.useA=!1;let e=function(e){let r=parseInt(e.substr(0,8),16),t=parseInt(e.substr(8,8),16),a=parseInt(e.substr(16,8),16),o=parseInt(e.substr(24,8),16);return function(){r|=0,t|=0,a|=0,o|=0;let e=(r+t|0)+o|0;return o=o+1|0,r=t^t>>>9,t=a+(a<<3)|0,a=a<<21|a>>>11,a=a+e|0,(e>>>0)/4294967296}};this.prngA=new e(tokenData.hash.substr(2,32)),this.prngB=new e(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_bool(e){return this.random_dec()<e}random_num(e,r){return e+(r-e)*this.random_dec()}random_int(e,r){return Math.floor(this.random_num(e,r+1))}}R=new Random;let gui,newDiv=document.createElement("div");newDiv.id="container",newDiv.style.display="inline-block",newDiv.style.margin="0",newDiv.style.width="100%",newDiv.style.height="100%",document.body.appendChild(newDiv),document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden";let renderer,camera,scene,raycaster,mouse,myCa,devicePixelRatio=window.devicePixelRatio||1,wPat="",wPat_print="",DIM={x:Math.min(window.innerWidth,window.innerHeight)};DIM.y=DIM.x;let tabelCells=[],squareDiv=document.createElement("div"),innerDiv=document.createElement("div");squareDiv.appendChild(innerDiv),newDiv.appendChild(squareDiv);let weave,displayColors={treadling:{active:{cell:16777215,edge:0},inactive:{cell:16777215,edge:0}},tieUp:{active:{cell:16777215,edge:0},inactive:{cell:16777215,edge:0}},threading:{active:{cell:16777215,edge:0},inactive:{cell:16777215,edge:0}},background:0,backgroundName:"White"},druckerSatinColors={oliveGreen:3686464,tenderGreen:5335383,appleGreen:10141309,emeraldGreen:1206126,purpleMaroon:4859707,carminRed:4859707,scarletRed:10625597,rubyRed:5975353,terracotta:8929589,pink:10966369,lightPink:12019057,black:2171945,grey:6909033,blueGrey:12566711,white:14870756,royalBlue:2243701,ultraMarine:1648699,lavenderBlue:3489100,lagoonBlue:30409,softBlue:5604238,waterGreen:10663343,chocolate:3880760,weatheredGold:6246469,beige:10060646,taupe:10390910,ivory:14339747,orange:13128752,peach:14527854,yellowTumeric:13080618,brightYellow:14660864},colorNames={oliveGreen:{eng:"Olive Green",fr:"Vert Olive"},tenderGreen:{eng:"Tender Green",fr:"Vert Tendre"},appleGreen:{eng:"Apple Green",fr:"Vert Pomme"},emeraldGreen:{eng:"Emerald Green",fr:"Vert Emeraude"},purpleMaroon:{eng:"Purple Maroon",fr:"Bordeaux Violet"},carminRed:{eng:"Carmin Red",fr:"Rouge Carmin"},scarletRed:{eng:"Scarlet Red",fr:"Rouge Ecarlate"},rubyRed:{eng:"Ruby Red",fr:"Rouge Rubis"},terracotta:{eng:"Terracotta",fr:"Terracotta"},pink:{eng:"Pink",fr:"Rose"},lightPink:{eng:"Light Pink",fr:"Rose Pastel"},black:{eng:"Black",fr:"Noir"},grey:{eng:"Grey",fr:"Gris"},blueGrey:{eng:"Blue Grey",fr:"Gris Bleute"},white:{eng:"White",fr:"Blanc"},royalBlue:{eng:"Royal Blue",fr:"Bleu Royal"},ultraMarine:{eng:"Ultra Marine",fr:"Bleu Outrener"},lavenderBlue:{eng:"Lavender Blue",fr:"Bleu Lavande"},lagoonBlue:{eng:"Lagoon Blue",fr:"Bleu Lagon"},softBlue:{eng:"Soft Blue",fr:"Bleu Doux"},waterGreen:{eng:"Water Green",fr:"Vert D'Eau"},chocolate:{eng:"Chocolate",fr:"Chocolat"},weatheredGold:{eng:"Weathered Gold",fr:"Or Patine"},beige:{eng:"Beige",fr:"Beige"},taupe:{eng:"Taupe",fr:"Taupe"},ivory:{eng:"Ivory",fr:"Ivoire"},orange:{eng:"Orange",fr:"Orange"},peach:{eng:"Peach",fr:"Peche"},yellowTumeric:{eng:"Yellow Tumeric",fr:"Jaune Curcuma"},brightYellow:{eng:"BrightYellow",fr:"Jaune Vif"}},palettes={2:[{name:"Light",p:1,arr:["white","scarletRed"]},{name:"Dark",p:1,arr:["black","purpleMaroon"]},{name:"Warm",p:1,arr:["yellowTumeric","lagoonBlue"]},{name:"Warm",p:1,arr:["scarletRed","softBlue"]},{name:"Warm",p:1,arr:["terracotta","beige"]},{name:"Cool",p:1,arr:["waterGreen","black"]},{name:"Cool",p:1,arr:["waterGreen","royalBlue"]},{name:"Cool",p:1,arr:["emeraldGreen","waterGreen"]},{name:"Mix",p:1,arr:["oliveGreen","taupe"]},{name:"Mix",p:1,arr:["white","black"]},{name:"Mix",p:1,arr:["softBlue","rubyRed"]},{name:"Cool",p:1,arr:["tenderGreen","white"]},{name:"Mix",p:1,arr:["black","ivory"]},{name:"Mix",p:1,arr:["ultraMarine","ivory"]},{name:"Dark",p:1,arr:["black","weatheredGold"]},{name:"Mix",p:1,arr:["oliveGreen","lightPink"]},{name:"Warm",p:1,arr:["orange","peach"]},{name:"Cool",p:1,arr:["lagoonBlue","orange"]},{name:"Cool",p:1,arr:["waterGreen","softBlue"]},{name:"Light",p:1,arr:["grey","ivory"]},{name:"Light",p:1,arr:["pink","ivory"]},{name:"Light",p:1,arr:["white","grey"]}],3:[{name:"Light",p:1,arr:["white","weatheredGold","grey"]},{name:"Dark",p:1,arr:["carminRed","lavenderBlue","emeraldGreen"]},{name:"Warm",p:1,arr:["brightYellow","waterGreen","black"]},{name:"Warm",p:1,arr:["brightYellow","ultraMarine","peach"]},{name:"Warm",p:1,arr:["ultraMarine","orange","tenderGreen"]},{name:"Cool",p:1,arr:["royalBlue","taupe","blueGrey"]},{name:"Mix",p:1,arr:["terracotta","appleGreen","black"]},{name:"Mix",p:1,arr:["taupe","pink","emeraldGreen"]},{name:"Mix",p:1,arr:["oliveGreen","ivory","grey"]},{name:"Warm",p:1,arr:["orange","peach","brightYellow"]},{name:"Mix",p:1,arr:["oliveGreen","lightPink","appleGreen"]},{name:"Warm",p:1,arr:["oliveGreen","yellowTumeric","beige"]}],4:[{name:"Light",p:1,arr:["white","softBlue","emeraldGreen","scarletRed"]},{name:"Light",p:1,arr:["lagoonBlue","royalBlue","orange","white"]},{name:"Light",p:1,arr:["terracotta","ultraMarine","lightPink","lagoonBlue"]},{name:"Dark",p:1,arr:["weatheredGold","rubyRed","ultraMarine","lagoonBlue"]},{name:"Warm",p:1,arr:["ivory","taupe","blueGrey","appleGreen"]},{name:"Warm",p:1,arr:["scarletRed","rubyRed","purpleMaroon","white"]},{name:"Cool",p:1,arr:["waterGreen","tenderGreen","lightPink","purpleMaroon"]},{name:"Cool",p:1,arr:["lagoonBlue","ivory","brightYellow","purpleMaroon"]},{name:"Mix",p:1,arr:["black","weatheredGold","grey","appleGreen"]},{name:"Mix",p:1,arr:["emeraldGreen","scarletRed","taupe","chocolate"]},{name:"Mix",p:1,arr:["oliveGreen","waterGreen","beige","scarletRed"]},{name:"Mix",p:1,arr:["grey","carminRed","rubyRed","peach"]},{name:"Cool",p:1,arr:["tenderGreen","ivory","weatheredGold","oliveGreen"]},{name:"Warm",p:1,arr:["rubyRed","terracotta","yellowTumeric","peach"]},{name:"Mix",p:1,arr:["tenderGreen","terracotta","ivory","taupe"]}],5:[{name:"Light",p:1,arr:["waterGreen","white","beige","terracotta","ultraMarine"]},{name:"Dark",p:1,arr:["chocolate","grey","blueGrey","ivory","weatheredGold"]},{name:"Warm",p:1,arr:["peach","orange","tenderGreen","scarletRed","waterGreen"]},{name:"Warm",p:1,arr:["terracotta","pink","scarletRed","ivory","grey"]},{name:"Red",p:1,arr:["grey","orange","beige","ultraMarine","weatheredGold"]},{name:"Cool",p:1,arr:["royalBlue","ultraMarine","lavenderBlue","softBlue","waterGreen"]},{name:"Mix",p:1,arr:["emeraldGreen","scarletRed","taupe","chocolate","oliveGreen"]},{name:"Mix",p:1,arr:["oliveGreen","waterGreen","beige","scarletRed","lightPink"]},{name:"Cool",p:1,arr:["tenderGreen","ivory","weatheredGold","oliveGreen","lavenderBlue"]},{name:"Warm",p:1,arr:["rubyRed","terracotta","yellowTumeric","peach","pink"]},{name:"Mix",p:1,arr:["tenderGreen","terracotta","ivory","taupe","weatheredGold"]}]},spacingTypes=["Standard","Tight","Close"],threadingPatternTypes=["twill","triWave","vPattern","rand"],treadlingPatternTypes=["twill","triWave","vPattern","rand"],colorPalettes=["random","analogous","fromArray","fromSelected"],presetTypes=["None","Duochrome","Figure","Linear","Field"],colorArrayNames=["Red","Yellow","Blue","Mix","Light","Dark"],colorSelectNames=["Warm","Cool","Mix","Light","Dark"],layouts=["Original","Tight"],displayModes=["Original","Inverse","Grid","Weave Colors"],M={var:{}};if(M.var={zoom:30,cellSize:1,activeColor:new THREE.Color(9803157),inactiveColor:new THREE.Color(15658734),backgroundColor:new THREE.Color(15658734),warpColors:[],weftColors:[],theRules:[0,0,0,0,0,0,0,0,1,0,0,0,0,0],maxGen:2,NUM_SHAFTS:8,NUM_THREADS:50,NUM_TREADLES:0,NUM_PICKS:0,startX:-27,startY:22,verticalSpacingType:rWeightedItems(spacingTypes,[1,2,0]),verticalSpacing:rWeightedItems([1.25,1,1],[1,2,0]),threadingPattern:rWeightedItems(threadingPatternTypes,[1,1,0,.1]),threadingSlope:rWeightedItems([.5,1,2],[1,1,1]),threadingOffset:1,threadingTranslate:0,threadingMirrorPattern:!1,threadingMirrorColor:!1,treadlingPattern:rWeightedItems(treadlingPatternTypes,[1,1,0,.1]),treadlingSlope:rWeightedItems([.5,1,2],[1,1,1]),treadlingOffset:1,treadlingTranslate:0,treadlingMirrorPattern:!1,treadlingMirrorColor:!1,colorSelectName:rWeightedItems(colorSelectNames,[1,1,1,1,1]),colorArrayName:rWeightedItems(colorArrayNames,[1,1,1,1,1,1]),colorPalette:rWeightedItems(colorPalettes,[0,0,0,1]),colorWeftCount:rWeightedItems([1,2,3],[1,1,1]),colorWarpCount:rWeightedItems([1,2,3],[1,1,1]),colorWarp:[],colorWeft:[],colorWarpNames:[],colorWeftNames:[],colorMaterial:rWeightedItems(["Satin","Glossy"],[1,0]),drawEdges:!1,passedLengthTest:!0,maxRun:8,preset:rWeightedItems(presetTypes,[0,30,15,20,35]),displayMode:rWeightedItems(displayModes,[0,35,55,10]),layout:rWeightedItems(layouts,[0,1]),threadingPosX:0,threadingPosY:0,tieUpPosX:0,tieUpPosY:0,treadlingPosX:0,treadlingPosY:0,colorWarpPosX:0,colorWarpPosY:0,colorWeftPosX:0,colorWeftPosY:0,drawdownPosX:0,drawdownPosY:0,colorWarpVisible:!0,colorWeftVisible:!1,textVisible:!1},M.var.NUM_TREADLES=M.var.NUM_SHAFTS,M.var.NUM_PICKS=M.var.NUM_THREADS,"Duochrome"==M.var.preset?(M.var.colorWeftCount=1,M.var.colorWarpCount=1):"Figure"==M.var.preset?(R.random_bool(-1)?(M.var.colorWeftCount=1,M.var.colorWarpCount=rWeightedItems([2,3],[1.25,1])):(M.var.colorWeftCount=rWeightedItems([2,3],[1,0]),M.var.colorWarpCount=1),M.var.threadingPattern=rWeightedItems(["twill","triWave"],[1,3]),M.var.threadingSlope=rWeightedItems([.5,1],[1.5,.8]),M.var.treadlingPattern=rWeightedItems(["twill","triWave"],[1,3]),M.var.treadlingSlope=rWeightedItems([.5,1],[1.5,.8])):"Linear"==M.var.preset?R.random_bool(-1)?(M.var.colorWeftCount=1,M.var.colorWarpCount=rWeightedItems([2,3],[1.25,1]),M.var.treadlingPattern=rWeightedItems(["twill","triWave"],[1,1]),M.var.treadlingSlope=rWeightedItems([1,2],[.5,1.5]),M.var.verticalSpacingType=rWeightedItems(spacingTypes,[1.1,.5,0])):(M.var.colorWeftCount=rWeightedItems([2,3],[1,1.5]),M.var.colorWarpCount=1,M.var.verticalSpacingType=rWeightedItems(spacingTypes,[1.2,.5,0]),M.var.threadingPattern=rWeightedItems(["twill","triWave"],[1,1]),M.var.threadingSlope=2,M.var.treadlingPattern=rWeightedItems(["twill","triWave"],[1,1]),M.var.treadlingSlope=rWeightedItems([1,2],[.5,1.5])):"Field"==M.var.preset&&(M.var.colorWarpCount=rWeightedItems([2,3],[1.25,1]),M.var.colorWeftCount=rWeightedItems([2,3],[1.25,1]),M.var.threadingPattern=rWeightedItems(["twill","triWave","rand"],[1,1,1]),M.var.threadingSlope=rWeightedItems([.5,1,2],[1,1,1]),M.var.treadlingPattern=rWeightedItems(["twill","triWave","rand"],[1,1,1]),M.var.treadlingSlope=rWeightedItems([.5,1,2],[1,1,1]),M.var.colorWarpCount+M.var.colorWeftCount==6&&M.var.colorWeftCount--),"Close"==M.var.verticalSpacingType?M.var.verticalSpacing=1:"Tight"==M.var.verticalSpacingType?M.var.verticalSpacing=1.25:"Standard"==M.var.verticalSpacingType&&(M.var.verticalSpacing=1.5),"Original"==M.var.layout)M.var.threadingPosX=0,M.var.threadingPosY=0,M.var.tieUpPosX=0,M.var.tieUpPosY=0,M.var.treadlingPosX=0,M.var.treadlingPosY=0,M.var.colorWarpPosX=0,M.var.colorWarpPosY=0,M.var.colorWeftPosX=0,M.var.colorWeftPosY=0,M.var.drawdownPosX=0,M.var.drawdownPosY=0,M.var.colorWarpVisible=!0,M.var.colorWeftVisible=!0;else if("Tight"==M.var.layout){let e=2,r=0;M.var.threadingPosX=0,M.var.threadingPosY=-e,M.var.tieUpPosX=-e,M.var.tieUpPosY=-e,M.var.treadlingPosX=-e+r,M.var.treadlingPosY=0,M.var.colorWarpPosX=0,M.var.colorWarpPosY=-e-1,M.var.colorWeftPosX=-e-2+r,M.var.colorWeftPosY=0,M.var.drawdownPosX=r,M.var.drawdownPosY=0,M.var.colorWarpVisible=!1,M.var.colorWeftVisible=!1}console.log("M",M);class squareGrid{constructor(e,r,t,a,o,l,i){this.name=e,this.position=new THREE.Vector2(r,t),this.size=new THREE.Vector2(a,o),this.length=a*o,this.pattern=[[]],this.mesh=[[]],this.posOffset=[[]],this.offSet={x:l,y:i}}}class weavedraft{constructor(){this.threading=new squareGrid("threading",M.var.startX+M.var.threadingPosX,M.var.startY+M.var.threadingPosY,M.var.NUM_SHAFTS,M.var.NUM_THREADS,1,1),this.tieUp=new squareGrid("tieUp",M.var.NUM_THREADS*M.var.cellSize+2+M.var.startX+M.var.tieUpPosX,M.var.startY+M.var.tieUpPosY,M.var.NUM_SHAFTS,M.var.NUM_TREADLES,1,1),this.treadling=new squareGrid("treadling",M.var.NUM_THREADS*M.var.cellSize+2+M.var.startX+M.var.treadlingPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.treadlingPosY,M.var.NUM_PICKS,M.var.NUM_TREADLES,1,M.var.verticalSpacing),this.colorWarp=new squareGrid("colorWarp",M.var.startX+M.var.colorWarpPosX,M.var.startY+2+M.var.colorWarpPosY,1,M.var.NUM_THREADS,1,1),this.colorWeft=new squareGrid("colorWeft",M.var.NUM_THREADS+2+M.var.NUM_TREADLES+2+M.var.startX+M.var.colorWeftPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.colorWeftPosY,M.var.NUM_PICKS,1,1,M.var.verticalSpacing),this.drawdownWarp=new squareGrid("drawdownWarp",M.var.startX+M.var.drawdownPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.drawdownPosY,M.var.NUM_PICKS,M.var.NUM_PICKS,1,M.var.verticalSpacing),this.drawdownWeft=new squareGrid("drawdownWeft",M.var.startX+M.var.drawdownPosX,-M.var.NUM_SHAFTS*M.var.cellSize-2+M.var.startY+M.var.drawdownPosY,M.var.NUM_PICKS,M.var.NUM_PICKS,1,M.var.verticalSpacing),this.drawdownCheckCount=0,this.resetPattern(this.threading),this.resetPattern(this.tieUp),this.resetPattern(this.treadling),this.managePattern(),this.getColorGridS(),this.getdisplayColors(),this.offsetPattern(this.threading),this.offsetPattern(this.tieUp),this.offsetPattern(this.treadling),this.offsetPattern(this.colorWarp),this.offsetPattern(this.colorWeft),this.offsetPattern(this.drawdownWarp),this.offsetPattern(this.drawdownWeft),this.theRules=M.var.theRules,this.caTieUpGrid(),this.visualizeGrid(this.threading),this.visualizeGrid(this.tieUp),this.visualizeGrid(this.treadli
// primatives by Aranda\Lasch // Benjamin Aranda, Jesse Bassett, Joaquin Bonifaz, Chris Lasch function partialSum(e){return e.reduce((e,t,r,o)=>{const a=o.slice(0,r+1),s=a.reduce((e,t)=>e+t,0);return[...e,s]},[])}function setup(){colorMode(HSB),canvas=createCanvas(DIM,DIM,WEBGL),noStroke(),rect(100*M,500*M,50*M,50*M),pixelDensity(2),1==mobile?(txG=createGraphics(txW,txH,WEBGL),txS=txG.createShader(basicVert2,fragShaderA)):(shaderA=createShader(basicVert,fragShaderA),shaderA.setUniform("u_resolution",[DIM,DIM]),shad_Size=1024,bkrez=2800,myImg=createImage(8*shad_Size,shad_Size)),shaderBK=createShader(basicVert,fragShaderA),shaderBK.setUniform("u_resolution",[bkrez,bkrez]),bkImg=createImage(bkrez,bkrez),sPress(),sun=new p5.Vector(1,-1,1),sun.normalize(),gBorder=2,gScale=20,gVals=growth_Max+gBorder,gVals=bkGridTrueMax,grw=new GrowSys(1),rg=new Grid_Rhomb(gVals,gVals,gVals,gScale);let e=patternSelect[0];for(targetPt=rg.gPts[e.x][e.y][e.z],patternSelect.shift(),go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0],goNum=1,i=0;i<goNum;i++){goDepot[i]=[],resetDepot[i]=[],nextGrow();for(let e=0;e<go.length;e++){resetDepot[i][e]=[];for(let t=0;t<go[e].verts.length-2;t++)resetDepot[i][e].push(new p5.Vector(go[e].verts[t].x,go[e].verts[t].y,go[e].verts[t].z))}goDepot[i]=go,goModelsDepot.push(goModels)}currCluster=goNum-1,grow=-1,timer=0,color0=color(hR,sR,bR),color1=color0,color2=color0;let t=R.random_int(1/6*goModels.length,.8*goModels.length),r=Math.round(5/12*goModels.length),o=t+r*(1/3),a=t+.5*r,s=t+r*(2/3),n=t+1*r,c=R.random_int(0,3);for(i=0;i<goModels.length;i++)renderPattern.push(0),1==ERASE&&i>5&&i<.33*goModels.length&&(renderPattern[i]=1),1==WIREFRAME?0==c?i>t&&i<n&&(renderPattern[i]=3):1==c?i>t&&i<a?renderPattern[i]=3:i>a&&i<n&&(renderPattern[i]=5):2==c?i>t&&i<o?renderPattern[i]=3:i>o&&i<s&&(renderPattern[i]=3):i>s&&i<n?renderPattern[i]=5:i>t&&i<n&&(renderPattern[i]=3):1==OPAQUE?i>t&&i<n&&(renderPattern[i]=2):renderPattern.push(0)}function draw(){if(1==drawTex){if(drawTex=!1,1==mobile){txG.noStroke(),txG.shader(txS),txS.setUniform("u_resolution",[txH,txH]);for(let e=0;e<8;e++)console.log("txG mode, Jesse"),readUniforms(txS,e),txG.rect(e*txW/8-txW/2,-txH/2,txW/8,txH);txG.resetShader()}else{shaderA.setUniform("u_resolution",[shad_Size,shad_Size]),shader(shaderA),resizeCanvas(shad_Size,shad_Size,!1);for(let e=0;e<8;e++)readUniforms(shaderA,e),rect(0,0,40,40),myImg.copy(canvas,0,0,2*shad_Size,2*shad_Size,shad_Size*e,0,2*shad_Size,2*shad_Size);resetShader()}resizeCanvas(bkrez,bkrez,!1),shader(shaderBK);let e=2*v;UNIVAR[8][0][0]=e,bkgd_f!=bkgd_cat.arr[2].name&&(UNIVAR[8][0][1]=e+R.random_num(-20,20),UNIVAR[8][0][2]=e+R.random_num(-30,30),UNIVAR[8][0][3]=e+R.random_num(-30,20),UNIVAR[8][1][0]=e+R.random_num(-20,30)),UNIVAR[8][12][0]*=e/60,UNIVAR[8][12][1]*=e/60,UNIVAR[8][12][2]*=e/60,UNIVAR[8][12][3]*=e/60,UNIVAR[8][13][0]*=e/60,readUniforms(shaderBK,8),rect(0,0,40,40),bkImg.copy(canvas,0,0,bkrez,bkrez,0,0,bkrez,bkrez),resetShader(),resizeCanvas(DIM,DIM,!1)}if(background(color1),makeBorder(),lightFalloff(.003,3e-4,0),ambientLight(color0),noStroke(),0==run_animation&&(steps=go.length),1==grow)steps>=go.length?steps=go.length:millis()>timer&&(timer+=delay,steps++);else if(-1==grow)if(steps<=1){currCluster+=1,currCluster>goNum-1&&(currCluster=0),1==initGrow&&(go=[],resetGo=[],go=goDepot[currCluster].slice(),resetGo=resetDepot[currCluster].slice(),goModels=goModelsDepot[currCluster],initGrow=!1),zoomStart=zoom,camStart=[cam[0],cam[1],cam[2]],camTarg=[camTarg[0],camTarg[1],camTarg[2]];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)go[e].verts[t]=new p5.Vector(resetGo[e][t].x,resetGo[e][t].y,resetGo[e][t].z);ratio=+camSpeed,vStart=vTarg,steps=1,grow*=-1}else millis()>timer&&(timer+=delay,steps-=3);if(push(),stroke(255,0,0),strokeWeight(6),line(0,0,0,0,0,1e5),pop(),updateCam(),1==swap&&(save("primitive"),pixelDensity(2),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),prtScn=!1,swap=!1),1==prtScn){let e=4800/DIM;pixelDensity(e),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),swap=!0}}function readUniforms(e,t){for(let r=0;r<UNI.length;r++)e.setUniform(UNI[r],UNIVAR[t][r])}function lPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]+angle,camTarg[2]+angle],zoomStart=zoom,myAngle+=angle,zflag--,zflag<0&&(zflag=2),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function rPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]-angle,camTarg[2]-angle],zoomStart=zoom,myAngle-=angle,zflag++,zflag>=3&&(zflag=0),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function sPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[cam[0],cam[1],cam[2]],Math.abs((myAngle+zoomRR)%Math.PI)<=ZoomPercent?(zoomTarg=defaultZoom/2,zflag=0):(zoomTarg=defaultZoom,zoomRRR>=.5?zflag=1:zoomRRR<=.5&&(zflag=2)),zoomStart=zoomTarg,ratio=+camSpeed,ratio=.98999}function touchStarted(){mouseX>WIDTH/2?rPress():mouseX<WIDTH/2&&lPress()}function keyPressed(){if(keyCode===LEFT_ARROW?lPress():keyCode===RIGHT_ARROW?rPress():keyCode===UP_ARROW?(zoomStart=zoom,zoomTarg=defaultZoom/2,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()):keyCode===DOWN_ARROW&&(zoomStart=zoom,zoomTarg=defaultZoom,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()),"o"==key||"O"==key){let e=[],t=[],r=0;for(let o=0;o<go.length;o++)if(1!=renderPattern[o])for(let a=0;a<go[o].faces.length;a++){for(let t=0;t<go[o].faces[a].facePts.length;t++)e.push("v "+go[o].faces[a].facePts[t].x+" "+go[o].faces[a].facePts[t].y+" "+go[o].faces[a].facePts[t].z),r+=1;t.push("f "+(r-2)+" "+(r-1)+" "+r)}let o=e.concat(t);saveStrings(o,"primitive","obj")}"i"!=key&&"I"!=key||(prtScn=!0,console.log(prtScn),console.log(swap)),"u"!=key&&"U"!=key||myImg.save("primitive texture","png"),"g"!=key&&"G"!=key||(run_animation=!0,grow=-1)}function makeBorder(){push(),scale(zoom),fill(color2);let e=.1*v/1.15;1==BKTEXT&&(push(),lightFalloff(.003,3e-4,0),ambientLight(color0),texture(bkImg),translate(0,0,-1e3),box(1.15*(2*v-e)/zoom,1.15*(2*v-e)/zoom),pop()),push(),translate(-1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(0,1.15*v/1.15,1e3),box(5*v,e),pop(),push(),translate(0,-1.15*v/1.15,1e3),box(5*v,e),pop(),pop()}function nextGrow(){cam=[0,cam[1]-myAngle,cam[2]-myAngle],camStart=[0,camStart[1]-myAngle,camStart[2]-myAngle],camTarg=[0,camTarg[1]-myAngle,camTarg[2]-myAngle],v=0,vStart=0,vTarg=0,steps=0,mGo=0,go=[],goModels=[],go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0];R.random_int(1,Math.floor(growth_Max/2)),Math.floor(growth_Max/2),R.random_int(1,growth_Max-1),R.random_int(1,growth_Max-1);currArraySize=go.length;for(let e=0;e<patternSelect.length;e++){let t=patternSelect[e];grw.growToTarget(rg.gPts[t.x][t.y][t.z])}getModelExtents();for(let e=0;e<go.length;e++){go[e].center.x+=-centerX,go[e].center.y+=-centerY,go[e].center.z+=-centerZ;for(let t=0;t<go[e].faces.length;t++){go[e].faces[t].center.x+=-centerX,go[e].faces[t].center.y+=-centerY,go[e].faces[t].center.z+=-centerZ;for(let r=0;r<go[e].faces[t].facePts.length;r++)go[e].faces[t].facePts[r].x+=-centerX,go[e].faces[t].facePts[r].y+=-centerY,go[e].faces[t].facePts[r].z+=-centerZ}}for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length;t++)go[e].verts[t].x+=-centerX,go[e].verts[t].y+=-centerY,go[e].verts[t].z+=-centerZ;xMax+=-centerX,xMin+=-centerX,yMax+=-centerY,yMin+=-centerY,zMax+=-centerZ,zMin+=-centerZ,getModelExtents(),0==v&&(v=vTarg,vStart=vTarg);for(let e=0;e<go.length;e++)geom=new p5.Geometry(1,1,buildModel),geom.gid="go"+mGo+"_"+R.random_dec(),goModels.push(geom),mGo++}function buildModel(){let e=0;for(let t=0;t<go[mGo].faces.length;t++){let r=[];for(let o=0;o<go[mGo].faces[t].facePts.length;o++)this.vertices.push(go[mGo].faces[t].facePts[o]),r.push(e),e+=1;this.faces.push([r[0],r[1],r[2]]),n=createVector(go[mGo].faces[t].normal.x,go[mGo].faces[t].normal.y,go[mGo].faces[t].normal.z),n.normalize(),this.vertexNormals.push(n,n,n);let o=1/8,a=sun.dot(n),s=(sun.angleBetween(n),map(a,-1,1,0,7));s=round(s);let c=this.vertices[r[0]].dist(this.vertices[r[1]]),i=this.vertices[r[0]].dist(this.vertices[r[2]]),l=this.vertices[r[1]].dist(this.vertices[r[2]]);c=map(c,0,41.71563256142714,0,1),i=map(c,0,41.71563256142714,0,1),l=map(c,0,41.71563256142714,0,1),"e"==go[mGo].faces[t].type?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.866*c*o,c/2])):c>i&&c>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.809*c*o,c/2])):i>c&&i>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s+.809*i*o,i/2]),this.uvs.push([o*s,i])):l>c&&l>i&&(this.uvs.push([o*s+.809*l*o,l/2]),this.uvs.push([o*s,0]),this.uvs.push([o*s,l]));let m=R3.random_dec(),d=R4.random_dec();if(m<=.5)for(let e=0;e<this.uvs.length;e++)this.uvs[e][1]=1-this.uvs[e][1];if(d<=.5)for(let e=0;e<this.uvs.length;e++);}}function getModelExtents(){let e,t,r=[],o=[],a=[];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)r.push(go[e].verts[t].x),o.push(go[e].verts[t].y),a.push(go[e].verts[t].z);r.sort((e,t)=>e-t),o.sort((e,t)=>e-t),a.sort((e,t)=>e-t),xMin=r[0],xMax=r[r.length-1],yMin=o[0],yMax=o[o.length-1],zMin=a[0],zMax=a[a.length-1],centerX=(xMax-xMin)/2+xMin,centerY=(yMax-yMin)/2+yMin,centerZ=(zMax-zMin)/2+zMin,e=Math.max(xMax,Math.abs(xMin)),t=Math.max(yMax,Math.abs(yMin)),vTarg=Math.max(e,t)}function drawGrid(){push();let e=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),t=bkGridDrawBoundsX+e,r=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),o=bkGridDrawBoundsY+r,a=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),s=bkGridDrawBoundsZ+a;if(stroke(0,0,0),strokeWeight(1),0==ignX)for(let n=r;n<=o;n++)for(let r=a;r<=s;r++)line(rg.gPts[e][n][r].x,rg.gPts[e][n][r].y,rg.gPts[e][n][r].z,rg.gPts[t][n][r].x,rg.gPts[t][n][r].y,rg.gPts[t][n][r].z);if(0==ignY)for(let n=e;n<=t;n++)for(let e=a;e<=s;e++)line(rg.gPts[n
// primatives by Aranda\Lasch // Benjamin Aranda, Jesse Bassett, Joaquin Bonifaz, Chris Lasch function partialSum(e){return e.reduce((e,t,r,o)=>{const a=o.slice(0,r+1),s=a.reduce((e,t)=>e+t,0);return[...e,s]},[])}function setup(){colorMode(HSB),canvas=createCanvas(DIM,DIM,WEBGL),noStroke(),rect(100*M,500*M,50*M,50*M),pixelDensity(2),1==mobile?(txG=createGraphics(txW,txH,WEBGL),txS=txG.createShader(basicVert2,fragShaderA)):(shaderA=createShader(basicVert,fragShaderA),shaderA.setUniform("u_resolution",[DIM,DIM]),shad_Size=1024,bkrez=2800,myImg=createImage(8*shad_Size,shad_Size)),shaderBK=createShader(basicVert,fragShaderA),shaderBK.setUniform("u_resolution",[bkrez,bkrez]),bkImg=createImage(bkrez,bkrez),sPress(),sun=new p5.Vector(1,-1,1),sun.normalize(),gBorder=2,gScale=20,gVals=growth_Max+gBorder,gVals=bkGridTrueMax,grw=new GrowSys(1),rg=new Grid_Rhomb(gVals,gVals,gVals,gScale);let e=patternSelect[0];for(targetPt=rg.gPts[e.x][e.y][e.z],patternSelect.shift(),go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0],goNum=1,i=0;i<goNum;i++){goDepot[i]=[],resetDepot[i]=[],nextGrow();for(let e=0;e<go.length;e++){resetDepot[i][e]=[];for(let t=0;t<go[e].verts.length-2;t++)resetDepot[i][e].push(new p5.Vector(go[e].verts[t].x,go[e].verts[t].y,go[e].verts[t].z))}goDepot[i]=go,goModelsDepot.push(goModels)}currCluster=goNum-1,grow=-1,timer=0,color0=color(hR,sR,bR),color1=color0,color2=color0;let t=R.random_int(1/6*goModels.length,.8*goModels.length),r=Math.round(5/12*goModels.length),o=t+r*(1/3),a=t+.5*r,s=t+r*(2/3),n=t+1*r,c=R.random_int(0,3);for(i=0;i<goModels.length;i++)renderPattern.push(0),1==ERASE&&i>5&&i<.33*goModels.length&&(renderPattern[i]=1),1==WIREFRAME?0==c?i>t&&i<n&&(renderPattern[i]=3):1==c?i>t&&i<a?renderPattern[i]=3:i>a&&i<n&&(renderPattern[i]=5):2==c?i>t&&i<o?renderPattern[i]=3:i>o&&i<s&&(renderPattern[i]=3):i>s&&i<n?renderPattern[i]=5:i>t&&i<n&&(renderPattern[i]=3):1==OPAQUE?i>t&&i<n&&(renderPattern[i]=2):renderPattern.push(0)}function draw(){if(1==drawTex){if(drawTex=!1,1==mobile){txG.noStroke(),txG.shader(txS),txS.setUniform("u_resolution",[txH,txH]);for(let e=0;e<8;e++)console.log("txG mode, Jesse"),readUniforms(txS,e),txG.rect(e*txW/8-txW/2,-txH/2,txW/8,txH);txG.resetShader()}else{shaderA.setUniform("u_resolution",[shad_Size,shad_Size]),shader(shaderA),resizeCanvas(shad_Size,shad_Size,!1);for(let e=0;e<8;e++)readUniforms(shaderA,e),rect(0,0,40,40),myImg.copy(canvas,0,0,2*shad_Size,2*shad_Size,shad_Size*e,0,2*shad_Size,2*shad_Size);resetShader()}resizeCanvas(bkrez,bkrez,!1),shader(shaderBK);let e=2*v;UNIVAR[8][0][0]=e,bkgd_f!=bkgd_cat.arr[2].name&&(UNIVAR[8][0][1]=e+R.random_num(-20,20),UNIVAR[8][0][2]=e+R.random_num(-30,30),UNIVAR[8][0][3]=e+R.random_num(-30,20),UNIVAR[8][1][0]=e+R.random_num(-20,30)),UNIVAR[8][12][0]*=e/60,UNIVAR[8][12][1]*=e/60,UNIVAR[8][12][2]*=e/60,UNIVAR[8][12][3]*=e/60,UNIVAR[8][13][0]*=e/60,readUniforms(shaderBK,8),rect(0,0,40,40),bkImg.copy(canvas,0,0,bkrez,bkrez,0,0,bkrez,bkrez),resetShader(),resizeCanvas(DIM,DIM,!1)}if(background(color1),makeBorder(),lightFalloff(.003,3e-4,0),ambientLight(color0),noStroke(),0==run_animation&&(steps=go.length),1==grow)steps>=go.length?steps=go.length:millis()>timer&&(timer+=delay,steps++);else if(-1==grow)if(steps<=1){currCluster+=1,currCluster>goNum-1&&(currCluster=0),1==initGrow&&(go=[],resetGo=[],go=goDepot[currCluster].slice(),resetGo=resetDepot[currCluster].slice(),goModels=goModelsDepot[currCluster],initGrow=!1),zoomStart=zoom,camStart=[cam[0],cam[1],cam[2]],camTarg=[camTarg[0],camTarg[1],camTarg[2]];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)go[e].verts[t]=new p5.Vector(resetGo[e][t].x,resetGo[e][t].y,resetGo[e][t].z);ratio=+camSpeed,vStart=vTarg,steps=1,grow*=-1}else millis()>timer&&(timer+=delay,steps-=3);if(push(),stroke(255,0,0),strokeWeight(6),line(0,0,0,0,0,1e5),pop(),updateCam(),1==swap&&(save("primitive"),pixelDensity(2),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),prtScn=!1,swap=!1),1==prtScn){let e=4800/DIM;pixelDensity(e),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),swap=!0}}function readUniforms(e,t){for(let r=0;r<UNI.length;r++)e.setUniform(UNI[r],UNIVAR[t][r])}function lPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]+angle,camTarg[2]+angle],zoomStart=zoom,myAngle+=angle,zflag--,zflag<0&&(zflag=2),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function rPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]-angle,camTarg[2]-angle],zoomStart=zoom,myAngle-=angle,zflag++,zflag>=3&&(zflag=0),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function sPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[cam[0],cam[1],cam[2]],Math.abs((myAngle+zoomRR)%Math.PI)<=ZoomPercent?(zoomTarg=defaultZoom/2,zflag=0):(zoomTarg=defaultZoom,zoomRRR>=.5?zflag=1:zoomRRR<=.5&&(zflag=2)),zoomStart=zoomTarg,ratio=+camSpeed,ratio=.98999}function touchStarted(){mouseX>WIDTH/2?rPress():mouseX<WIDTH/2&&lPress()}function keyPressed(){if(keyCode===LEFT_ARROW?lPress():keyCode===RIGHT_ARROW?rPress():keyCode===UP_ARROW?(zoomStart=zoom,zoomTarg=defaultZoom/2,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()):keyCode===DOWN_ARROW&&(zoomStart=zoom,zoomTarg=defaultZoom,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()),"o"==key||"O"==key){let e=[],t=[],r=0;for(let o=0;o<go.length;o++)if(1!=renderPattern[o])for(let a=0;a<go[o].faces.length;a++){for(let t=0;t<go[o].faces[a].facePts.length;t++)e.push("v "+go[o].faces[a].facePts[t].x+" "+go[o].faces[a].facePts[t].y+" "+go[o].faces[a].facePts[t].z),r+=1;t.push("f "+(r-2)+" "+(r-1)+" "+r)}let o=e.concat(t);saveStrings(o,"primitive","obj")}"i"!=key&&"I"!=key||(prtScn=!0,console.log(prtScn),console.log(swap)),"u"!=key&&"U"!=key||myImg.save("primatives texture","png"),"g"!=key&&"G"!=key||(run_animation=!0,grow=-1)}function makeBorder(){push(),scale(zoom),fill(color2);let e=.1*v/1.15;1==BKTEXT&&(push(),lightFalloff(.003,3e-4,0),ambientLight(color0),texture(bkImg),translate(0,0,-1e3),box(1.15*(2*v-e)/zoom,1.15*(2*v-e)/zoom),pop()),push(),translate(-1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(0,1.15*v/1.15,1e3),box(5*v,e),pop(),push(),translate(0,-1.15*v/1.15,1e3),box(5*v,e),pop(),pop()}function nextGrow(){cam=[0,cam[1]-myAngle,cam[2]-myAngle],camStart=[0,camStart[1]-myAngle,camStart[2]-myAngle],camTarg=[0,camTarg[1]-myAngle,camTarg[2]-myAngle],v=0,vStart=0,vTarg=0,steps=0,mGo=0,go=[],goModels=[],go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0];R.random_int(1,Math.floor(growth_Max/2)),Math.floor(growth_Max/2),R.random_int(1,growth_Max-1),R.random_int(1,growth_Max-1);currArraySize=go.length;for(let e=0;e<patternSelect.length;e++){let t=patternSelect[e];grw.growToTarget(rg.gPts[t.x][t.y][t.z])}getModelExtents();for(let e=0;e<go.length;e++){go[e].center.x+=-centerX,go[e].center.y+=-centerY,go[e].center.z+=-centerZ;for(let t=0;t<go[e].faces.length;t++){go[e].faces[t].center.x+=-centerX,go[e].faces[t].center.y+=-centerY,go[e].faces[t].center.z+=-centerZ;for(let r=0;r<go[e].faces[t].facePts.length;r++)go[e].faces[t].facePts[r].x+=-centerX,go[e].faces[t].facePts[r].y+=-centerY,go[e].faces[t].facePts[r].z+=-centerZ}}for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length;t++)go[e].verts[t].x+=-centerX,go[e].verts[t].y+=-centerY,go[e].verts[t].z+=-centerZ;xMax+=-centerX,xMin+=-centerX,yMax+=-centerY,yMin+=-centerY,zMax+=-centerZ,zMin+=-centerZ,getModelExtents(),0==v&&(v=vTarg,vStart=vTarg);for(let e=0;e<go.length;e++)geom=new p5.Geometry(1,1,buildModel),geom.gid="go"+mGo+"_"+R.random_dec(),goModels.push(geom),mGo++}function buildModel(){let e=0;for(let t=0;t<go[mGo].faces.length;t++){let r=[];for(let o=0;o<go[mGo].faces[t].facePts.length;o++)this.vertices.push(go[mGo].faces[t].facePts[o]),r.push(e),e+=1;this.faces.push([r[0],r[1],r[2]]),n=createVector(go[mGo].faces[t].normal.x,go[mGo].faces[t].normal.y,go[mGo].faces[t].normal.z),n.normalize(),this.vertexNormals.push(n,n,n);let o=1/8,a=sun.dot(n),s=(sun.angleBetween(n),map(a,-1,1,0,7));s=round(s);let c=this.vertices[r[0]].dist(this.vertices[r[1]]),i=this.vertices[r[0]].dist(this.vertices[r[2]]),l=this.vertices[r[1]].dist(this.vertices[r[2]]);c=map(c,0,41.71563256142714,0,1),i=map(c,0,41.71563256142714,0,1),l=map(c,0,41.71563256142714,0,1),"e"==go[mGo].faces[t].type?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.866*c*o,c/2])):c>i&&c>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.809*c*o,c/2])):i>c&&i>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s+.809*i*o,i/2]),this.uvs.push([o*s,i])):l>c&&l>i&&(this.uvs.push([o*s+.809*l*o,l/2]),this.uvs.push([o*s,0]),this.uvs.push([o*s,l]));let m=R3.random_dec(),d=R4.random_dec();if(m<=.5)for(let e=0;e<this.uvs.length;e++)this.uvs[e][1]=1-this.uvs[e][1];if(d<=.5)for(let e=0;e<this.uvs.length;e++);}}function getModelExtents(){let e,t,r=[],o=[],a=[];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)r.push(go[e].verts[t].x),o.push(go[e].verts[t].y),a.push(go[e].verts[t].z);r.sort((e,t)=>e-t),o.sort((e,t)=>e-t),a.sort((e,t)=>e-t),xMin=r[0],xMax=r[r.length-1],yMin=o[0],yMax=o[o.length-1],zMin=a[0],zMax=a[a.length-1],centerX=(xMax-xMin)/2+xMin,centerY=(yMax-yMin)/2+yMin,centerZ=(zMax-zMin)/2+zMin,e=Math.max(xMax,Math.abs(xMin)),t=Math.max(yMax,Math.abs(yMin)),vTarg=Math.max(e,t)}function drawGrid(){push();let e=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),t=bkGridDrawBoundsX+e,r=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),o=bkGridDrawBoundsY+r,a=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),s=bkGridDrawBoundsZ+a;if(stroke(0,0,0),strokeWeight(1),0==ignX)for(let n=r;n<=o;n++)for(let r=a;r<=s;r++)line(rg.gPts[e][n][r].x,rg.gPts[e][n][r].y,rg.gPts[e][n][r].z,rg.gPts[t][n][r].x,rg.gPts[t][n][r].y,rg.gPts[t][n][r].z);if(0==ignY)for(let n=e;n<=t;n++)for(let e=a;e<=s;e++)line(rg.gPts[n
oid 0,void 0,void 0,void 0,void 0,void 0,a,o,.5)),a=go[go.length-1];let t=!0,s="",n=0;for(;1==t;){rand2=R2.random_dec();let e=small_death_chance;rand2>e?(s+="f",n+=1,n>=4&&(s+="+",n=0),rand3=R3.random_dec(),e=.98,rand3>e&&(s+="/",n=0)):t=!1}e=this.render(s,a,r),e=this.remDups(e),e=this.remFaces(e);for(let t=0;t<e.length;t++)go.push(e[t])}}}currArraySize=e,e=go.length}}remDups(e){for(let t=0;t<e.length;t++){let r=e[t];for(let o=0;o<e.length;o++)if(o!=t){let t;t=e[o],r.center.dist(t.center)<.1&&e.splice(o,1)}}return e}remFaces(e){for(let t=0;t<e.length;t++){e[t];for(let r=0;r<e.length;r++)if(r!=t)for(let o=0;o<e[t].faces.length;o++){let a=e[t].faces[o].center;for(let s=0;s<e[r].faces.length;s++)if(a.dist(e[r].faces[s].center)<.1){e[t].faces.splice(o,1),e[r].faces.splice(s,1);break}}}return e}render(e,t,r){let o,a=e,s=t,n=a.length,c=[],i=2;o=0==r?0:3;for(let e=0;e<n;e++){let t=a.charAt(e);if("f"==t){0==o?i=2==i?6:2:1==o?i=2==i?4:4==i?2:4:2==o?i=2==i?6:6==i?2:6:3==o?i=3==i?5:3:4==o&&(i=5==i?7:5),c.push(new Go3d(2,void 0,void 0,void 0,void 0,void 0,s.faces[i],s));let e=c[c.length-1];s=e}else"+"==t?o<3?(o+=1,o>2&&(o=0)):(o+=1,o>4&&(o=3)):"/"==t&&(o=o<3?3:0)}return c}}class Face{constructor(e,t,r,o){this.type=o,this.facePts=[],this.center=new p5.Vector,this.facePts[0]=createVector(e.x,e.y,e.z),this.facePts[1]=createVector(t.x,t.y,t.z),this.facePts[2]=createVector(r.x,r.y,r.z),this.center=vertex_average(this.facePts),this.normal=p5.Vector.sub(this.facePts[1],this.facePts[0]).cross(p5.Vector.sub(this.facePts[2],this.facePts[0])),this.normal.mult(-1),this.normal.normalize()}}
vec2 Nx2; uniform float indx; uniform vec4 Ld; uniform float cBlend; \n#define BlendScreen(base,blend) (1.0-((1.0-base)*(1.0-blend)))\nvec3 mod289(vec3 x) {return x-floor(x*(1.0 / 289.0))*289.0;} vec2 mod289(vec2 x) {return x-floor(x*(1.0 / 289.0))*289.0;} vec3 permute(vec3 x) {return mod289(((x*34.0)+1.0)*x);} float snoise(vec2 v) {const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439); vec2 i=floor(v+dot(v,C.yy)); vec2 x0=v-i+dot(i,C.xx); vec2 i1=vec2(0.0); i1=(x0.x > x0.y)? vec2(1.0,0.0):vec2(0.0,1.0); vec2 x1=x0.xy+C.xx-i1; vec2 x2=x0.xy+C.zz; i=mod289(i); vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0)); vec3 m=max(0.5-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0); m=m*m; m=m*m; vec3 x=2.0*fract(p*C.www)-1.0; vec3 h=abs(x)-0.5; vec3 ox=floor(x+0.5); vec3 a0=x-ox; m*=1.79284291400159-0.85373472095314*(a0*a0+h*h); vec3 g=vec3(0.0); g.x=a0.x*x0.x+h.x*x0.y; g.yz=a0.yz*vec2(x1.x,x2.x)+h.yz*vec2(x1.y,x2.y); return 130.0*dot(m,g);} vec2 rotateUV(vec2 uv,float rotation) {return vec2(cos(rotation)*(uv.x-0.5)+sin(rotation)*(uv.y-0.5)+0.5,cos(rotation)*(uv.y-0.5)-sin(rotation)*(uv.x-0.5)+0.5);} float SmoothStep(float edge0,float edge1,float x){float t=clamp((x-edge0) / (edge1-edge0),0.0,1.0); return t;} void main() {vec2 st=vTexCoord; vec2 st_1=st; vec2 st_2=st; vec2 st_3=st; vec2 st_4=st; vec2 st_5=st; vec2 st_6=st; vec3 color=vec3(0.0); st_1=rotateUV(st,LR1.x); st_1.x+=cos(st_1.y*dA1.x)/df1.x; st_1.y+=sin(st_1.x*dA1.x)/df1.x; float pos_1=st_1.x*LF1.x; float y=0.; float x=pos_1; y=sin((x+Ld.z)*Ld.y); y+=sin((x+Ld.z)*Ld.y*2.1+Ld.w)*4.5; y+=sin((x+Ld.z)*Ld.y*1.72+Ld.w*1.121)*4.0; y+=sin((x+Ld.z)*Ld.y*2.221+Ld.w*0.437)*5.0; y+=sin((x+Ld.z)*Ld.y*3.1122+Ld.w*4.269)*2.5; y*=Ld.x*0.06; pos_1=pos_1+y; float colL_1=wb1.x*bb1.x*((cos(pos_1*2.*3.14)+1.)/2.)-bb1.x+1.; float colLC_1=clamp(colL_1,0.090,1.0); vec2 posN_1=st*Nf1.x; float colN_1=(snoise(posN_1)*.5+.5); float colNC_1=smoothstep(Nn1.x,Nx1.x,colN_1); st_2=rotateUV(st_2,LR1.y); st_2.x+=cos(st_2.y*dA1.y)/df1.y; st_2.y+=sin(st_2.x*dA1.y)/df1.y; float pos_2=st_2.x*LF1.y; float colL_2=wb1.y*bb1.y*((cos(pos_2*2.*3.14)+1.)/2.)-bb1.y+1.; float colLC_2=clamp(colL_2,0.090,1.0); vec2 posN_2=st_2*Nf1.y; float colN_2=(snoise(posN_2)*.5+.5); float colNC_2=smoothstep(Nn1.y,Nx1.y,colN_2); st_3=rotateUV(st_3,LR1.z); st_3.x+=cos(st_3.y*dA1.z)/df1.z; st_3.y+=sin(st_3.x*dA1.z)/df1.z; float pos_3=st_3.x*LF1.z; float colL_3=wb1.z*bb1.z*((cos(pos_3*2.*3.14)+1.)/2.)-bb1.z+1.; float colLC_3=clamp(colL_3,0.090,1.0); vec2 posN_3=st_3*Nf1.z; float colN_3=(snoise(posN_3)*.5+.5); float colNC_3=smoothstep(Nn1.z,Nx1.z,colN_3); st_4=rotateUV(st_4,LR1.w); st_4.x+=cos(st_4.y*dA1.w)/df1.w; st_4.y+=sin(st_4.x*dA1.w)/df1.w; float pos_4=st_4.x*LF1.w; float colL_4=wb1.w*bb1.w*((cos(pos_4*2.*3.14)+1.)/2.)-bb1.w+1.; float colLC_4=clamp(colL_4,0.090,1.0); vec2 posN_4=st_4*Nf1.w; float colN_4=(snoise(posN_4)*.5+.5); float colNC_4=smoothstep(Nn1.w,Nx1.w,colN_4); st_5=rotateUV(st_5,LR2.x); st_5.x+=cos(st_5.y*dA2.x)/df2.x; st_5.y+=sin(st_5.x*dA2.x)/df2.x; float pos_5=st_5.x*LF2.x; float colL_5=wb2.x*bb2.x*((cos(pos_5*2.*3.14)+1.)/2.)-bb2.x+1.; float colLC_5=clamp(colL_5,0.090,1.0); vec2 posN_5=st_5*Nf2.x; float colN_5=(snoise(posN_5)*.5+.5); float colNC_5=smoothstep(Nn2.x,Nx2.x,colN_5); vec2 posN_6=st_6*Nf2.y; float colN_6=(snoise(posN_6)*.5+.5); float colNC_6=smoothstep(Nn2.y,Nx2.y,colN_6); if(indx==1.0){colNC_5=colNC_5+colNC_2; colNC_4=colNC_4+colNC_3; colNC_1=0.108*(colNC_6-0.)+colNC_1; colNC_2=0.292*(colNC_6-0.)+colNC_2; colNC_3=-0.448*(-colNC_6+0.024)+colNC_3;}else if (indx==2.0){colNC_5=colNC_5+colNC_2; colNC_4=1.; colNC_3=0.664*colNC_6+colNC_3; colNC_2=1.664*colNC_6+colNC_2; colNC_1=1.;}else if (indx==3.0){colNC_5=colNC_5+colNC_3; colNC_4=0.032*colNC_6+colNC_4; colNC_3=0.712*colNC_6+colNC_3; colNC_1=0.672*colNC_6+colNC_1;}else if (indx==4.0){colNC_5=colNC_5+colNC_3; colNC_3=1.680*colNC_5+colNC_3-1.; colNC_4=0.784*colNC_6+colNC_4; colNC_3=0.736*colNC_6+colNC_3; colNC_1=-0.016*colNC_6+colNC_1;}else if (indx==5.0){colNC_5=colNC_5+colNC_3; colNC_4=0.016*colNC_6+colNC_4; colNC_3=0.000*colNC_6+colNC_3; colNC_2=0.328*colNC_6+colNC_2; colNC_1=0.992*(colNC_6-0.024)+colNC_1;}else if (indx==6.0){colNC_5=colNC_5+colNC_3;}else if (indx==7.0){colNC_5=colNC_5+colNC_3;}else if (indx==8.0){colNC_5=colNC_5+colNC_3;} float colB_1=BlendScreen(colNC_1,colLC_1); float colB_2=BlendScreen(colNC_2,colLC_2); float colB_3=BlendScreen(colNC_3,colLC_3); float colB_4=BlendScreen(colNC_4,colLC_4); float colB_5=BlendScreen(colNC_5,colLC_5); float colF_1=SmoothStep(cBlend,1.,colB_1); float colF_2=SmoothStep(cBlend,1.,colB_2); float colF_3=SmoothStep(cBlend,1.,colB_3); float colF_4=SmoothStep(cBlend,1.,colB_4); float colF_5=SmoothStep(cBlend,1.,colB_5); float colF=min(colF_1,colF_2); colF=min(colF,colF_3); colF=min(colF,colF_4); colF=min(colF,colF_5); color=vec3(colF); gl_FragColor=vec4(color,1.0);} ",angle=Math.PI/3,defaultZoom=1.15,zoom=1.15,zoomStart=1.15,zoomTarg=1.15,v=0,vStart=0,vTarg=0,ratio=0,camSpeed=.02,easing=.05,initCamAngle=R.random_int(0,5)*angle,cam=[initCamAngle.PI/6,initCamAngle,initCamAngle],camStart=[0,0,0],camTarg=[0,0,0],rx1=1+R.random_dec()/100,ry1=1+R.random_dec()/100,rz1=1+R.random_dec()/100,rx2=1+R.random_dec()/100,ry2=1+R.random_dec()/100,rz2=1+R.random_dec()/100,rx3=1+R.random_dec()/100,ry3=1+R.random_dec()/100,rz3=1+R.random_dec()/100;class Go3d{constructor(e,t,r,o,a,s,n,c,i,l){if(this.verts=[],this.faces=[],this.faceIndx=[],this.gScale=a,this.x=0,this.y=0,this.z=0,this.center=new p5.Vector,this.ballCenter1=new p5.Vector,this.ballCenter2=new p5.Vector,1==e){this.x=t,this.y=r,this.z=o,this.verts[0]=createVector(0,0,0),this.verts[1]=createVector(-.548,1.097,1.687),this.verts[2]=createVector(1.226,0,1.687),this.verts[3]=createVector(1.226,1.984,1.687),this.verts[4]=createVector(1.774,.887,0),this.verts[5]=createVector(0,1.984,0),this.verts[6]=createVector(-.548,-.887,1.688),this.verts[7]=createVector(1.774,2.87,-0);for(let e=0;e<this.verts.length;e++)this.verts[e].x=this.verts[e].x*this.gScale+this.x,this.verts[e].y=this.verts[e].y*this.gScale+this.y,this.verts[e].z=this.verts[e].z*this.gScale+this.z;this.faceIndx=[[0,1,2],[3,5,4],[0,5,1],[5,3,1],[1,3,2],[2,3,4],[0,2,4],[0,4,5]]}else if(2==e){let e,t=new Face(n.facePts[0],n.facePts[1],n.facePts[2]);e=c;for(let r=0;r<8;r++)this.verts[r]=reflect3d(e.verts[r],t);for(let t=0;t<8;t++)this.faceIndx.push([e.faceIndx[t][0],e.faceIndx[t][2],e.faceIndx[t][1]])}else if(3==e){let e=i,t=l,r=c;for(let o=0;o<8;o++)this.verts[o]=scale3d(r.verts[o],e,t);for(let e=0;e<8;e++)this.faceIndx.push([r.faceIndx[e][0],r.faceIndx[e][1],r.faceIndx[e][2]])}this.ballCenter1=this.verts[6],this.ballCenter2=this.verts[7],this.center=vertex_average([this.verts[0],this.verts[1],this.verts[2],this.verts[3],this.verts[4],this.verts[5]]);for(let e=0;e<8;e++){let t;t=e<2?"e":"i",this.faces.push(new Face(this.verts[this.faceIndx[e][0]],this.verts[this.faceIndx[e][1]],this.verts[this.faceIndx[e][2]],t))}}}class Grid_Rhomb{constructor(e,t,r,o){this.gPts=[],this.gIndx=[],this.vecNum=3,this.moveVectors=new p5.Vector(2*this.vecNum),this.moveVectorsIndx=new Array(2*this.vecNum),this.gVectors=new p5.Vector,this.w=e,this.h=t,this.l=r,this.gridScale=o,this.moveVectorSize=2*this.vecNum,this.gVectors=this.findDodecaVectors();for(let e=0;e<20;e++)this.gVectors[e].mult(2);this.moveVectors[0]=this.gVectors[0],this.moveVectors[1]=this.gVectors[1],this.moveVectors[2]=this.gVectors[10],this.moveVectors[3]=this.gVectors[17],this.moveVectors[4]=this.gVectors[18],this.moveVectors[5]=this.gVectors[8],this.moveVectorsIndx[0]=0,this.moveVectorsIndx[1]=1,this.moveVectorsIndx[2]=10,this.moveVectorsIndx[3]=17,this.moveVectorsIndx[4]=18,this.moveVectorsIndx[5]=8;for(let e=0;e<this.l;e++){this.gPts[e]=[],this.gIndx[e]=[];for(let t=0;t<this.w;t++){this.gPts[e][t]=[],this.gIndx[e][t]=[];for(let r=0;r<this.h;r++){let o=new p5.Vector(this.moveVectors[0].x,this.moveVectors[0].y,this.moveVectors[0].z),a=new p5.Vector(this.moveVectors[1].x,this.moveVectors[1].y,this.moveVectors[1].z),s=new p5.Vector(this.moveVectors[2].x,this.moveVectors[2].y,this.moveVectors[2].z),n=.5*this.w;o.mult((e-n)*this.gridScale),a.mult((t-n)*this.gridScale),s.mult((r-n)*this.gridScale);let c=new p5.Vector(0,0,0);c.add(o),c.add(a),c.add(s),this.gPts[e][t][r]=new p5.Vector(c.x,c.y,c.z),this.gIndx[e][t][r]=new p5.Vector(e,t,r)}}}}findDodecaVectors(){let e=[],t=[],r=52.6226359,o=10.81231754,a=1,s=PI*r/180,n=PI*o/180,c=PI*-o/180,i=PI*-r/180,l=72*PI/180,m=l/2,d=0,h=createVector(0,0,0);for(let e=0;e<5;e++)t[e]=[],t[e][0]=a*cos(d)*cos(s),t[e][1]=a*sin(d)*cos(s),t[e][2]=a*sin(s),t.push(h),d+=l;d=0;for(let e=5;e<10;e++)t[e]=[],t[e][0]=a*cos(d)*cos(n),t[e][1]=a*sin(d)*cos(n),t[e][2]=a*sin(n),d+=l;d=m;for(let e=10;e<15;e++)t[e]=[],t[e][0]=a*cos(d)*cos(c),t[e][1]=a*sin(d)*cos(c),t[e][2]=a*sin(c),d+=l;d=m;for(let e=15;e<20;e++)t[e]=[],t[e][0]=a*cos(d)*cos(i),t[e][1]=a*sin(d)*cos(i),t[e][2]=a*sin(i),d+=l;for(let r=0;r<20;r++)e.push(new p5.Vector(t[r][0],t[r][1],t[r][2]));return e}}class GrowSys{constructor(e){this.gens=e,this.gen1=0}growToTarget(e){let t=e,r=!0,o=currGo,a=o.verts[3].dist(o.verts[0]),s=0;for(;1==r;){s+=1,o=currGo;let e=o.center.dist(t);if(e>a&&s<199){let e=[];e=this.growByBall(o,t);let r,a=99,s=9999;for(let o=0;o<e.length;o++){let n=e[o];r=n.center.dist(t),r<s&&(s=r,a=o),go.push(n)}currGo=e[a]}else r=!1,go=this.remDups(go),this.gen1=go.length,1==DECORATE&&this.decorate(),go=this.remDups(go)}}growByBall(e,t){let r=[],o=e,a=t,s=99;return s=o.faces[0].center.dist(a)<=o.faces[1].center.dist(a)?0:1,r=this.render(Lstring,o,s),r}decorate(){let e=go.length;for(let t=0;t<=this.gens;t++){for(let t=currArraySize;t<e;t++){let e=[],r=0;if(rand=R.random_dec(),rand>growth_percent){let o,a=go[t];rand1=R1.random_dec(),rand1>growth_type_ratio?(o=a.ballCenter1,r=0):(o=a.ballCenter2,r=3);let s=0,n=go[0].center.dist(go[0].faces[0].center);for(let e=0;e<go.length;e++)go[e].center.dist(o)<n&&(s=1);if(0==s){go.push(new Go3d(3,v
tch",chance:.08},{name:"cross hatch",chance:.1},{name:"stipple hatch",chance:.1},{name:"dark hatch",chance:.2}],patt_lib=[{name:"cluster",chance:.55},{name:"branch",chance:.1},{name:"loop",chance:.05},{name:"hole",chance:.1},{name:"line",chance:.1},{name:"point",chance:.1}],frac_lib=[{name:"minimal",chance:.01},{name:"shallow",chance:.3},{name:"medium",chance:.36},{name:"deep",chance:.33}],scat_lib=[{name:"none",chance:.5},{name:"fragmented",chance:.5}],rndr_lib=[{name:"complete",chance:.9},{name:"proof",chance:.1}],scale_cat=new Category(scale_lib);scale_cat.setByChance(),scale_cat.sum();let colr_cat=new Category(colr_lib);colr_cat.setByChance(),colr_cat.sum();let bkgd_cat=new Category(bkgd_lib);bkgd_cat.setByChance(),bkgd_cat.sum();let frac_cat=new Category(frac_lib);frac_cat.setByChance(),frac_cat.sum();let patt_cat=new Category(patt_lib);patt_cat.setByChance(),patt_cat.sum();let scat_cat=new Category(scat_lib);scat_cat.setByChance(),scat_cat.sum();let rndr_cat=new Category(rndr_lib);rndr_cat.setByChance(),rndr_cat.sum();let scale_f=scale_cat.pickCategory().name,colr_f=colr_cat.pickCategory().name,bkgd_f=bkgd_cat.pickCategory().name,frac_f=frac_cat.pickCategory().name,patt_f=patt_cat.pickCategory().name,scat_f=scat_cat.pickCategory().name,rndr_f=rndr_cat.pickCategory().name,run_animation=!0,DECORATE=!0,prtScn=!1,swap=!1,camZoomInit=!0,mobile=!1;WIDTH=window.innerWidth,HEIGHT=window.innerHeight;2400==window.innerWidth&&2400==window.innerHeight&&(run_animation=!1),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(run_animation=!1,mobile=!0);let color0,color1,color2,hR,sR,bR,ZoomPercent=scale_lib[1].chance*Math.PI;if(colr_f==colr_cat.arr[0].name){let e=R.random_dec();e<.9?hR=R11.random_num(30,65):(hR=R.random_int(0,105)-40,hR<0&&(hR+=360)),sR=R.random_int(6,15),bR=R.random_int(78,100)}else colr_f==colr_cat.arr[1].name?(hR=R.random_int(65,320),sR=R.random_int(6,15),bR=R.random_int(78,100)):colr_f==colr_cat.arr[2].name?(hR=R.random_int(0,360),sR=R.random_int(0,2),bR=R.random_int(78,94)):colr_f==colr_cat.arr[3].name&&(hR=R.random_int(0,360),sR=R.random_int(0,1),bR=R.random_int(96,100));if(bkgd_f==bkgd_cat.arr[0].name?(BKTEXT=!1,BKGRID=!1,bkUniform=[[0,0,0,0],[0,0],[0,0,0,0],[0,0],[0,100.16,100.16,2.88],[2.88,0],[0,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[4.35,.86,.86,.86],[.86,0],[0,43.752,41.752,24.216],[0,1.2],[0,-.26,-.26,.1],[0,0],[0,.376,.376,.376],[0,1],1,[0,0,0,0],.796]):bkgd_f==bkgd_cat.arr[1].name?(BLTEXT=!1,BKGRID=!0,bkUniform=[[0,0,0,0],[0,0],[0,0,0,0],[0,0],[0,100.16,100.16,2.88],[2.88,0],[0,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[4.35,.86,.86,.86],[.86,0],[0,43.752,41.752,24.216],[0,1.2],[0,-.26,-.26,.1],[0,0],[0,.376,.376,.376],[0,1],1,[0,0,0,0],.796]):bkgd_f==bkgd_cat.arr[2].name?(BKTEXT=!0,BKGRID=!1,bkrot=R.random_int(0,7)*Math.PI/4,bkfreq=0,bkamp=150,bkNscale=0,bkNmin=.65,bkNmax=.651,bkUniform=[[bkSCALE,0,0,0],[0,0],[bkrot,0,0,0],[0,0],[bkfreq,100.16,100.16,2.88],[2.88,0],[bkamp,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[4.35,.86,.86,.86],[.86,0],[bkNscale,43.752,41.752,24.216],[0,1.2],[bkNmin,-.26,-.26,.1],[0,0],[bkNmax,.376,.376,.376],[0,1],1,[0,0,0,0],.796],bkgd_f="linear hatch"):bkgd_f==bkgd_cat.arr[3].name?(BKTEXT=!0,BKGRID=!1,bkSCALE=200,bkrot=R.random_int(0,7)*Math.PI/4,bkfreq=0,bkamp=150,bkNscale=bkSCALE/4,bkNmin=.3,bkNmax=.651,bkUniform=[[bkSCALE,0,0,0],[0,0],[bkrot,0,0,0],[0,0],[bkfreq,100.16,100.16,2.88],[2.88,0],[bkamp,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[30,.86,.86,.86],[.86,0],[bkNscale,43.752,41.752,24.216],[0,1.2],[bkNmin,-.26,-.26,.1],[0,0],[bkNmax,.376,.376,.376],[0,1],1,[0,0,0,0],.796],bkgd_f="linear hatch"):bkgd_f==bkgd_cat.arr[4].name?(BKTEXT=!0,BKGRID=!1,bkSCALE=200,bkrot=R.random_int(0,7)*Math.PI/4,bkfreq=0,bkamp=150,bkNscale=bkSCALE/4,bkNmin=.3,bkNmax=.651,bkUniform=[[bkSCALE,bkSCALE,0,0],[0,0],[bkrot,bkrot+Math.PI/4*R.random_int(1,3),0,0],[0,0],[bkfreq,0,100.16,2.88],[2.88,0],[bkamp,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[30,.86,.86,.86],[.86,0],[bkNscale,bkNscale,41.752,24.216],[0,1.2],[bkNmin,bkNmin,-.26,.1],[0,0],[bkNmax,bkNmax,.376,.376],[0,1],1,[0,0,0,0],.796],bkgd_f="cross hatch"):bkgd_f==bkgd_cat.arr[5].name?(BKTEXT=!0,BKGRID=!1,bkUniform=UNIVAR[R.random_int(1,2)],bkgd_f="cross hatch"):bkgd_f==bkgd_cat.arr[6].name&&(BKTEXT=!0,BKGRID=!1,bkUniform=UNIVAR[R.random_int(6,7)]),patt_f==patt_cat.arr[0].name){let e,t=R.random_dec();t<=.6?e=0:(e=pattOrgClust.length-1,e=R.random_int(1,e)),pattDirector=pattOrgClust[e]}else if(patt_f==patt_cat.arr[1].name){let e=pattOrgBranch.length-1;e=R.random_int(0,e),pattDirector=pattOrgBranch[e]}else if(patt_f==patt_cat.arr[2].name){let e=pattOrgLoop.length-1;e=R.random_int(0,e),pattDirector=pattOrgLoop[e]}else if(patt_f==patt_cat.arr[3].name){let e=pattOrgHole.length-1;e=R.random_int(0,e),pattDirector=pattOrgHole[e]}else if(patt_f==patt_cat.arr[4].name){let e=pattOrgLine.length-1;e=R.random_int(0,e),pattDirector=pattOrgLine[e]}else if(patt_f==patt_cat.arr[5].name){let e=pattOrgPT.length-1;e=R.random_int(0,e),pattDirector=pattOrgPT[e],Lstring="ffff+fff+ff+fff+f+fff+f+ffff+ff"}if(pS=pattDirector[1],1==pattDirector[2])frac_f=frac_cat.arr[0].name;else if(0==pattDirector[2]){let e=R.random_dec();frac_f=e<=.5?frac_cat.arr[3].name:frac_cat.arr[2].name}else-1==pattDirector[2]||2==pattDirector[2]||3==pattDirector[2]&&(frac_f=frac_cat.arr[1].name);if(frac_f==frac_cat.arr[0].name?(growth_Max=10,growth_percent=.8,growth_type_ratio=.5,small_death_chance=.2):frac_f==frac_cat.arr[1].name?(growth_Max=6,growth_percent=.7,growth_type_ratio=.5,small_death_chance=.15):frac_f==frac_cat.arr[2].name?(growth_Max=1,growth_percent=0,growth_type_ratio=.5,small_death_chance=.1):frac_f==frac_cat.arr[3].name&&(growth_Max=2,growth_percent=.6,growth_type_ratio=.5,small_death_chance=.04),scat_f==scat_cat.arr[0].name||scat_f==scat_cat.arr[1].name&&(ERASE=!0),rndr_f==rndr_cat.arr[0].name);else if(rndr_f==rndr_cat.arr[1].name){let e=R.random_dec();e<.5?WIREFRAME=!0:OPAQUE=!0}let growthPts=[[{x:0,y:0,z:0},{x:R.random_int(1,Math.floor(growth_Max/2))+Math.floor(growth_Max/2),y:R.random_int(1,growth_Max-1),z:R.random_int(1,growth_Max-1)}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:0,y:pS,z:pS},{x:0,y:pS,z:0},{x:pS,y:pS,z:0}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:0,y:pS,z:pS},{x:0,y:pS,z:0},{x:pS,y:pS,z:0},{x:0,y:pS,z:0},{x:pS,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:0,y:-pS,z:0},{x:0,y:0,z:0},{x:pS,y:0,z:0},{x:-pS,y:0,z:0},{x:0,y:0,z:0},{x:0,y:0,z:pS},{x:0,y:0,z:pS}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:pS,y:pS,z:0},{x:pS,y:0,z:0},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:0,z:pS},{x:0,y:pS,z:pS},{x:0,y:pS,z:0},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:0,z:pS},{x:pS,y:0,z:pS},{x:pS,y:0,z:0},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:pS,y:pS,z:pS},{x:pS,y:0,z:pS},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:pS,y:pS,z:pS}],[{x:0,y:0,z:0},{x:1,y:1,z:1}],[{x:0,y:0,z:0},{x:2,y:2,z:2},{x:0,y:1,z:0},{x:0,y:0,z:0},{x:0,y:0,z:0},{x:0,y:1,z:0},{x:0,y:0,z:0}]];patternSelect=growthPts[pattDirector[0]],UNIVAR.push(bkUniform);let xGridMax=-1e3,yGridMax=-1e3,zGridMax=-1e3;for(i=0;i<patternSelect.length;i++)patternSelect[i].x>=xGridMax&&(xGridMax=patternSelect[i].x),patternSelect[i].y>=yGridMax&&(yGridMax=patternSelect[i].y),patternSelect[i].z>=zGridMax&&(zGridMax=patternSelect[i].z);bkGridDrawBoundsX=xGridMax+5,bkGridDrawBoundsY=yGridMax+5,bkGridDrawBoundsZ=zGridMax+5;let ignX=!1,ignY=!1,ignZ=!1,ignR=R.random_dec();for(ignR<=.33?ignX=!0:ignR>=.66?ignY=!0:ignZ=!0,i=0;i<patternSelect.length;i++)patternSelect[i].x+=Math.floor(bkGridTrueMax/2),patternSelect[i].y+=Math.floor(bkGridTrueMax/2),patternSelect[i].z+=Math.floor(bkGridTrueMax/2);let bkG,txG,dSX=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),dFX=bkGridDrawBoundsX+dSX,dSY=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),dFY=bkGridDrawBoundsY+dSY,dSZ=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),dFZ=bkGridDrawBoundsZ+dSZ,renderPattern=[],zoomRRR=R4.random_num(0,1);zoomRR=R4.random_num(0,Math.PI),scale_f=scale_cat.arr[0].name,Math.abs((myAngle+zoomRR)%Math.PI)<=ZoomPercent&&(scale_f=scale_cat.arr[1].name,zoomRR=0);let bkS,txS,txW=2048,txH=256,txSr=2048,display={"Growth Pattern":patt_f,"Fractal Depth":frac_f,Fragmentation:scat_f,Completeness:rndr_f,Background:bkgd_f,Scale:scale_f,"Paper Color":colr_f};console.log("primatives by ArandaLasch"),console.log("Benjamin Aranda, Jesse Bassett, Joaquin Bonifaz, Chris Lasch"),console.log(" "),console.log("Growth Pattern: "+patt_f),console.log("Fractal Depth: "+frac_f),console.log("Broken/scatter: "+scat_f),console.log("Completness: "+rndr_f),console.log("Scale: "+scale_f),console.log("Background: "+bkgd_f),console.log("Paper Color: "+colr_f),window.addEventListener("keydown",function(e){["Space","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code)>-1&&e.preventDefault()},!1) ;let resetPt,resetTarg,basicVert="\n attribute vec3 aPosition;\n attribute vec2 aTexCoord;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord=aTexCoord;\n vec4 positionVec4=vec4(aPosition,1.0);\n positionVec4.xy=positionVec4.xy*2.0-1.0;\n gl_Position=positionVec4;\n }\n ",basicVert2="\n attribute vec3 aPosition;\n attribute vec2 aTexCoord;\n varying vec2 vTexCoord;\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix;\n void main() {\n vTexCoord = aTexCoord;\n vec4 positionVec4 = vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n }\n",fragShaderA="\n//Author:Jesse Bassett\n#ifdef GL_ES\nprecision mediump float;\n#endif\nvarying vec2 vTexCoord; varying vec4 Depth; uniform vec4 LF1; uniform vec2 LF2; uniform vec4 LR1; uniform vec2 LR2; uniform vec4 dA1; uniform vec2 dA2; uniform vec4 df1; uniform vec2 df2; uniform vec4 wb1; uniform vec2 wb2; uniform vec4 bb1; uniform vec2 bb2; uniform vec4 Nf1; uniform vec2 Nf2; uniform vec4 Nn1; uniform vec2 Nn2; uniform vec4 Nx1; uniform
][r][e].x,rg.gPts[n][r][e].y,rg.gPts[n][r][e].z,rg.gPts[n][o][e].x,rg.gPts[n][o][e].y,rg.gPts[n][o][e].z);if(0==ignZ)for(let n=e;n<=t;n++)for(let e=r;e<=o;e++)line(rg.gPts[n][e][a].x,rg.gPts[n][e][a].y,rg.gPts[n][e][a].z,rg.gPts[n][e][s].x,rg.gPts[n][e][s].y,rg.gPts[n][e][s].z);pop()}function windowResized(){DIM=min(windowWidth,windowHeight),resizeCanvas(DIM,DIM)}function setLineDash(e){drawingContext.setLineDash(e)}function dash_line(e,t,r,o,a,s,n,c){let i=createVector(e,t,r),l=createVector(o,a,s),m=p5.Vector.sub(l,i),d=m.mag(),h=int(d/(n+c));push(),translate(e,t,r);let g=m.copy().setMag(n),f=m.copy().setMag(n+c);for(let e=0;e<h;e++)line(0,0,0,g.x,g.y,g.z),translate(f.x,f.y,f.z);pop()}function updateCam(){for(push(),rotateZ(cam[2]),rotateY(cam[1]),push(),i=0;i<steps;i++)0==renderPattern[i]?(1==mobile?texture(txG):texture(myImg),model(goModels[i])):1==renderPattern[i]||(2==renderPattern[i]?(noStroke(),fill(255),model(goModels[i]),noFill()):3==renderPattern[i]?(stroke(0),strokeWeight(1),noFill(),model(goModels[i]),noStroke()):4==renderPattern[i]?(stroke(0),strokeWeight(1),fill(255),model(goModels[i]),noStroke(),noFill()):5==renderPattern[i]?(1==mobile?texture(txG):texture(myImg),stroke(0),strokeWeight(1),model(goModels[i]),noStroke()):(noStroke(),1==mobile?texture(txG):texture(myImg),model(goModels[i])));if(pop(),1==BKGRID&&drawGrid(),pop(),ratio>0&&ratio<1){ratio>=.99999&&(ratio=1),zoom=lerp(zoomStart,zoomTarg,ratio),cam[0]=lerp(camStart[0],camTarg[0],ratio),cam[1]=lerp(camStart[1],camTarg[1],ratio),cam[2]=lerp(camStart[2],camTarg[2],ratio),v=lerp(vStart,vTarg,ratio);let e=1-ratio;ratio+=e*easing,1==camZoomInit&&(ratio=.99999,zoom=defaultZoom/2,camZoomInit=!1)}ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4)}function pointRotateY(e,t){let r=new p5.Vector;return r.x=e.z*Math.sin(t)+e.x*Math.cos(t),r.y=e.y,r.z=e.z*Math.cos(t)-e.x*Math.sin(t),r}function pointRotateZ(e,t){let r=new p5.Vector;return r.x=e.x*Math.cos(t)-e.y*Math.sin(t),r.y=e.x*Math.sin(t)+e.y*Math.cos(t),r.z=e.z,r}function reflect3d(e,t){let r=new p5.Vector(0,0,0),o=new Face(t.facePts[0],t.facePts[1],t.facePts[2]),a=new p5.Vector(o.facePts[0].x,o.facePts[0].y,o.facePts[0].z),s=p5.Vector.sub(o.facePts[1],o.facePts[0]),n=p5.Vector.sub(o.facePts[2],o.facePts[0]),c=n.cross(s);if(c.normalize(),gTestPV0=a,gTestPV1=s,gTestPV2=n,0==e.dist(o.facePts[0])||0==e.dist(o.facePts[1])||0==e.dist(o.facePts[2]))r.x=e.x,r.y=e.y,r.z=e.z;else{let t=p5.Vector.sub(e,o.facePts[0]),s=Math.abs(t.angleBetween(c)),n=t.cross(c);n.normalize(),n.mult(20),testCross1=new p5.Vector(n.x,n.y,n.z),n.normalize();let i=c.cross(n);i.normalize(),i.mult(t.mag()*sin(s)),c.normalize(),c.mult(t.mag()*cos(s));let l=new p5.Vector(c.x,c.y,c.z);l.mult(-1),r.x=l.x,r.y=l.y,r.z=l.z,retV1=new p5.Vector(r.x,r.y,r.z),r.add(i),retV2=new p5.Vector(r.x,r.y,r.z),r.add(a),retV3=new p5.Vector(r.x,r.y,r.z)}return r}function scale3d(e,t,r){let o=new p5.Vector(0,0,0);return o.x=e.x+-1*t.x,o.y=e.y+-1*t.y,o.z=e.z+-1*t.z,o.x=o.x*r,o.y=o.y*r,o.z=o.z*r,o.x=o.x+t.x,o.y=o.y+t.y,o.z=o.z+t.z,o}function vertex_average(e){let t=new p5.Vector(0,0,0);for(let r=0;r<e.length;r++)t.x=t.x+e[r].x,t.y=t.y+e[r].y,t.z=t.z+e[r].z;let r=e.length;return t.x=t.x/r,t.y=t.y/r,t.z=t.z/r,t}document.oncontextmenu=(()=>!1);class Random{constructor(){this.useA=!1;let e=function(e){let t=parseInt(e.substr(0,8),16),r=parseInt(e.substr(8,8),16),o=parseInt(e.substr(16,8),16),a=parseInt(e.substr(24,8),16);return function(){t|=0,r|=0,o|=0,a|=0;let e=(t+r|0)+a|0;return a=a+1|0,t=r^r>>>9,r=o+(o<<3)|0,o=o<<21|o>>>11,o=o+e|0,(e>>>0)/4294967296}};this.prngA=new e(tokenData.hash.substr(2,32)),this.prngB=new e(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(e,t){return e+(t-e)*this.random_dec()}random_int(e,t){return Math.floor(this.random_num(e,t+1))}}let R,R1,R2,R3,R4,R10,R11,grw;R=new Random,R1=new Random,R2=new Random,R3=new Random,R4=new Random,R10=new Random,R11=new Random;class Category{constructor(e=[{name:"default",chance:1,amount:1,min:0,max:1}]){this.count=500,this.arr=e,this.select={}}setByAmount(){let e=0;for(let t=0;t<this.arr.length;t++)e+=this.arr[t].amount;this.count=e;for(let e=0;e<this.arr.length;e++)this.arr[e].chance=this.arr[e].amount/this.count}setByChance(e=this.count){let t=0;for(let e=0;e<this.arr.length;e++)t+=this.arr[e].chance;if(t>=.9999999999&&t<=1.00000000001)for(let e=0;e<this.arr.length;e++)this.arr[e].amount=this.arr[e].chance*this.count;else console.log("Improper Sum: "+t)}sum(){let e=[],t=[];t.push(0);for(let r=0;r<this.arr.length;r++)e.push(this.arr[r].chance),t.push(this.arr[r].chance);t.pop(),e=partialSum(e),t=partialSum(t);for(let r=0;r<this.arr.length;r++)this.arr[r].min=t[r],this.arr[r].max=e[r]}pickCategory(){let e,t=R.random_dec();for(let r=0;r<this.arr.length;r++)this.arr[r].min<=t&&t<this.arr[r].max&&(e=this.arr[r].name);return this.select={name:e,value:t},{name:e,value:t}}setCategory(e){let t,r=0;for(let r=0;r<this.arr.length;r++)e==this.arr[r].name&&(t=this.arr[r].name);return this.select={name:t,value:r},{name:t,value:r}}setCategoryValue(e){let t,r;for(let o=0;o<this.arr.length;o++)this.arr[o].min<=e&&e<this.arr[o].max&&(r=this.arr[o].name,t=e);return this.select={name:r,value:t},{name:r,value:t}}}let currGo,currFace,currPoint,targetPt,go=[],resetGo=[],goDepot=[],resetDepot=[],steps=0,currArraySize=0,zflag=0,sun=new p5.Vector(1,-1,1);sun.normalize();let geom,timer,img,centerX,centerY,centerZ,xMin,xMax,yMin,yMax,zMin,zMax,goNum,rand,rand1,rand2,rand3,zoomRR,num,myAngle=0,mGo=0,goModels=[],goModelsDepot=[],delay=3,bBox=[],currCluster=0,grow=1,initGrow=!0;var DEFAULT_SIZE=1400,WIDTH=window.innerWidth,HEIGHT=window.innerHeight,DIM=Math.min(WIDTH,HEIGHT),M=DIM/DEFAULT_SIZE;let myImg,canvas,shaderA,rg,patternSelect,bkImg,shaderBK,bkUniform,Lstring="ffff+fff",shad_Size=512,drawTex=!0,UNI=["LF1","LF2","LR1","LR2","dA1","dA2","df1","df2","wb1","wb2","bb1","bb2","Nf1","Nf2","Nn1","Nn2","Nx1","Nx2","indx","Ld","cBlend"],sG=10,UNIVAR=[[[54.64+sG,49.324+sG,40.324+sG,50+sG],[80.48+sG,0],[1.57079632679,-.788,-.788,-4.668],[3.604,0],[2,100.16,100.16,2.88],[2.88,0],[147.2,516.8,516.8,589.6],[589.6,0],[3.424,4.816,4.816,4.056],[3.592,0],[1.484,.86,.86,.86],[.86,0],[40,43.752,41.752,24.216],[0,1.2],[-.02,-.26,-.26,.1],[0,0],[.304,.376,.376,.376],[0,1],1,[0,0,0,0],.796],[[52.696+sG,54.324+sG,55.324+sG,62.392+sG],[80.48+sG,0],[0,.796,1.64,3.196],[5.332,5],[11.712,100.16,100.16,2.88],[2.88,0],[247.2,516.8,516.8,589.6],[589.6,0],[2.904,3.608,3.192,3.224],[3.592,0],[1.484,.86,.86,.86],[.86,0],[16.376,35.832,36.136,3.312],[4.152,-1.152],[0,.22,-.124,.1],[.1,.1],[0,.4,.56,1.128],[1.128,1],2,[0,0,0,0],.796],[[54.64+sG,49.324+sG,49.324+sG,49.284+sG],[80.48+sG,0],[0,1.58,4.548,2.316],[3.604,0],[11.712,100.16,100.16,98.696],[2.88,0],[247.2,516.8,516.8,621.6],[589.6,0],[3.488,3.088,3.056,3.848],[3.592,0],[1.484,.86,.86,.86],[.86,0],[16.376,35.832,36.136,36.136],[4.152,-1.5],[-0,-.26,-.124,-.124],[.1,.1],[.4,.4,.56,.592],[1.128,1],3,[0,0,0,0],.796],[[60.32+sG,49.324+sG,49.324+sG,49.284+sG],[80.408+sG,0],[2.227,.836,6.828,2.316],[3.932,0],[11.632,11.256,100.16,98.696],[2.88,0],[553.6,290.4,516.8,621.6],[589.6,0],[2.92,3.84,3.712,3.88],[2.832,0],[.276,1.188,.86,.86],[.86,0],[16.376,35.832,36.136,36.136],[4.152,.7],[.388,.212,-.124,-.124],[.1,.1],[1.024,.424,.56,.592],[1.544,1],4,[-.168,2.336,1.506,.952],.81],[[53.72+sG,46.468+sG,49.324+sG,49.284+sG],[50.352+sG,0],[3.963,2.032,6.876,.1],[2.604,0],[13.384,11.112,100.16,98.696],[3.24,0],[487.2,290.4,516.8,621.6],[589.6,0],[2.696,2.808,2.488,2.96],[1.464,0],[.196,1.188,.9,.86],[.86,0],[16.376,35.832,24.264,33.872],[3.2,-.8],[.572,.212,-.124,-.124],[-.084,.05],[.976,.656,.48,.592],[1.816,.9],5,[.63,.378,.601,3.632],.924],[[58.408+sG,46.468+sG,53.916+sG,51.336+sG],[40.424+sG,0],[4.707,1.104,6.676,2.596],[2.98,0],[12.208,10.12,100.16,98.704],[2.88,0],[578.4,290.4,516.8,621.6],[589.6,0],[1.156,2.376,2.376,2.168],[2.208,0],[.708,1.188,.86,.86],[.86,0],[18.168,40.832,25,3.136],[3.112,1.112],[.108,.212,-.124,-.116],[.1,.1],[1.304,.512,.56,1.072],[1.104,1.104],6,[0,0,0,0],.796],[[60.32+sG,60.324+sG,61.692+sG,61.336+sG],[50.424+sG,0],[2.091,.796,4.724,2.596],[4.788,0],[18.376,10.544,100.16,98.704],[2.88,0],[553.6,444,516.8,621.6],[589.6,0],[1.616,2.28,2.72,2.312],[1.776,0],[1.484,1.188,.86,.86],[.86,0],[16.744,35.832,36.136,3.136],[4.336,0],[.388,.212,-.508,-.124],[.1,0],[1.096,1.248,1.36,.592],[1.768,0],7,[0,0,0,0],.796],[[60.32+sG,80.324+sG,51.692+sG,60.368+sG],[1+sG,0],[6.427,1.012,6.828,4.836],[1,0],[11.632,10.056,100.16,98.696],[4,0],[553.6,444,516.8,621.6],[.4,0],[1.44,.92,2.256,2.024],[.2,0],[1.484,1.188,.86,.86],[.2,0],[16.16,35.832,36.136,3.136],[.1,0],[.388,.212,-.508,-.124],[0,0],[1.096,1.248,1.784,.496],[0,0],8,[0,0,0,0],.796]],gBorder=1,gScale=20,gVals=7+gBorder,growth_Max=7,growth_percent=.5,growth_type_ratio=.5,small_death_chance=.1,BKGRID=!1,bkGridTrueMax=27,bkGridDrawBoundsX=11,bkGridDrawBoundsY=11,bkGridDrawBoundsZ=11,pS=1,BKTEXT=!1,bkrez=2048,bkSCALE=250,bkrot=0,bkfreq=0,bkamp=0,bkNscale=0,bkNmin=0,bkNmax=0,pattDirector=[],pattOrgClust=[[0,0,-1],[1,2,0],[2,2,0],[4,2,0],[5,2,0],[7,2,0],[3,2,1],[4,3,1],[6,2,1],[7,2,1]],pattOrgBranch=[[1,3,3],[2,4,3],[1,4,3],[1,3,3],[2,4,3],[1,4,3],[1,5,1],[1,6,1],[1,7,1],[2,5,1],[3,4,1]],pattOrgLoop=[[4,4,1],[4,5,1],[5,4,1],[5,5,1],[6,5,1],[7,3,1],[7,4,1]],pattOrgLine=[[8,3,3],[8,4,3],[8,3,3],[8,4,3],[8,3,3],[8,4,3],[8,5,1],[8,6,1],[8,7,1]],pattOrgHole=[[10,0,-1],[10,0,-1],[10,0,-1],[2,3,1],[4,4,1],[6,3,1]],pattOrgPT=[[9,0,-1],[9,0,-1],[9,0,-1],[9,0,-1],[9,0,-1],[9,0,-1],[9,0,0],[9,0,0],[9,0,0],[9,0,0],[9,0,0],[9,0,0],[9,0,1]],ERASE=!1,WIREFRAME=!1,OPAQUE=!1,scale_lib=[{name:"fit",chance:.8},{name:"zoom",chance:.2}],colr_lib=[{name:"warm",chance:.55},{name:"cool",chance:.15},{name:"grey",chance:.2},{name:"white",chance:.1}],bkgd_lib=[{name:"blank",chance:.3},{name:"grid lattice",chance:.15},{name:"linear hatch",chance:.07},{name:"noise ha
// primatives by Aranda\Lasch // Benjamin Aranda, Jesse Bassett, Joaquin Bonifaz, Chris Lasch function partialSum(e){return e.reduce((e,t,r,o)=>{const a=o.slice(0,r+1),s=a.reduce((e,t)=>e+t,0);return[...e,s]},[])}function setup(){colorMode(HSB),canvas=createCanvas(DIM,DIM,WEBGL),noStroke(),rect(100*M,500*M,50*M,50*M),pixelDensity(2),1==mobile?(txG=createGraphics(txW,txH,WEBGL),txS=txG.createShader(basicVert2,fragShaderA)):(shaderA=createShader(basicVert,fragShaderA),shaderA.setUniform("u_resolution",[DIM,DIM]),shad_Size=1024,bkrez=2800,myImg=createImage(8*shad_Size,shad_Size)),shaderBK=createShader(basicVert,fragShaderA),shaderBK.setUniform("u_resolution",[bkrez,bkrez]),bkImg=createImage(bkrez,bkrez),sPress(),sun=new p5.Vector(1,-1,1),sun.normalize(),gBorder=2,gScale=20,gVals=growth_Max+gBorder,gVals=bkGridTrueMax,grw=new GrowSys(1),rg=new Grid_Rhomb(gVals,gVals,gVals,gScale);let e=patternSelect[0];for(targetPt=rg.gPts[e.x][e.y][e.z],patternSelect.shift(),go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0],goNum=1,i=0;i<goNum;i++){goDepot[i]=[],resetDepot[i]=[],nextGrow();for(let e=0;e<go.length;e++){resetDepot[i][e]=[];for(let t=0;t<go[e].verts.length-2;t++)resetDepot[i][e].push(new p5.Vector(go[e].verts[t].x,go[e].verts[t].y,go[e].verts[t].z))}goDepot[i]=go,goModelsDepot.push(goModels)}currCluster=goNum-1,grow=-1,timer=0,color0=color(hR,sR,bR),color1=color0,color2=color0;let t=R.random_int(1/6*goModels.length,.8*goModels.length),r=Math.round(5/12*goModels.length),o=t+r*(1/3),a=t+.5*r,s=t+r*(2/3),n=t+1*r,c=R.random_int(0,3);for(i=0;i<goModels.length;i++)renderPattern.push(0),1==ERASE&&i>5&&i<.33*goModels.length&&(renderPattern[i]=1),1==WIREFRAME?0==c?i>t&&i<n&&(renderPattern[i]=3):1==c?i>t&&i<a?renderPattern[i]=3:i>a&&i<n&&(renderPattern[i]=5):2==c?i>t&&i<o?renderPattern[i]=3:i>o&&i<s&&(renderPattern[i]=3):i>s&&i<n?renderPattern[i]=5:i>t&&i<n&&(renderPattern[i]=3):1==OPAQUE?i>t&&i<n&&(renderPattern[i]=2):renderPattern.push(0)}function draw(){if(1==drawTex){if(drawTex=!1,1==mobile){txG.noStroke(),txG.shader(txS),txS.setUniform("u_resolution",[txH,txH]);for(let e=0;e<8;e++)console.log("txG mode, Jesse"),readUniforms(txS,e),txG.rect(e*txW/8-txW/2,-txH/2,txW/8,txH);txG.resetShader()}else{shaderA.setUniform("u_resolution",[shad_Size,shad_Size]),shader(shaderA),resizeCanvas(shad_Size,shad_Size,!1);for(let e=0;e<8;e++)readUniforms(shaderA,e),rect(0,0,40,40),myImg.copy(canvas,0,0,2*shad_Size,2*shad_Size,shad_Size*e,0,2*shad_Size,2*shad_Size);resetShader()}resizeCanvas(bkrez,bkrez,!1),shader(shaderBK);let e=2*v;UNIVAR[8][0][0]=e,bkgd_f!=bkgd_cat.arr[2].name&&(UNIVAR[8][0][1]=e+R.random_num(-20,20),UNIVAR[8][0][2]=e+R.random_num(-30,30),UNIVAR[8][0][3]=e+R.random_num(-30,20),UNIVAR[8][1][0]=e+R.random_num(-20,30)),UNIVAR[8][12][0]*=e/60,UNIVAR[8][12][1]*=e/60,UNIVAR[8][12][2]*=e/60,UNIVAR[8][12][3]*=e/60,UNIVAR[8][13][0]*=e/60,readUniforms(shaderBK,8),rect(0,0,40,40),bkImg.copy(canvas,0,0,bkrez,bkrez,0,0,bkrez,bkrez),resetShader(),resizeCanvas(DIM,DIM,!1)}if(background(color1),makeBorder(),lightFalloff(.003,3e-4,0),ambientLight(color0),noStroke(),0==run_animation&&(steps=go.length),1==grow)steps>=go.length?steps=go.length:millis()>timer&&(timer+=delay,steps++);else if(-1==grow)if(steps<=1){currCluster+=1,currCluster>goNum-1&&(currCluster=0),1==initGrow&&(go=[],resetGo=[],go=goDepot[currCluster].slice(),resetGo=resetDepot[currCluster].slice(),goModels=goModelsDepot[currCluster],initGrow=!1),zoomStart=zoom,camStart=[cam[0],cam[1],cam[2]],camTarg=[camTarg[0],camTarg[1],camTarg[2]];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)go[e].verts[t]=new p5.Vector(resetGo[e][t].x,resetGo[e][t].y,resetGo[e][t].z);ratio=+camSpeed,vStart=vTarg,steps=1,grow*=-1}else millis()>timer&&(timer+=delay,steps-=3);if(push(),stroke(255,0,0),strokeWeight(6),line(0,0,0,0,0,1e5),pop(),updateCam(),1==swap&&(save("primative"),pixelDensity(2),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),prtScn=!1,swap=!1),1==prtScn){let e=4800/DIM;pixelDensity(e),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),swap=!0}}function readUniforms(e,t){for(let r=0;r<UNI.length;r++)e.setUniform(UNI[r],UNIVAR[t][r])}function lPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]+angle,camTarg[2]+angle],zoomStart=zoom,myAngle+=angle,zflag--,zflag<0&&(zflag=2),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function rPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]-angle,camTarg[2]-angle],zoomStart=zoom,myAngle-=angle,zflag++,zflag>=3&&(zflag=0),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function sPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[cam[0],cam[1],cam[2]],Math.abs((myAngle+zoomRR)%Math.PI)<=ZoomPercent?(zoomTarg=defaultZoom/2,zflag=0):(zoomTarg=defaultZoom,zoomRRR>=.5?zflag=1:zoomRRR<=.5&&(zflag=2)),zoomStart=zoomTarg,ratio=+camSpeed,ratio=.98999}function touchStarted(){mouseX>WIDTH/2?rPress():mouseX<WIDTH/2&&lPress()}function keyPressed(){if(keyCode===LEFT_ARROW?lPress():keyCode===RIGHT_ARROW?rPress():keyCode===UP_ARROW?(zoomStart=zoom,zoomTarg=defaultZoom/2,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()):keyCode===DOWN_ARROW&&(zoomStart=zoom,zoomTarg=defaultZoom,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()),"o"==key||"O"==key){let e=[],t=[],r=0;for(let o=0;o<go.length;o++)if(1!=renderPattern[o])for(let a=0;a<go[o].faces.length;a++){for(let t=0;t<go[o].faces[a].facePts.length;t++)e.push("v "+go[o].faces[a].facePts[t].x+" "+go[o].faces[a].facePts[t].y+" "+go[o].faces[a].facePts[t].z),r+=1;t.push("f "+(r-2)+" "+(r-1)+" "+r)}let o=e.concat(t);saveStrings(o,"primitive","obj")}"i"!=key&&"I"!=key||(prtScn=!0,console.log(prtScn),console.log(swap)),"u"!=key&&"U"!=key||myImg.save("primatives texture","png"),"g"!=key&&"G"!=key||(run_animation=!0,grow=-1)}function makeBorder(){push(),scale(zoom),fill(color2);let e=.1*v/1.15;1==BKTEXT&&(push(),lightFalloff(.003,3e-4,0),ambientLight(color0),texture(bkImg),translate(0,0,-1e3),box(1.15*(2*v-e)/zoom,1.15*(2*v-e)/zoom),pop()),push(),translate(-1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(0,1.15*v/1.15,1e3),box(5*v,e),pop(),push(),translate(0,-1.15*v/1.15,1e3),box(5*v,e),pop(),pop()}function nextGrow(){cam=[0,cam[1]-myAngle,cam[2]-myAngle],camStart=[0,camStart[1]-myAngle,camStart[2]-myAngle],camTarg=[0,camTarg[1]-myAngle,camTarg[2]-myAngle],v=0,vStart=0,vTarg=0,steps=0,mGo=0,go=[],goModels=[],go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0];R.random_int(1,Math.floor(growth_Max/2)),Math.floor(growth_Max/2),R.random_int(1,growth_Max-1),R.random_int(1,growth_Max-1);currArraySize=go.length;for(let e=0;e<patternSelect.length;e++){let t=patternSelect[e];grw.growToTarget(rg.gPts[t.x][t.y][t.z])}getModelExtents();for(let e=0;e<go.length;e++){go[e].center.x+=-centerX,go[e].center.y+=-centerY,go[e].center.z+=-centerZ;for(let t=0;t<go[e].faces.length;t++){go[e].faces[t].center.x+=-centerX,go[e].faces[t].center.y+=-centerY,go[e].faces[t].center.z+=-centerZ;for(let r=0;r<go[e].faces[t].facePts.length;r++)go[e].faces[t].facePts[r].x+=-centerX,go[e].faces[t].facePts[r].y+=-centerY,go[e].faces[t].facePts[r].z+=-centerZ}}for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length;t++)go[e].verts[t].x+=-centerX,go[e].verts[t].y+=-centerY,go[e].verts[t].z+=-centerZ;xMax+=-centerX,xMin+=-centerX,yMax+=-centerY,yMin+=-centerY,zMax+=-centerZ,zMin+=-centerZ,getModelExtents(),0==v&&(v=vTarg,vStart=vTarg);for(let e=0;e<go.length;e++)geom=new p5.Geometry(1,1,buildModel),geom.gid="go"+mGo+"_"+R.random_dec(),goModels.push(geom),mGo++}function buildModel(){let e=0;for(let t=0;t<go[mGo].faces.length;t++){let r=[];for(let o=0;o<go[mGo].faces[t].facePts.length;o++)this.vertices.push(go[mGo].faces[t].facePts[o]),r.push(e),e+=1;this.faces.push([r[0],r[1],r[2]]),n=createVector(go[mGo].faces[t].normal.x,go[mGo].faces[t].normal.y,go[mGo].faces[t].normal.z),n.normalize(),this.vertexNormals.push(n,n,n);let o=1/8,a=sun.dot(n),s=(sun.angleBetween(n),map(a,-1,1,0,7));s=round(s);let c=this.vertices[r[0]].dist(this.vertices[r[1]]),i=this.vertices[r[0]].dist(this.vertices[r[2]]),l=this.vertices[r[1]].dist(this.vertices[r[2]]);c=map(c,0,41.71563256142714,0,1),i=map(c,0,41.71563256142714,0,1),l=map(c,0,41.71563256142714,0,1),"e"==go[mGo].faces[t].type?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.866*c*o,c/2])):c>i&&c>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.809*c*o,c/2])):i>c&&i>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s+.809*i*o,i/2]),this.uvs.push([o*s,i])):l>c&&l>i&&(this.uvs.push([o*s+.809*l*o,l/2]),this.uvs.push([o*s,0]),this.uvs.push([o*s,l]));let m=R3.random_dec(),d=R4.random_dec();if(m<=.5)for(let e=0;e<this.uvs.length;e++)this.uvs[e][1]=1-this.uvs[e][1];if(d<=.5)for(let e=0;e<this.uvs.length;e++);}}function getModelExtents(){let e,t,r=[],o=[],a=[];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)r.push(go[e].verts[t].x),o.push(go[e].verts[t].y),a.push(go[e].verts[t].z);r.sort((e,t)=>e-t),o.sort((e,t)=>e-t),a.sort((e,t)=>e-t),xMin=r[0],xMax=r[r.length-1],yMin=o[0],yMax=o[o.length-1],zMin=a[0],zMax=a[a.length-1],centerX=(xMax-xMin)/2+xMin,centerY=(yMax-yMin)/2+yMin,centerZ=(zMax-zMin)/2+zMin,e=Math.max(xMax,Math.abs(xMin)),t=Math.max(yMax,Math.abs(yMin)),vTarg=Math.max(e,t)}function drawGrid(){push();let e=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),t=bkGridDrawBoundsX+e,r=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),o=bkGridDrawBoundsY+r,a=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),s=bkGridDrawBoundsZ+a;if(stroke(0,0,0),strokeWeight(1),0==ignX)for(let n=r;n<=o;n++)for(let r=a;r<=s;r++)line(rg.gPts[e][n][r].x,rg.gPts[e][n][r].y,rg.gPts[e][n][r].z,rg.gPts[t][n][r].x,rg.gPts[t][n][r].y,rg.gPts[t][n][r].z);if(0==ignY)for(let n=e;n<=t;n++)for(let e=a;e<=s;e++)line(rg.gPts[n
){let o,a=e,s=t,c=a.length,n=[],i=2;o=0==r?0:3;for(let e=0;e<c;e++){let t=a.charAt(e);if("f"==t){0==o?i=2==i?6:2:1==o?i=2==i?4:4==i?2:4:2==o?i=2==i?6:6==i?2:6:3==o?i=3==i?5:3:4==o&&(i=5==i?7:5),n.push(new Go3d(2,void 0,void 0,void 0,void 0,void 0,s.faces[i],s));let e=n[n.length-1];s=e}else"+"==t?o<3?(o+=1,o>2&&(o=0)):(o+=1,o>4&&(o=3)):"/"==t&&(o=o<3?3:0)}return n}}class Face{constructor(e,t,r,o){this.type=o,this.facePts=[],this.center=new p5.Vector,this.facePts[0]=createVector(e.x,e.y,e.z),this.facePts[1]=createVector(t.x,t.y,t.z),this.facePts[2]=createVector(r.x,r.y,r.z),this.center=vertex_average(this.facePts),this.normal=p5.Vector.sub(this.facePts[1],this.facePts[0]).cross(p5.Vector.sub(this.facePts[2],this.facePts[0])),this.normal.mult(-1),this.normal.normalize()}}
r(x+0.5); vec3 a0=x-ox; m*=1.79284291400159-0.85373472095314*(a0*a0+h*h); vec3 g=vec3(0.0); g.x=a0.x*x0.x+h.x*x0.y; g.yz=a0.yz*vec2(x1.x,x2.x)+h.yz*vec2(x1.y,x2.y); return 130.0*dot(m,g);} vec2 rotateUV(vec2 uv,float rotation) {return vec2(cos(rotation)*(uv.x-0.5)+sin(rotation)*(uv.y-0.5)+0.5,cos(rotation)*(uv.y-0.5)-sin(rotation)*(uv.x-0.5)+0.5);} float SmoothStep(float edge0,float edge1,float x){float t=clamp((x-edge0) / (edge1-edge0),0.0,1.0); return t;} void main() {vec2 st=vTexCoord; vec2 st_1=st; vec2 st_2=st; vec2 st_3=st; vec2 st_4=st; vec2 st_5=st; vec2 st_6=st; vec3 color=vec3(0.0); st_1=rotateUV(st,LR1.x); st_1.x+=cos(st_1.y*dA1.x)/df1.x; st_1.y+=sin(st_1.x*dA1.x)/df1.x; float pos_1=st_1.x*LF1.x; float y=0.; float x=pos_1; y=sin((x+Ld.z)*Ld.y); y+=sin((x+Ld.z)*Ld.y*2.1+Ld.w)*4.5; y+=sin((x+Ld.z)*Ld.y*1.72+Ld.w*1.121)*4.0; y+=sin((x+Ld.z)*Ld.y*2.221+Ld.w*0.437)*5.0; y+=sin((x+Ld.z)*Ld.y*3.1122+Ld.w*4.269)*2.5; y*=Ld.x*0.06; pos_1=pos_1+y; float colL_1=wb1.x*bb1.x*((cos(pos_1*2.*3.14)+1.)/2.)-bb1.x+1.; float colLC_1=clamp(colL_1,0.090,1.0); vec2 posN_1=st*Nf1.x; float colN_1=(snoise(posN_1)*.5+.5); float colNC_1=smoothstep(Nn1.x,Nx1.x,colN_1); st_2=rotateUV(st_2,LR1.y); st_2.x+=cos(st_2.y*dA1.y)/df1.y; st_2.y+=sin(st_2.x*dA1.y)/df1.y; float pos_2=st_2.x*LF1.y; float colL_2=wb1.y*bb1.y*((cos(pos_2*2.*3.14)+1.)/2.)-bb1.y+1.; float colLC_2=clamp(colL_2,0.090,1.0); vec2 posN_2=st_2*Nf1.y; float colN_2=(snoise(posN_2)*.5+.5); float colNC_2=smoothstep(Nn1.y,Nx1.y,colN_2); st_3=rotateUV(st_3,LR1.z); st_3.x+=cos(st_3.y*dA1.z)/df1.z; st_3.y+=sin(st_3.x*dA1.z)/df1.z; float pos_3=st_3.x*LF1.z; float colL_3=wb1.z*bb1.z*((cos(pos_3*2.*3.14)+1.)/2.)-bb1.z+1.; float colLC_3=clamp(colL_3,0.090,1.0); vec2 posN_3=st_3*Nf1.z; float colN_3=(snoise(posN_3)*.5+.5); float colNC_3=smoothstep(Nn1.z,Nx1.z,colN_3); st_4=rotateUV(st_4,LR1.w); st_4.x+=cos(st_4.y*dA1.w)/df1.w; st_4.y+=sin(st_4.x*dA1.w)/df1.w; float pos_4=st_4.x*LF1.w; float colL_4=wb1.w*bb1.w*((cos(pos_4*2.*3.14)+1.)/2.)-bb1.w+1.; float colLC_4=clamp(colL_4,0.090,1.0); vec2 posN_4=st_4*Nf1.w; float colN_4=(snoise(posN_4)*.5+.5); float colNC_4=smoothstep(Nn1.w,Nx1.w,colN_4); st_5=rotateUV(st_5,LR2.x); st_5.x+=cos(st_5.y*dA2.x)/df2.x; st_5.y+=sin(st_5.x*dA2.x)/df2.x; float pos_5=st_5.x*LF2.x; float colL_5=wb2.x*bb2.x*((cos(pos_5*2.*3.14)+1.)/2.)-bb2.x+1.; float colLC_5=clamp(colL_5,0.090,1.0); vec2 posN_5=st_5*Nf2.x; float colN_5=(snoise(posN_5)*.5+.5); float colNC_5=smoothstep(Nn2.x,Nx2.x,colN_5); vec2 posN_6=st_6*Nf2.y; float colN_6=(snoise(posN_6)*.5+.5); float colNC_6=smoothstep(Nn2.y,Nx2.y,colN_6); if(indx==1.0){colNC_5=colNC_5+colNC_2; colNC_4=colNC_4+colNC_3; colNC_1=0.108*(colNC_6-0.)+colNC_1; colNC_2=0.292*(colNC_6-0.)+colNC_2; colNC_3=-0.448*(-colNC_6+0.024)+colNC_3;}else if (indx==2.0){colNC_5=colNC_5+colNC_2; colNC_4=1.; colNC_3=0.664*colNC_6+colNC_3; colNC_2=1.664*colNC_6+colNC_2; colNC_1=1.;}else if (indx==3.0){colNC_5=colNC_5+colNC_3; colNC_4=0.032*colNC_6+colNC_4; colNC_3=0.712*colNC_6+colNC_3; colNC_1=0.672*colNC_6+colNC_1;}else if (indx==4.0){colNC_5=colNC_5+colNC_3; colNC_3=1.680*colNC_5+colNC_3-1.; colNC_4=0.784*colNC_6+colNC_4; colNC_3=0.736*colNC_6+colNC_3; colNC_1=-0.016*colNC_6+colNC_1;}else if (indx==5.0){colNC_5=colNC_5+colNC_3; colNC_4=0.016*colNC_6+colNC_4; colNC_3=0.000*colNC_6+colNC_3; colNC_2=0.328*colNC_6+colNC_2; colNC_1=0.992*(colNC_6-0.024)+colNC_1;}else if (indx==6.0){colNC_5=colNC_5+colNC_3;}else if (indx==7.0){colNC_5=colNC_5+colNC_3;}else if (indx==8.0){colNC_5=colNC_5+colNC_3;} float colB_1=BlendScreen(colNC_1,colLC_1); float colB_2=BlendScreen(colNC_2,colLC_2); float colB_3=BlendScreen(colNC_3,colLC_3); float colB_4=BlendScreen(colNC_4,colLC_4); float colB_5=BlendScreen(colNC_5,colLC_5); float colF_1=SmoothStep(cBlend,1.,colB_1); float colF_2=SmoothStep(cBlend,1.,colB_2); float colF_3=SmoothStep(cBlend,1.,colB_3); float colF_4=SmoothStep(cBlend,1.,colB_4); float colF_5=SmoothStep(cBlend,1.,colB_5); float colF=min(colF_1,colF_2); colF=min(colF,colF_3); colF=min(colF,colF_4); colF=min(colF,colF_5); color=vec3(colF); gl_FragColor=vec4(color,1.0);} ",angle=Math.PI/3,defaultZoom=1.15,zoom=1.15,zoomStart=1.15,zoomTarg=1.15,v=0,vStart=0,vTarg=0,ratio=0,camSpeed=.02,easing=.05,initCamAngle=R.random_int(0,5)*angle,cam=[initCamAngle.PI/6,initCamAngle,initCamAngle],camStart=[0,0,0],camTarg=[0,0,0],rx1=1+R.random_dec()/100,ry1=1+R.random_dec()/100,rz1=1+R.random_dec()/100,rx2=1+R.random_dec()/100,ry2=1+R.random_dec()/100,rz2=1+R.random_dec()/100,rx3=1+R.random_dec()/100,ry3=1+R.random_dec()/100,rz3=1+R.random_dec()/100;class Go3d{constructor(e,t,r,o,a,s,c,n,i,l){if(this.verts=[],this.faces=[],this.faceIndx=[],this.gScale=a,this.x=0,this.y=0,this.z=0,this.center=new p5.Vector,this.ballCenter1=new p5.Vector,this.ballCenter2=new p5.Vector,1==e){this.x=t,this.y=r,this.z=o,this.verts[0]=createVector(0,0,0),this.verts[1]=createVector(-.548,1.097,1.687),this.verts[2]=createVector(1.226,0,1.687),this.verts[3]=createVector(1.226,1.984,1.687),this.verts[4]=createVector(1.774,.887,0),this.verts[5]=createVector(0,1.984,0),this.verts[6]=createVector(-.548,-.887,1.688),this.verts[7]=createVector(1.774,2.87,-0);for(let e=0;e<this.verts.length;e++)this.verts[e].x=this.verts[e].x*this.gScale+this.x,this.verts[e].y=this.verts[e].y*this.gScale+this.y,this.verts[e].z=this.verts[e].z*this.gScale+this.z;this.faceIndx=[[0,1,2],[3,5,4],[0,5,1],[5,3,1],[1,3,2],[2,3,4],[0,2,4],[0,4,5]]}else if(2==e){let e,t=new Face(c.facePts[0],c.facePts[1],c.facePts[2]);e=n;for(let r=0;r<8;r++)this.verts[r]=reflect3d(e.verts[r],t);for(let t=0;t<8;t++)this.faceIndx.push([e.faceIndx[t][0],e.faceIndx[t][2],e.faceIndx[t][1]])}else if(3==e){let e=i,t=l,r=n;for(let o=0;o<8;o++)this.verts[o]=scale3d(r.verts[o],e,t);for(let e=0;e<8;e++)this.faceIndx.push([r.faceIndx[e][0],r.faceIndx[e][1],r.faceIndx[e][2]])}this.ballCenter1=this.verts[6],this.ballCenter2=this.verts[7],this.center=vertex_average([this.verts[0],this.verts[1],this.verts[2],this.verts[3],this.verts[4],this.verts[5]]);for(let e=0;e<8;e++){let t;t=e<2?"e":"i",this.faces.push(new Face(this.verts[this.faceIndx[e][0]],this.verts[this.faceIndx[e][1]],this.verts[this.faceIndx[e][2]],t))}}}class Grid_Rhomb{constructor(e,t,r,o){this.gPts=[],this.gIndx=[],this.vecNum=3,this.moveVectors=new p5.Vector(2*this.vecNum),this.moveVectorsIndx=new Array(2*this.vecNum),this.gVectors=new p5.Vector,this.w=e,this.h=t,this.l=r,this.gridScale=o,this.moveVectorSize=2*this.vecNum,this.gVectors=this.findDodecaVectors();for(let e=0;e<20;e++)this.gVectors[e].mult(2);this.moveVectors[0]=this.gVectors[0],this.moveVectors[1]=this.gVectors[1],this.moveVectors[2]=this.gVectors[10],this.moveVectors[3]=this.gVectors[17],this.moveVectors[4]=this.gVectors[18],this.moveVectors[5]=this.gVectors[8],this.moveVectorsIndx[0]=0,this.moveVectorsIndx[1]=1,this.moveVectorsIndx[2]=10,this.moveVectorsIndx[3]=17,this.moveVectorsIndx[4]=18,this.moveVectorsIndx[5]=8;for(let e=0;e<this.l;e++){this.gPts[e]=[],this.gIndx[e]=[];for(let t=0;t<this.w;t++){this.gPts[e][t]=[],this.gIndx[e][t]=[];for(let r=0;r<this.h;r++){let o=new p5.Vector(this.moveVectors[0].x,this.moveVectors[0].y,this.moveVectors[0].z),a=new p5.Vector(this.moveVectors[1].x,this.moveVectors[1].y,this.moveVectors[1].z),s=new p5.Vector(this.moveVectors[2].x,this.moveVectors[2].y,this.moveVectors[2].z),c=.5*this.w;o.mult((e-c)*this.gridScale),a.mult((t-c)*this.gridScale),s.mult((r-c)*this.gridScale);let n=new p5.Vector(0,0,0);n.add(o),n.add(a),n.add(s),this.gPts[e][t][r]=new p5.Vector(n.x,n.y,n.z),this.gIndx[e][t][r]=new p5.Vector(e,t,r)}}}}findDodecaVectors(){let e=[],t=[],r=52.6226359,o=10.81231754,a=1,s=PI*r/180,c=PI*o/180,n=PI*-o/180,i=PI*-r/180,l=72*PI/180,m=l/2,h=0,d=createVector(0,0,0);for(let e=0;e<5;e++)t[e]=[],t[e][0]=a*cos(h)*cos(s),t[e][1]=a*sin(h)*cos(s),t[e][2]=a*sin(s),t.push(d),h+=l;h=0;for(let e=5;e<10;e++)t[e]=[],t[e][0]=a*cos(h)*cos(c),t[e][1]=a*sin(h)*cos(c),t[e][2]=a*sin(c),h+=l;h=m;for(let e=10;e<15;e++)t[e]=[],t[e][0]=a*cos(h)*cos(n),t[e][1]=a*sin(h)*cos(n),t[e][2]=a*sin(n),h+=l;h=m;for(let e=15;e<20;e++)t[e]=[],t[e][0]=a*cos(h)*cos(i),t[e][1]=a*sin(h)*cos(i),t[e][2]=a*sin(i),h+=l;for(let r=0;r<20;r++)e.push(new p5.Vector(t[r][0],t[r][1],t[r][2]));return e}}class GrowSys{constructor(e){this.gens=e,this.gen1=0}growToTarget(e){let t=e,r=!0,o=currGo,a=o.verts[3].dist(o.verts[0]),s=0;for(;1==r;){s+=1,o=currGo;let e=o.center.dist(t);if(e>a&&s<199){let e=[];e=this.growByBall(o,t);let r,a=99,s=9999;for(let o=0;o<e.length;o++){let c=e[o];r=c.center.dist(t),r<s&&(s=r,a=o),go.push(c)}currGo=e[a]}else r=!1,go=this.remDups(go),this.gen1=go.length,1==DECORATE&&this.decorate(),go=this.remDups(go)}}growByBall(e,t){let r=[],o=e,a=t,s=99;return s=o.faces[0].center.dist(a)<=o.faces[1].center.dist(a)?0:1,r=this.render(Lstring,o,s),r}decorate(){let e=go.length;for(let t=0;t<=this.gens;t++){for(let t=currArraySize;t<e;t++){let e=[],r=0;if(rand=R.random_dec(),rand>growth_percent){let o,a=go[t];rand1=R1.random_dec(),rand1>growth_type_ratio?(o=a.ballCenter1,r=0):(o=a.ballCenter2,r=3);let s=0,c=go[0].center.dist(go[0].faces[0].center);for(let e=0;e<go.length;e++)go[e].center.dist(o)<c&&(s=1);if(0==s){go.push(new Go3d(3,void 0,void 0,void 0,void 0,void 0,void 0,a,o,.5)),a=go[go.length-1];let t=!0,s="",c=0;for(;1==t;){rand2=R2.random_dec();let e=small_death_chance;rand2>e?(s+="f",c+=1,c>=4&&(s+="+",c=0),rand3=R3.random_dec(),e=.98,rand3>e&&(s+="/",c=0)):t=!1}e=this.render(s,a,r),e=this.remDups(e),e=this.remFaces(e);for(let t=0;t<e.length;t++)go.push(e[t])}}}currArraySize=e,e=go.length}}remDups(e){for(let t=0;t<e.length;t++){let r=e[t];for(let o=0;o<e.length;o++)if(o!=t){let t;t=e[o],r.center.dist(t.center)<.1&&e.splice(o,1)}}return e}remFaces(e){for(let t=0;t<e.length;t++){e[t];for(let r=0;r<e.length;r++)if(r!=t)for(let o=0;o<e[t].faces.length;o++){let a=e[t].faces[o].center;for(let s=0;s<e[r].faces.length;s++)if(a.dist(e[r].faces[s].center)<.1){e[t].faces.splice(o,1),e[r].faces.splice(s,1);break}}}return e}render(e,t,r
,chance:.01},{name:"shallow",chance:.3},{name:"medium",chance:.36},{name:"deep",chance:.33}],scat_lib=[{name:"none",chance:.5},{name:"fragmented",chance:.5}],rndr_lib=[{name:"complete",chance:.9},{name:"proof",chance:.1}],scale_cat=new Category(scale_lib);scale_cat.setByChance(),scale_cat.sum();let colr_cat=new Category(colr_lib);colr_cat.setByChance(),colr_cat.sum();let bkgd_cat=new Category(bkgd_lib);bkgd_cat.setByChance(),bkgd_cat.sum();let frac_cat=new Category(frac_lib);frac_cat.setByChance(),frac_cat.sum();let patt_cat=new Category(patt_lib);patt_cat.setByChance(),patt_cat.sum();let scat_cat=new Category(scat_lib);scat_cat.setByChance(),scat_cat.sum();let rndr_cat=new Category(rndr_lib);rndr_cat.setByChance(),rndr_cat.sum();let scale_f=scale_cat.pickCategory().name,colr_f=colr_cat.pickCategory().name,bkgd_f=bkgd_cat.pickCategory().name,frac_f=frac_cat.pickCategory().name,patt_f=patt_cat.pickCategory().name,scat_f=scat_cat.pickCategory().name,rndr_f=rndr_cat.pickCategory().name,run_animation=!0,DECORATE=!0,prtScn=!1,swap=!1,camZoomInit=!0;WIDTH=window.innerWidth,HEIGHT=window.innerHeight;2400==window.innerWidth&&2400==window.innerHeight&&(run_animation=!1);let color0,color1,color2,hR,sR,bR,ZoomPercent=scale_lib[1].chance*Math.PI;if(colr_f==colr_cat.arr[0].name){let e=R.random_dec();e<.9?hR=R11.random_num(30,65):(hR=R.random_int(0,105)-40,hR<0&&(hR+=360)),sR=R.random_int(6,15),bR=R.random_int(78,100)}else colr_f==colr_cat.arr[1].name?(hR=R.random_int(65,320),sR=R.random_int(6,15),bR=R.random_int(78,100)):colr_f==colr_cat.arr[2].name?(hR=R.random_int(0,360),sR=R.random_int(0,2),bR=R.random_int(78,94)):colr_f==colr_cat.arr[3].name&&(hR=R.random_int(0,360),sR=R.random_int(0,1),bR=R.random_int(96,100));if(bkgd_f==bkgd_cat.arr[0].name?(BKTEXT=!1,BKGRID=!1,bkUniform=[[0,0,0,0],[0,0],[0,0,0,0],[0,0],[0,100.16,100.16,2.88],[2.88,0],[0,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[4.35,.86,.86,.86],[.86,0],[0,43.752,41.752,24.216],[0,1.2],[0,-.26,-.26,.1],[0,0],[0,.376,.376,.376],[0,1],1,[0,0,0,0],.796]):bkgd_f==bkgd_cat.arr[1].name?(BLTEXT=!1,BKGRID=!0,bkUniform=[[0,0,0,0],[0,0],[0,0,0,0],[0,0],[0,100.16,100.16,2.88],[2.88,0],[0,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[4.35,.86,.86,.86],[.86,0],[0,43.752,41.752,24.216],[0,1.2],[0,-.26,-.26,.1],[0,0],[0,.376,.376,.376],[0,1],1,[0,0,0,0],.796]):bkgd_f==bkgd_cat.arr[2].name?(BKTEXT=!0,BKGRID=!1,bkrot=R.random_int(0,7)*Math.PI/4,bkfreq=0,bkamp=150,bkNscale=0,bkNmin=.65,bkNmax=.651,bkUniform=[[bkSCALE,0,0,0],[0,0],[bkrot,0,0,0],[0,0],[bkfreq,100.16,100.16,2.88],[2.88,0],[bkamp,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[4.35,.86,.86,.86],[.86,0],[bkNscale,43.752,41.752,24.216],[0,1.2],[bkNmin,-.26,-.26,.1],[0,0],[bkNmax,.376,.376,.376],[0,1],1,[0,0,0,0],.796],bkgd_f="linear hatch"):bkgd_f==bkgd_cat.arr[3].name?(BKTEXT=!0,BKGRID=!1,bkSCALE=200,bkrot=R.random_int(0,7)*Math.PI/4,bkfreq=0,bkamp=150,bkNscale=bkSCALE/4,bkNmin=.3,bkNmax=.651,bkUniform=[[bkSCALE,0,0,0],[0,0],[bkrot,0,0,0],[0,0],[bkfreq,100.16,100.16,2.88],[2.88,0],[bkamp,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[30,.86,.86,.86],[.86,0],[bkNscale,43.752,41.752,24.216],[0,1.2],[bkNmin,-.26,-.26,.1],[0,0],[bkNmax,.376,.376,.376],[0,1],1,[0,0,0,0],.796],bkgd_f="linear hatch"):bkgd_f==bkgd_cat.arr[4].name?(BKTEXT=!0,BKGRID=!1,bkSCALE=200,bkrot=R.random_int(0,7)*Math.PI/4,bkfreq=0,bkamp=150,bkNscale=bkSCALE/4,bkNmin=.3,bkNmax=.651,bkUniform=[[bkSCALE,bkSCALE,0,0],[0,0],[bkrot,bkrot+Math.PI/4*R.random_int(1,3),0,0],[0,0],[bkfreq,0,100.16,2.88],[2.88,0],[bkamp,.2,516.8,516.8,589.6],[589.6,0],[4.5,4.816,4.816,4.056],[3.592,0],[30,.86,.86,.86],[.86,0],[bkNscale,bkNscale,41.752,24.216],[0,1.2],[bkNmin,bkNmin,-.26,.1],[0,0],[bkNmax,bkNmax,.376,.376],[0,1],1,[0,0,0,0],.796],bkgd_f="cross hatch"):bkgd_f==bkgd_cat.arr[5].name?(BKTEXT=!0,BKGRID=!1,bkUniform=UNIVAR[R.random_int(1,2)],bkgd_f="cross hatch"):bkgd_f==bkgd_cat.arr[6].name&&(BKTEXT=!0,BKGRID=!1,bkUniform=UNIVAR[R.random_int(6,7)]),patt_f==patt_cat.arr[0].name){let e,t=R.random_dec();t<=.6?e=0:(e=pattOrgClust.length-1,e=R.random_int(1,e)),pattDirector=pattOrgClust[e]}else if(patt_f==patt_cat.arr[1].name){let e=pattOrgBranch.length-1;e=R.random_int(0,e),pattDirector=pattOrgBranch[e]}else if(patt_f==patt_cat.arr[2].name){let e=pattOrgLoop.length-1;e=R.random_int(0,e),pattDirector=pattOrgLoop[e]}else if(patt_f==patt_cat.arr[3].name){let e=pattOrgHole.length-1;e=R.random_int(0,e),pattDirector=pattOrgHole[e]}else if(patt_f==patt_cat.arr[4].name){let e=pattOrgLine.length-1;e=R.random_int(0,e),pattDirector=pattOrgLine[e]}else if(patt_f==patt_cat.arr[5].name){let e=pattOrgPT.length-1;e=R.random_int(0,e),pattDirector=pattOrgPT[e],Lstring="ffff+fff+ff+fff+f+fff+f+ffff+ff"}if(pS=pattDirector[1],1==pattDirector[2])frac_f=frac_cat.arr[0].name;else if(0==pattDirector[2]){let e=R.random_dec();frac_f=e<=.5?frac_cat.arr[3].name:frac_cat.arr[2].name}else-1==pattDirector[2]||2==pattDirector[2]||3==pattDirector[2]&&(frac_f=frac_cat.arr[1].name);if(frac_f==frac_cat.arr[0].name?(growth_Max=10,growth_percent=.8,growth_type_ratio=.5,small_death_chance=.2):frac_f==frac_cat.arr[1].name?(growth_Max=6,growth_percent=.7,growth_type_ratio=.5,small_death_chance=.15):frac_f==frac_cat.arr[2].name?(growth_Max=1,growth_percent=0,growth_type_ratio=.5,small_death_chance=.1):frac_f==frac_cat.arr[3].name&&(growth_Max=2,growth_percent=.6,growth_type_ratio=.5,small_death_chance=.04),scat_f==scat_cat.arr[0].name||scat_f==scat_cat.arr[1].name&&(ERASE=!0),rndr_f==rndr_cat.arr[0].name);else if(rndr_f==rndr_cat.arr[1].name){let e=R.random_dec();e<.5?WIREFRAME=!0:OPAQUE=!0}let growthPts=[[{x:0,y:0,z:0},{x:R.random_int(1,Math.floor(growth_Max/2))+Math.floor(growth_Max/2),y:R.random_int(1,growth_Max-1),z:R.random_int(1,growth_Max-1)}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:0,y:pS,z:pS},{x:0,y:pS,z:0},{x:pS,y:pS,z:0}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:0,y:pS,z:pS},{x:0,y:pS,z:0},{x:pS,y:pS,z:0},{x:0,y:pS,z:0},{x:pS,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:0,y:-pS,z:0},{x:0,y:0,z:0},{x:pS,y:0,z:0},{x:-pS,y:0,z:0},{x:0,y:0,z:0},{x:0,y:0,z:pS},{x:0,y:0,z:pS}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:pS,y:pS,z:0},{x:pS,y:0,z:0},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:0,z:pS},{x:0,y:pS,z:pS},{x:0,y:pS,z:0},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:0,z:pS},{x:pS,y:0,z:pS},{x:pS,y:0,z:0},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:0,y:pS,z:0},{x:pS,y:pS,z:pS},{x:pS,y:0,z:pS},{x:0,y:0,z:0}],[{x:0,y:0,z:0},{x:pS,y:pS,z:pS}],[{x:0,y:0,z:0},{x:1,y:1,z:1}],[{x:0,y:0,z:0},{x:2,y:2,z:2},{x:0,y:1,z:0},{x:0,y:0,z:0},{x:0,y:0,z:0},{x:0,y:1,z:0},{x:0,y:0,z:0}]];patternSelect=growthPts[pattDirector[0]],UNIVAR.push(bkUniform);let xGridMax=-1e3,yGridMax=-1e3,zGridMax=-1e3;for(i=0;i<patternSelect.length;i++)patternSelect[i].x>=xGridMax&&(xGridMax=patternSelect[i].x),patternSelect[i].y>=yGridMax&&(yGridMax=patternSelect[i].y),patternSelect[i].z>=zGridMax&&(zGridMax=patternSelect[i].z);bkGridDrawBoundsX=xGridMax+5,bkGridDrawBoundsY=yGridMax+5,bkGridDrawBoundsZ=zGridMax+5;let ignX=!1,ignY=!1,ignZ=!1,ignR=R.random_dec();for(ignR<=.33?ignX=!0:ignR>=.66?ignY=!0:ignZ=!0,i=0;i<patternSelect.length;i++)patternSelect[i].x+=Math.floor(bkGridTrueMax/2),patternSelect[i].y+=Math.floor(bkGridTrueMax/2),patternSelect[i].z+=Math.floor(bkGridTrueMax/2);let dSX=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),dFX=bkGridDrawBoundsX+dSX,dSY=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),dFY=bkGridDrawBoundsY+dSY,dSZ=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),dFZ=bkGridDrawBoundsZ+dSZ,renderPattern=[],zoomRRR=R4.random_num(0,1);zoomRR=R4.random_num(0,Math.PI),scale_f=scale_cat.arr[0].name,Math.abs((myAngle+zoomRR)%Math.PI)<=ZoomPercent&&(scale_f=scale_cat.arr[1].name,zoomRR=0);let display={"Growth Pattern":patt_f,"Fractal Depth":frac_f,Fragmentation:scat_f,Completeness:rndr_f,Background:bkgd_f,Scale:scale_f,"Paper Color":colr_f};console.log("primatives by ArandaLasch"),console.log("Benjamin Aranda, Jesse Bassett, Joaquin Bonifaz, Chris Lasch"),console.log(" "),console.log("Growth Pattern: "+patt_f),console.log("Fractal Depth: "+frac_f),console.log("Broken/scatter: "+scat_f),console.log("Completness: "+rndr_f),console.log("Scale: "+scale_f),console.log("Background: "+bkgd_f),console.log("Paper Color: "+colr_f),window.addEventListener("keydown",function(e){["Space","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code)>-1&&e.preventDefault()},!1) ;let resetPt,resetTarg,basicVert="\n attribute vec3 aPosition;\n attribute vec2 aTexCoord;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord=aTexCoord;\n vec4 positionVec4=vec4(aPosition,1.0);\n positionVec4.xy=positionVec4.xy*2.0-1.0;\n gl_Position=positionVec4;\n }\n ",fragShaderA="\n//Author:Jesse Bassett\n#ifdef GL_ES\nprecision mediump float;\n#endif\nvarying vec2 vTexCoord; varying vec4 Depth; uniform vec4 LF1; uniform vec2 LF2; uniform vec4 LR1; uniform vec2 LR2; uniform vec4 dA1; uniform vec2 dA2; uniform vec4 df1; uniform vec2 df2; uniform vec4 wb1; uniform vec2 wb2; uniform vec4 bb1; uniform vec2 bb2; uniform vec4 Nf1; uniform vec2 Nf2; uniform vec4 Nn1; uniform vec2 Nn2; uniform vec4 Nx1; uniform vec2 Nx2; uniform float indx; uniform vec4 Ld; uniform float cBlend; \n#define BlendScreen(base,blend) (1.0-((1.0-base)*(1.0-blend)))\nvec3 mod289(vec3 x) {return x-floor(x*(1.0 / 289.0))*289.0;} vec2 mod289(vec2 x) {return x-floor(x*(1.0 / 289.0))*289.0;} vec3 permute(vec3 x) {return mod289(((x*34.0)+1.0)*x);} float snoise(vec2 v) {const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439); vec2 i=floor(v+dot(v,C.yy)); vec2 x0=v-i+dot(i,C.xx); vec2 i1=vec2(0.0); i1=(x0.x > x0.y)? vec2(1.0,0.0):vec2(0.0,1.0); vec2 x1=x0.xy+C.xx-i1; vec2 x2=x0.xy+C.zz; i=mod289(i); vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0)); vec3 m=max(0.5-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0); m=m*m; m=m*m; vec3 x=2.0*fract(p*C.www)-1.0; vec3 h=abs(x)-0.5; vec3 ox=floo
[e][s].x,rg.gPts[c][e][s].y,rg.gPts[c][e][s].z);pop()}function windowResized(){DIM=min(windowWidth,windowHeight),resizeCanvas(DIM,DIM)}function setLineDash(e){drawingContext.setLineDash(e)}function dash_line(e,t,r,o,a,s,c,n){let i=createVector(e,t,r),l=createVector(o,a,s),m=p5.Vector.sub(l,i),h=m.mag(),d=int(h/(c+n));push(),translate(e,t,r);let g=m.copy().setMag(c),f=m.copy().setMag(c+n);for(let e=0;e<d;e++)line(0,0,0,g.x,g.y,g.z),translate(f.x,f.y,f.z);pop()}function updateCam(){for(push(),rotateZ(cam[2]),rotateY(cam[1]),push(),i=0;i<steps;i++)0==renderPattern[i]?(texture(myImg),model(goModels[i])):1==renderPattern[i]||(2==renderPattern[i]?(noStroke(),fill(255),model(goModels[i]),noFill()):3==renderPattern[i]?(stroke(0),strokeWeight(1),noFill(),model(goModels[i]),noStroke()):4==renderPattern[i]?(stroke(0),strokeWeight(1),fill(255),model(goModels[i]),noStroke(),noFill()):5==renderPattern[i]?(texture(myImg),stroke(0),strokeWeight(1),model(goModels[i]),noStroke()):(noStroke(),texture(myImg),model(goModels[i])));if(pop(),1==BKGRID&&drawGrid(),pop(),ratio>0&&ratio<1){ratio>=.99999&&(ratio=1),zoom=lerp(zoomStart,zoomTarg,ratio),cam[0]=lerp(camStart[0],camTarg[0],ratio),cam[1]=lerp(camStart[1],camTarg[1],ratio),cam[2]=lerp(camStart[2],camTarg[2],ratio),v=lerp(vStart,vTarg,ratio);let e=1-ratio;ratio+=e*easing,1==camZoomInit&&(ratio=.99999,zoom=defaultZoom/2,camZoomInit=!1)}ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4)}function pointRotateY(e,t){let r=new p5.Vector;return r.x=e.z*Math.sin(t)+e.x*Math.cos(t),r.y=e.y,r.z=e.z*Math.cos(t)-e.x*Math.sin(t),r}function pointRotateZ(e,t){let r=new p5.Vector;return r.x=e.x*Math.cos(t)-e.y*Math.sin(t),r.y=e.x*Math.sin(t)+e.y*Math.cos(t),r.z=e.z,r}function reflect3d(e,t){let r=new p5.Vector(0,0,0),o=new Face(t.facePts[0],t.facePts[1],t.facePts[2]),a=new p5.Vector(o.facePts[0].x,o.facePts[0].y,o.facePts[0].z),s=p5.Vector.sub(o.facePts[1],o.facePts[0]),c=p5.Vector.sub(o.facePts[2],o.facePts[0]),n=c.cross(s);if(n.normalize(),gTestPV0=a,gTestPV1=s,gTestPV2=c,0==e.dist(o.facePts[0])||0==e.dist(o.facePts[1])||0==e.dist(o.facePts[2]))r.x=e.x,r.y=e.y,r.z=e.z;else{let t=p5.Vector.sub(e,o.facePts[0]),s=Math.abs(t.angleBetween(n)),c=t.cross(n);c.normalize(),c.mult(20),testCross1=new p5.Vector(c.x,c.y,c.z),c.normalize();let i=n.cross(c);i.normalize(),i.mult(t.mag()*sin(s)),n.normalize(),n.mult(t.mag()*cos(s));let l=new p5.Vector(n.x,n.y,n.z);l.mult(-1),r.x=l.x,r.y=l.y,r.z=l.z,retV1=new p5.Vector(r.x,r.y,r.z),r.add(i),retV2=new p5.Vector(r.x,r.y,r.z),r.add(a),retV3=new p5.Vector(r.x,r.y,r.z)}return r}function scale3d(e,t,r){let o=new p5.Vector(0,0,0);return o.x=e.x+-1*t.x,o.y=e.y+-1*t.y,o.z=e.z+-1*t.z,o.x=o.x*r,o.y=o.y*r,o.z=o.z*r,o.x=o.x+t.x,o.y=o.y+t.y,o.z=o.z+t.z,o}function vertex_average(e){let t=new p5.Vector(0,0,0);for(let r=0;r<e.length;r++)t.x=t.x+e[r].x,t.y=t.y+e[r].y,t.z=t.z+e[r].z;let r=e.length;return t.x=t.x/r,t.y=t.y/r,t.z=t.z/r,t}document.oncontextmenu=(()=>!1);class Random{constructor(){this.useA=!1;let e=function(e){let t=parseInt(e.substr(0,8),16),r=parseInt(e.substr(8,8),16),o=parseInt(e.substr(16,8),16),a=parseInt(e.substr(24,8),16);return function(){t|=0,r|=0,o|=0,a|=0;let e=(t+r|0)+a|0;return a=a+1|0,t=r^r>>>9,r=o+(o<<3)|0,o=o<<21|o>>>11,o=o+e|0,(e>>>0)/4294967296}};this.prngA=new e(tokenData.hash.substr(2,32)),this.prngB=new e(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(e,t){return e+(t-e)*this.random_dec()}random_int(e,t){return Math.floor(this.random_num(e,t+1))}}let R,R1,R2,R3,R4,R10,R11,grw;R=new Random,R1=new Random,R2=new Random,R3=new Random,R4=new Random,R10=new Random,R11=new Random;class Category{constructor(e=[{name:"default",chance:1,amount:1,min:0,max:1}]){this.count=500,this.arr=e,this.select={}}setByAmount(){let e=0;for(let t=0;t<this.arr.length;t++)e+=this.arr[t].amount;this.count=e;for(let e=0;e<this.arr.length;e++)this.arr[e].chance=this.arr[e].amount/this.count}setByChance(e=this.count){let t=0;for(let e=0;e<this.arr.length;e++)t+=this.arr[e].chance;if(t>=.9999999999&&t<=1.00000000001)for(let e=0;e<this.arr.length;e++)this.arr[e].amount=this.arr[e].chance*this.count;else console.log("Improper Sum: "+t)}sum(){let e=[],t=[];t.push(0);for(let r=0;r<this.arr.length;r++)e.push(this.arr[r].chance),t.push(this.arr[r].chance);t.pop(),e=partialSum(e),t=partialSum(t);for(let r=0;r<this.arr.length;r++)this.arr[r].min=t[r],this.arr[r].max=e[r]}pickCategory(){let e,t=R.random_dec();for(let r=0;r<this.arr.length;r++)this.arr[r].min<=t&&t<this.arr[r].max&&(e=this.arr[r].name);return this.select={name:e,value:t},{name:e,value:t}}setCategory(e){let t,r=0;for(let r=0;r<this.arr.length;r++)e==this.arr[r].name&&(t=this.arr[r].name);return this.select={name:t,value:r},{name:t,value:r}}setCategoryValue(e){let t,r;for(let o=0;o<this.arr.length;o++)this.arr[o].min<=e&&e<this.arr[o].max&&(r=this.arr[o].name,t=e);return this.select={name:r,value:t},{name:r,value:t}}}let currGo,currFace,currPoint,targetPt,go=[],resetGo=[],goDepot=[],resetDepot=[],steps=0,currArraySize=0,zflag=0,sun=new p5.Vector(1,-1,1);sun.normalize();let geom,timer,img,centerX,centerY,centerZ,xMin,xMax,yMin,yMax,zMin,zMax,goNum,rand,rand1,rand2,rand3,zoomRR,num,myAngle=0,mGo=0,goModels=[],goModelsDepot=[],delay=3,bBox=[],currCluster=0,grow=1,initGrow=!0;var DEFAULT_SIZE=1400,WIDTH=window.innerWidth,HEIGHT=window.innerHeight,DIM=Math.min(WIDTH,HEIGHT),M=DIM/DEFAULT_SIZE;let myImg,canvas,shaderA,rg,patternSelect,bkImg,shaderBK,bkUniform,Lstring="ffff+fff",shad_Size=512,drawTex=!0,UNI=["LF1","LF2","LR1","LR2","dA1","dA2","df1","df2","wb1","wb2","bb1","bb2","Nf1","Nf2","Nn1","Nn2","Nx1","Nx2","indx","Ld","cBlend"],sG=10,UNIVAR=[[[54.64+sG,49.324+sG,40.324+sG,50+sG],[80.48+sG,0],[1.57079632679,-.788,-.788,-4.668],[3.604,0],[2,100.16,100.16,2.88],[2.88,0],[147.2,516.8,516.8,589.6],[589.6,0],[3.424,4.816,4.816,4.056],[3.592,0],[1.484,.86,.86,.86],[.86,0],[40,43.752,41.752,24.216],[0,1.2],[-.02,-.26,-.26,.1],[0,0],[.304,.376,.376,.376],[0,1],1,[0,0,0,0],.796],[[52.696+sG,54.324+sG,55.324+sG,62.392+sG],[80.48+sG,0],[0,.796,1.64,3.196],[5.332,5],[11.712,100.16,100.16,2.88],[2.88,0],[247.2,516.8,516.8,589.6],[589.6,0],[2.904,3.608,3.192,3.224],[3.592,0],[1.484,.86,.86,.86],[.86,0],[16.376,35.832,36.136,3.312],[4.152,-1.152],[0,.22,-.124,.1],[.1,.1],[0,.4,.56,1.128],[1.128,1],2,[0,0,0,0],.796],[[54.64+sG,49.324+sG,49.324+sG,49.284+sG],[80.48+sG,0],[0,1.58,4.548,2.316],[3.604,0],[11.712,100.16,100.16,98.696],[2.88,0],[247.2,516.8,516.8,621.6],[589.6,0],[3.488,3.088,3.056,3.848],[3.592,0],[1.484,.86,.86,.86],[.86,0],[16.376,35.832,36.136,36.136],[4.152,-1.5],[-0,-.26,-.124,-.124],[.1,.1],[.4,.4,.56,.592],[1.128,1],3,[0,0,0,0],.796],[[60.32+sG,49.324+sG,49.324+sG,49.284+sG],[80.408+sG,0],[2.227,.836,6.828,2.316],[3.932,0],[11.632,11.256,100.16,98.696],[2.88,0],[553.6,290.4,516.8,621.6],[589.6,0],[2.92,3.84,3.712,3.88],[2.832,0],[.276,1.188,.86,.86],[.86,0],[16.376,35.832,36.136,36.136],[4.152,.7],[.388,.212,-.124,-.124],[.1,.1],[1.024,.424,.56,.592],[1.544,1],4,[-.168,2.336,1.506,.952],.81],[[53.72+sG,46.468+sG,49.324+sG,49.284+sG],[50.352+sG,0],[3.963,2.032,6.876,.1],[2.604,0],[13.384,11.112,100.16,98.696],[3.24,0],[487.2,290.4,516.8,621.6],[589.6,0],[2.696,2.808,2.488,2.96],[1.464,0],[.196,1.188,.9,.86],[.86,0],[16.376,35.832,24.264,33.872],[3.2,-.8],[.572,.212,-.124,-.124],[-.084,.05],[.976,.656,.48,.592],[1.816,.9],5,[.63,.378,.601,3.632],.924],[[58.408+sG,46.468+sG,53.916+sG,51.336+sG],[40.424+sG,0],[4.707,1.104,6.676,2.596],[2.98,0],[12.208,10.12,100.16,98.704],[2.88,0],[578.4,290.4,516.8,621.6],[589.6,0],[1.156,2.376,2.376,2.168],[2.208,0],[.708,1.188,.86,.86],[.86,0],[18.168,40.832,25,3.136],[3.112,1.112],[.108,.212,-.124,-.116],[.1,.1],[1.304,.512,.56,1.072],[1.104,1.104],6,[0,0,0,0],.796],[[60.32+sG,60.324+sG,61.692+sG,61.336+sG],[50.424+sG,0],[2.091,.796,4.724,2.596],[4.788,0],[18.376,10.544,100.16,98.704],[2.88,0],[553.6,444,516.8,621.6],[589.6,0],[1.616,2.28,2.72,2.312],[1.776,0],[1.484,1.188,.86,.86],[.86,0],[16.744,35.832,36.136,3.136],[4.336,0],[.388,.212,-.508,-.124],[.1,0],[1.096,1.248,1.36,.592],[1.768,0],7,[0,0,0,0],.796],[[60.32+sG,80.324+sG,51.692+sG,60.368+sG],[1+sG,0],[6.427,1.012,6.828,4.836],[1,0],[11.632,10.056,100.16,98.696],[4,0],[553.6,444,516.8,621.6],[.4,0],[1.44,.92,2.256,2.024],[.2,0],[1.484,1.188,.86,.86],[.2,0],[16.16,35.832,36.136,3.136],[.1,0],[.388,.212,-.508,-.124],[0,0],[1.096,1.248,1.784,.496],[0,0],8,[0,0,0,0],.796]],gBorder=1,gScale=20,gVals=7+gBorder,growth_Max=7,growth_percent=.5,growth_type_ratio=.5,small_death_chance=.1,BKGRID=!1,bkGridTrueMax=27,bkGridDrawBoundsX=11,bkGridDrawBoundsY=11,bkGridDrawBoundsZ=11,pS=1,BKTEXT=!1,bkrez=2048,bkSCALE=250,bkrot=0,bkfreq=0,bkamp=0,bkNscale=0,bkNmin=0,bkNmax=0,pattDirector=[],pattOrgClust=[[0,0,-1],[1,2,0],[2,2,0],[4,2,0],[5,2,0],[7,2,0],[3,2,1],[4,3,1],[6,2,1],[7,2,1]],pattOrgBranch=[[1,3,3],[2,4,3],[1,4,3],[1,3,3],[2,4,3],[1,4,3],[1,5,1],[1,6,1],[1,7,1],[2,5,1],[3,4,1]],pattOrgLoop=[[4,4,1],[4,5,1],[5,4,1],[5,5,1],[6,5,1],[7,3,1],[7,4,1]],pattOrgLine=[[8,3,3],[8,4,3],[8,3,3],[8,4,3],[8,3,3],[8,4,3],[8,5,1],[8,6,1],[8,7,1]],pattOrgHole=[[10,0,-1],[10,0,-1],[10,0,-1],[2,3,1],[4,4,1],[6,3,1]],pattOrgPT=[[9,0,-1],[9,0,-1],[9,0,-1],[9,0,-1],[9,0,-1],[9,0,-1],[9,0,0],[9,0,0],[9,0,0],[9,0,0],[9,0,0],[9,0,0],[9,0,1]],ERASE=!1,WIREFRAME=!1,OPAQUE=!1,scale_lib=[{name:"fit",chance:.8},{name:"zoom",chance:.2}],colr_lib=[{name:"warm",chance:.55},{name:"cool",chance:.15},{name:"grey",chance:.2},{name:"white",chance:.1}],bkgd_lib=[{name:"blank",chance:.3},{name:"grid lattice",chance:.15},{name:"linear hatch",chance:.07},{name:"noise hatch",chance:.08},{name:"cross hatch",chance:.1},{name:"stipple hatch",chance:.1},{name:"dark hatch",chance:.2}],patt_lib=[{name:"cluster",chance:.55},{name:"branch",chance:.1},{name:"loop",chance:.05},{name:"hole",chance:.1},{name:"line",chance:.1},{name:"point",chance:.1}],frac_lib=[{name:"minimal"
// primatives by Aranda\Lasch // Benjamin Aranda, Jesse Bassett, Joaquin Bonifaz, Chris Lasch function partialSum(e){return e.reduce((e,t,r,o)=>{const a=o.slice(0,r+1),s=a.reduce((e,t)=>e+t,0);return[...e,s]},[])}function setup(){colorMode(HSB),canvas=createCanvas(DIM,DIM,WEBGL),noStroke(),rect(100*M,500*M,50*M,50*M),pixelDensity(2),shaderA=createShader(basicVert,fragShaderA),shaderA.setUniform("u_resolution",[DIM,DIM]),shad_Size=1024,bkrez=2800,myImg=createImage(8*shad_Size,shad_Size),shaderBK=createShader(basicVert,fragShaderA),shaderBK.setUniform("u_resolution",[bkrez,bkrez]),bkImg=createImage(bkrez,bkrez),sPress(),sun=new p5.Vector(1,-1,1),sun.normalize(),gBorder=2,gScale=20,gVals=growth_Max+gBorder,gVals=bkGridTrueMax,grw=new GrowSys(1),rg=new Grid_Rhomb(gVals,gVals,gVals,gScale);let e=patternSelect[0];for(targetPt=rg.gPts[e.x][e.y][e.z],patternSelect.shift(),go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0],goNum=1,i=0;i<goNum;i++){goDepot[i]=[],resetDepot[i]=[],nextGrow();for(let e=0;e<go.length;e++){resetDepot[i][e]=[];for(let t=0;t<go[e].verts.length-2;t++)resetDepot[i][e].push(new p5.Vector(go[e].verts[t].x,go[e].verts[t].y,go[e].verts[t].z))}goDepot[i]=go,goModelsDepot.push(goModels)}currCluster=goNum-1,grow=-1,timer=0,color0=color(hR,sR,bR),color1=color0,color2=color0;let t=R.random_int(1/6*goModels.length,.8*goModels.length),r=Math.round(5/12*goModels.length),o=t+r*(1/3),a=t+.5*r,s=t+r*(2/3),c=t+1*r,n=R.random_int(0,3);for(i=0;i<goModels.length;i++)renderPattern.push(0),1==ERASE&&i>5&&i<.33*goModels.length&&(renderPattern[i]=1),1==WIREFRAME?0==n?i>t&&i<c&&(renderPattern[i]=3):1==n?i>t&&i<a?renderPattern[i]=3:i>a&&i<c&&(renderPattern[i]=5):2==n?i>t&&i<o?renderPattern[i]=3:i>o&&i<s&&(renderPattern[i]=3):i>s&&i<c?renderPattern[i]=5:i>t&&i<c&&(renderPattern[i]=3):1==OPAQUE?i>t&&i<c&&(renderPattern[i]=2):renderPattern.push(0)}function draw(){if(1==drawTex){drawTex=!1,shaderA.setUniform("u_resolution",[shad_Size,shad_Size]),shader(shaderA),resizeCanvas(shad_Size,shad_Size,!1);for(let e=0;e<8;e++)readUniforms(shaderA,e),rect(0,0,40,40),myImg.copy(canvas,0,0,2*shad_Size,2*shad_Size,shad_Size*e,0,2*shad_Size,2*shad_Size);resetShader(),resizeCanvas(bkrez,bkrez,!1),shader(shaderBK);let e=2*v;UNIVAR[8][0][0]=e,bkgd_f!=bkgd_cat.arr[2].name&&(UNIVAR[8][0][1]=e+R.random_num(-20,20),UNIVAR[8][0][2]=e+R.random_num(-30,30),UNIVAR[8][0][3]=e+R.random_num(-30,20),UNIVAR[8][1][0]=e+R.random_num(-20,30)),UNIVAR[8][12][0]*=e/60,UNIVAR[8][12][1]*=e/60,UNIVAR[8][12][2]*=e/60,UNIVAR[8][12][3]*=e/60,UNIVAR[8][13][0]*=e/60,readUniforms(shaderBK,8),rect(0,0,40,40),bkImg.copy(canvas,0,0,bkrez,bkrez,0,0,bkrez,bkrez),resetShader(),resizeCanvas(DIM,DIM,!1)}if(background(color1),makeBorder(),lightFalloff(.003,3e-4,0),ambientLight(color0),noStroke(),0==run_animation&&(steps=go.length),1==grow)steps>=go.length?steps=go.length:millis()>timer&&(timer+=delay,steps++);else if(-1==grow)if(steps<=1){currCluster+=1,currCluster>goNum-1&&(currCluster=0),1==initGrow&&(go=[],resetGo=[],go=goDepot[currCluster].slice(),resetGo=resetDepot[currCluster].slice(),goModels=goModelsDepot[currCluster],initGrow=!1),zoomStart=zoom,camStart=[cam[0],cam[1],cam[2]],camTarg=[camTarg[0],camTarg[1],camTarg[2]];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)go[e].verts[t]=new p5.Vector(resetGo[e][t].x,resetGo[e][t].y,resetGo[e][t].z);ratio=+camSpeed,vStart=vTarg,steps=1,grow*=-1}else millis()>timer&&(timer+=delay,steps-=3);if(push(),stroke(255,0,0),strokeWeight(6),line(0,0,0,0,0,1e5),pop(),updateCam(),1==swap&&(save("primative"),pixelDensity(2),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),prtScn=!1,swap=!1),1==prtScn){let e=4800/DIM;pixelDensity(e),ortho(-v*zoom,v*zoom,-v*zoom,v*zoom,-1e4,1e4),swap=!0}}function readUniforms(e,t){for(let r=0;r<UNI.length;r++)e.setUniform(UNI[r],UNIVAR[t][r])}function lPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]+angle,camTarg[2]+angle],zoomStart=zoom,myAngle+=angle,zflag--,zflag<0&&(zflag=2),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function rPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1]-angle,camTarg[2]-angle],zoomStart=zoom,myAngle-=angle,zflag++,zflag>=3&&(zflag=0),zoomTarg=0==zflag?defaultZoom/2:defaultZoom,ratio=+camSpeed,vStart=vTarg,getModelExtents()}function sPress(){camStart=[cam[0],cam[1],cam[2]],camTarg=[cam[0],cam[1],cam[2]],Math.abs((myAngle+zoomRR)%Math.PI)<=ZoomPercent?(zoomTarg=defaultZoom/2,zflag=0):(zoomTarg=defaultZoom,zoomRRR>=.5?zflag=1:zoomRRR<=.5&&(zflag=2)),zoomStart=zoomTarg,ratio=+camSpeed,ratio=.98999}function touchStarted(){mouseX>WIDTH/2?rPress():mouseX<WIDTH/2&&lPress()}function keyPressed(){if(keyCode===LEFT_ARROW?lPress():keyCode===RIGHT_ARROW?rPress():keyCode===UP_ARROW?(zoomStart=zoom,zoomTarg=defaultZoom/2,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()):keyCode===DOWN_ARROW&&(zoomStart=zoom,zoomTarg=defaultZoom,ratio=+camSpeed,camStart=[cam[0],cam[1],cam[2]],camTarg=[0,camTarg[1],camTarg[2]],vStart=vTarg,getModelExtents()),"o"==key||"O"==key){let e=[],t=[],r=0;for(let o=0;o<go.length;o++)if(1!=renderPattern[o])for(let a=0;a<go[o].faces.length;a++){for(let t=0;t<go[o].faces[a].facePts.length;t++)e.push("v "+go[o].faces[a].facePts[t].x+" "+go[o].faces[a].facePts[t].y+" "+go[o].faces[a].facePts[t].z),r+=1;t.push("f "+(r-2)+" "+(r-1)+" "+r)}let o=e.concat(t);saveStrings(o,"primitive","obj")}"i"!=key&&"I"!=key||(prtScn=!0,console.log(prtScn),console.log(swap)),"u"!=key&&"U"!=key||myImg.save("primatives texture","png"),"g"!=key&&"G"!=key||(run_animation=!0,grow=-1)}function makeBorder(){push(),scale(zoom),fill(color2);let e=.1*v/1.15;1==BKTEXT&&(push(),lightFalloff(.003,3e-4,0),ambientLight(color0),texture(bkImg),translate(0,0,-1e3),box(1.15*(2*v-e)/zoom,1.15*(2*v-e)/zoom),pop()),push(),translate(-1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(1.15*v/1.15,0,1e3),box(e,5*v),pop(),push(),translate(0,1.15*v/1.15,1e3),box(5*v,e),pop(),push(),translate(0,-1.15*v/1.15,1e3),box(5*v,e),pop(),pop()}function nextGrow(){cam=[0,cam[1]-myAngle,cam[2]-myAngle],camStart=[0,camStart[1]-myAngle,camStart[2]-myAngle],camTarg=[0,camTarg[1]-myAngle,camTarg[2]-myAngle],v=0,vStart=0,vTarg=0,steps=0,mGo=0,go=[],goModels=[],go.push(new Go3d(1,targetPt.x,targetPt.y,targetPt.z,gScale)),currGo=go[0];R.random_int(1,Math.floor(growth_Max/2)),Math.floor(growth_Max/2),R.random_int(1,growth_Max-1),R.random_int(1,growth_Max-1);currArraySize=go.length;for(let e=0;e<patternSelect.length;e++){let t=patternSelect[e];grw.growToTarget(rg.gPts[t.x][t.y][t.z])}getModelExtents();for(let e=0;e<go.length;e++){go[e].center.x+=-centerX,go[e].center.y+=-centerY,go[e].center.z+=-centerZ;for(let t=0;t<go[e].faces.length;t++){go[e].faces[t].center.x+=-centerX,go[e].faces[t].center.y+=-centerY,go[e].faces[t].center.z+=-centerZ;for(let r=0;r<go[e].faces[t].facePts.length;r++)go[e].faces[t].facePts[r].x+=-centerX,go[e].faces[t].facePts[r].y+=-centerY,go[e].faces[t].facePts[r].z+=-centerZ}}for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length;t++)go[e].verts[t].x+=-centerX,go[e].verts[t].y+=-centerY,go[e].verts[t].z+=-centerZ;xMax+=-centerX,xMin+=-centerX,yMax+=-centerY,yMin+=-centerY,zMax+=-centerZ,zMin+=-centerZ,getModelExtents(),0==v&&(v=vTarg,vStart=vTarg);for(let e=0;e<go.length;e++)geom=new p5.Geometry(1,1,buildModel),geom.gid="go"+mGo+"_"+R.random_dec(),goModels.push(geom),mGo++}function buildModel(){let e=0;for(let t=0;t<go[mGo].faces.length;t++){let r=[];for(let o=0;o<go[mGo].faces[t].facePts.length;o++)this.vertices.push(go[mGo].faces[t].facePts[o]),r.push(e),e+=1;this.faces.push([r[0],r[1],r[2]]),n=createVector(go[mGo].faces[t].normal.x,go[mGo].faces[t].normal.y,go[mGo].faces[t].normal.z),n.normalize(),this.vertexNormals.push(n,n,n);let o=1/8,a=sun.dot(n),s=(sun.angleBetween(n),map(a,-1,1,0,7));s=round(s);let c=this.vertices[r[0]].dist(this.vertices[r[1]]),i=this.vertices[r[0]].dist(this.vertices[r[2]]),l=this.vertices[r[1]].dist(this.vertices[r[2]]);c=map(c,0,41.71563256142714,0,1),i=map(c,0,41.71563256142714,0,1),l=map(c,0,41.71563256142714,0,1),"e"==go[mGo].faces[t].type?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.866*c*o,c/2])):c>i&&c>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s,c]),this.uvs.push([o*s+.809*c*o,c/2])):i>c&&i>l?(this.uvs.push([o*s,0]),this.uvs.push([o*s+.809*i*o,i/2]),this.uvs.push([o*s,i])):l>c&&l>i&&(this.uvs.push([o*s+.809*l*o,l/2]),this.uvs.push([o*s,0]),this.uvs.push([o*s,l]));let m=R3.random_dec(),h=R4.random_dec();if(m<=.5)for(let e=0;e<this.uvs.length;e++)this.uvs[e][1]=1-this.uvs[e][1];if(h<=.5)for(let e=0;e<this.uvs.length;e++);}}function getModelExtents(){let e,t,r=[],o=[],a=[];for(let e=0;e<go.length;e++)for(let t=0;t<go[e].verts.length-2;t++)r.push(go[e].verts[t].x),o.push(go[e].verts[t].y),a.push(go[e].verts[t].z);r.sort((e,t)=>e-t),o.sort((e,t)=>e-t),a.sort((e,t)=>e-t),xMin=r[0],xMax=r[r.length-1],yMin=o[0],yMax=o[o.length-1],zMin=a[0],zMax=a[a.length-1],centerX=(xMax-xMin)/2+xMin,centerY=(yMax-yMin)/2+yMin,centerZ=(zMax-zMin)/2+zMin,e=Math.max(xMax,Math.abs(xMin)),t=Math.max(yMax,Math.abs(yMin)),vTarg=Math.max(e,t)}function drawGrid(){push();let e=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),t=bkGridDrawBoundsX+e,r=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),o=bkGridDrawBoundsY+r,a=Math.ceil((bkGridTrueMax-bkGridDrawBoundsX)/2),s=bkGridDrawBoundsZ+a;if(stroke(0,0,0),strokeWeight(1),0==ignX)for(let c=r;c<=o;c++)for(let r=a;r<=s;r++)line(rg.gPts[e][c][r].x,rg.gPts[e][c][r].y,rg.gPts[e][c][r].z,rg.gPts[t][c][r].x,rg.gPts[t][c][r].y,rg.gPts[t][c][r].z);if(0==ignY)for(let c=e;c<=t;c++)for(let e=a;e<=s;e++)line(rg.gPts[c][r][e].x,rg.gPts[c][r][e].y,rg.gPts[c][r][e].z,rg.gPts[c][o][e].x,rg.gPts[c][o][e].y,rg.gPts[c][o][e].z);if(0==ignZ)for(let c=e;c<=t;c++)for(let e=r;e<=o;e++)line(rg.gPts[c][e][a].x,rg.gPts[c][e][a].y,rg.gPts[c][e][a].z,rg.gPts[c]
Our studio, Aranda\Lasch, was formed in the early 2000s to explore algorithmic systems and generative processes as a means to understand the world around us and make things within it. Whether encapsulated in physical or computational techniques, these processes act with their own degree of autonomy from our own biases and as a result, open up new ideas and sensibilities while dismantling traditional notions of authorship. They allow one to code the possibility of discovery and surprise into the creative process in a manner that can be widely shared and because of this transmissibility, algorithms frustrate the idea of a single author, inviting speculation on the shared nature of creativity. For this reason we have always understood our work to be a collaboration between each other, those who share with us and those who inspire us. Over the years, the studio has indulged in a number of obsessions. One is the conviction that history is a generative source with which to constantly entangle. Whether it is through stories, characters, techniques, or events, history acts as a medium active with properties that constantly reshape and transform our concept of the present. We look back to move forward, like hitching a ride. It is here that we encounter Albrecht Dürer (1471-1528) and his masterpiece Melancholia I (1514) to inspire a deep dive into the process of engraving as a representational technique reinterpreted through the contemporary medium of code. By scratching metal away from a plate, an inversion of conventional drawing, engraving allowed a work of art to be reproduced and disseminated widely. In addition to the piece’s masterful delineation, its allegory resonates with us as well. In Dürer’s time melancholy was associated with insanity but also with creativity. In the engraving, the winged personification of melancholy -- the work is widely regarded to be a self-portrait of the artist -- is surrounded by the tools and elements of geometry. For Dürer, as for a handful of others who came before and after, who test the porous borders between art, science and religion, geometry is a vehicle for imagination, a shadow of the divine and a portal to the infinite. This work Primitives is a kindred meditation on infinity through an exploration of a novel geometric structure using algorithm and code, the tools of today's geometers and mystics, made visible through the anachronism of the engravers trade translated into pure 1’s and 0’s. Primitives grows through a single shape that can repeat and scale in specific ways that are never random, but rather tightly governed by geometric logics. It is about drawing infinity through a radical modularity; ordered but aperiodic. Unlike a regular crystal, whose molecular pattern is periodic (or repetitive in all directions), the distinctive quality of this quasicrystal is that its structural pattern never repeats the same way twice. Endless and uneven in aggregate, Primitive clusters can be described by the precise arrangement of a single modular part. As these small units aggregate together they form larger figures that themselves combine into ever larger movements, always a little bit different from any other. In this sense, quasicrystalline patterns have an infinite capacity to create and carry information. We are here because this is a medium for sharing in perpetuity. In the last couple of years, on the cusp of our third decade of practice, we have watched with awe and delight a renaissance in generative work as it's adopted by an entirely new generation around blockchain technologies. This inspired us to enter this new space with our own enduring questions of form and geometry, modularity and variability, historical continuity, and the thirst for endlessness. Primitives is what we selected as our primer into generative art on-chain because both the work and the medium grapple with these questions. Some Notes: On the screen, Primitives is represented as a two-dimensional projection of a three-dimensional figure. Each invocation comes with a sequence of projections, or rotations, around this object. As Primitives spins, there are moments when its blocks snap into alignment with other blocks revealing its underlying lattice and crystalline nature. Each projection can be saved as a high resolution image for printing. Primitives can also be saved in three dimensions as an .obj file for a variety of uses including the creation of a physical object through 3-d printing or fabrication. Below is a list of interface instructions: 'left' + 'right' arrow keys to rotate 'up' + 'down' arrow keys to zoom in 'g' regrows geometry 'i' saves image 'o' saves .obj Thank you, Aranda\Lasch 2022