0xa5d9232c…5604sent to0x0a1bbd57…3676·#19,159,929·view on Etherscan
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())});