let customFont;function preload(){customFont=loadFont("/content/470ef95ec8a4d4c39ac592d40ee951ce31c11da39418a555825792945dc0461ai0")}let startSize,endSize,pixelBase=25,rowsCount=8,colsCount=8,strokeWeightVal=30,thickness=0,minSizeFactor=.7,maxSizeFactor=1,waveFrequency=.02,colorPalettes=[{backgroundColor:[204,123,10],lineColor:[100,100,100],fillColor:[255,153,10],pixelColor:[177,80,0],blockRectColor1:[255,30,0],blockRectColor2:[255,30,0],textColor:[255,255,255],pixelAlpha:180},{backgroundColor:[0,128,128],lineColor:[0,0,128],fillColor:[162,162,162],pixelColor:[240,0,0],blockRectColor1:[225,225,96],blockRectColor2:[225,225,94],textColor:[255,255,255],pixelAlpha:180},{backgroundColor:[40,40,40],lineColor:[204,123,10],fillColor:[40,40,40],pixelColor:[205,30,0],blockRectColor1:[205,30,0],blockRectColor2:[205,30,0],textColor:[204,123,10],pixelAlpha:180},{backgroundColor:[4,123,107],lineColor:[207,24,233],fillColor:[255,255,255],pixelColor:[10,130,180],blockRectColor1:[0,143,255],blockRectColor2:[0,143,255],textColor:[255,255,255],pixelAlpha:180},{backgroundColor:[250,235,215],lineColor:[51,139,51,150],fillColor:[255,255,255,100],pixelColor:[255,120,40],blockRectColor1:[120,13,155],blockRectColor2:[120,13,155],textColor:[120,50,200],pixelAlpha:180}],currentPaletteIndex=0,backgroundColor=[...colorPalettes[0].backgroundColor],lineColor=[...colorPalettes[0].lineColor],fillColor=[...colorPalettes[0].fillColor],pixelColor=[...colorPalettes[0].pixelColor],blockRectColor1Current=[...colorPalettes[0].blockRectColor1],blockRectColor2Current=[...colorPalettes[0].blockRectColor2],textColorCurrent=[...colorPalettes[0].textColor],pixelAlphaCurrent=colorPalettes[0].pixelAlpha,alphaMin=100,alphaMax=180,alphaTime=0,alphaSpeed=.02,pixelEditMode=!1,typedNumber="",toggledPix=[],pattern6x6={name:"myPattern",pixels:[]},maxSteps=64,steps=[],iMultiplierMin=10,iMultiplierMax=10,ampMin=150,ampMax=500,phaseMin=.004,phaseMax=.015,iMultiplier=5,ampValue=250,phaseMultiplier=.02,noiseSpeedIMult=.01,noiseSpeedAmp=5e-4,noiseSpeedPhase=.002,noiseSpeedPos=.001,xOffsetRange=100,blockMode=!1,isDetected=!1,detectedProgress=0,transitionSpeed=.02,detectionTimeout=null,redRectTime=0,redRectTime2=0,baseRectSpeed=.03,maxRectSpeed=.15,offsetPhase=2.5,typedText="",typedIndex=0,typingSpeed=1,lastDetected=!1,lastToggled=null,typedLines=[],typedIndices=[],rotationDuration=120,rotationOffset=5;function setup(){createCanvas(1e3,1e3),textFont(customFont);let e=pixelBase*max(rowsCount,colsCount);startSize=e*minSizeFactor,endSize=e*maxSizeFactor;for(let e=0;e0&&drawTypingText()}function drawAll(){background(backgroundColor),alphaTime+=alphaSpeed;let e=sin(alphaTime),t=map(e,-1,1,alphaMin,alphaMax);updateDetectedMode();let o=noise(frameCount*noiseSpeedIMult),l=noise(1e3+frameCount*noiseSpeedAmp),r=noise(2e3+frameCount*noiseSpeedPhase),i=noise(frameCount*noiseSpeedPos);iMultiplier=map(o,0,1,iMultiplierMin,iMultiplierMax),ampValue=map(l,0,1,ampMin,ampMax),phaseMultiplier=map(r,0,1,phaseMin,phaseMax);let n=map(i,0,1,-xOffsetRange/2,xOffsetRange/2),s=lerp(baseRectSpeed,maxRectSpeed,detectedProgress);redRectTime+=s,redRectTime2+=s;let p=.03*frameCount,a=.05*frameCount;for(let e=0;ewidth||C+x<0||C-x>height||(push(),translate(u,C),rotate(c),drawPixelGrid(0,0,o.grid,lineColor,thickness,fillColor,o.size,o.alpha,blockMode,redRectTime,redRectTime2-offsetPhase,detectedProgress),pop())}lastDetected=isDetected}function mousePressed(){let e=frameCount;for(let t=maxSteps-1;t>=0;t--)steps[t].waveTimes.push(e),e+=rotationOffset}function keyPressed(){if("b"===key||"B"===key)blockMode=!blockMode,lastToggled="b",updateTypedMessages(),blockMode&&startDetectedMode(1e4);else if("c"===key||"C"===key)currentPaletteIndex=(currentPaletteIndex+1)%colorPalettes.length,applyPalette(currentPaletteIndex);else if("p"===key||"P"===key)pixelEditMode=!pixelEditMode,lastToggled="p",updateTypedMessages(),pixelEditMode?typedNumber="":(toggledPix=[],pattern6x6.pixels=[],reapplyPatternToSteps());else if(pixelEditMode)if(key>="0"&&key<="9")typedNumber+=key;else if("Enter"===key){let e=parseInt(typedNumber);!isNaN(e)&&e>=1&&e<=64&&togglePixel(e),typedNumber=""}else"Backspace"===key&&(typedNumber=typedNumber.substring(0,typedNumber.length-1))}function updateTypedMessages(){typedLines=[],typedIndices=[],pixelEditMode&&blockMode?"b"===lastToggled?(typedLines.push("pixel mode: insert a number 1-64 and press enter"),typedLines.push("blockmode")):(typedLines.push("blockmode"),typedLines.push("pixel mode: insert a number 1-64 and press enter")):pixelEditMode&&!blockMode?typedLines.push("pixel mode: insert a number 1-64 and press enter"):!pixelEditMode&&blockMode&&typedLines.push("blockmode");for(let e=0;e1&&(detectedProgress=1)):!isDetected&&detectedProgress>0&&(detectedProgress-=transitionSpeed,detectedProgress<0&&(detectedProgress=0))}function drawTypingText(){typedIndextypedText.length&&(typedIndex=typedText.length));let e=typedText.substring(0,Math.floor(typedIndex));push(),fill(textColorCurrent[0],textColorCurrent[1],textColorCurrent[2],200),noStroke(),textSize(18),textAlign(RIGHT,BOTTOM),text(e,width-10,height-10),pop()}function createPixelGrid(e,t,o){let l=[];for(let r=0;r{if(t<1||t>r)return;let o=Math.floor((t-1)/l),i=(t-1)%l;e[o][i]=[...pixelColor]}))}function drawPixelGrid(e,t,o,l,r,i,n,s,p,a,d,c){let u=o.length;if(0===u)return;let C=o[0].length,x=n/C,g=C*x,f=u*x,h=e-g/2,m=t-f/2;stroke(l[0],l[1],l[2],s),strokeWeight(strokeWeightVal),noFill(),rect(h,m,g,f);let k=.5,b=1,y=.5,P=1,M=1;if(1===c&&(k=.9,b=1,y=.9,P=1,M=1.6),p){let e=map(g,0,600,5,25);e=constrain(e,5,25),e*=M;let t=lerp(10,-10,c),o=g-2*t,l=f-2*t,r=(sin(a)+1)/2,i=lerp(k,b,r),n=o*i,p=l*i,u=(o-n)/2,C=(l-p)/2,x=map(i,.5,1,.3*s,s);x=constrain(x,0,s),stroke(blockRectColor1Current[0],blockRectColor1Current[1],blockRectColor1Current[2],x),strokeWeight(e),noFill(),rect(h+t+u,m+t+C,n,p);let S=(sin(d)+1)/2,T=lerp(y,P,S),R=o*T,I=l*T,w=(l-I)/2,F=(l-I)/2,L=map(T,.5,1,.3*s,s);L=constrain(L,0,s),L*=.8,stroke(blockRectColor2Current[0],blockRectColor2Current[1],blockRectColor2Current[2],L),strokeWeight(.8*e),noFill(),rect(h+t+w,m+t+F,R,I)}for(let e=0;e