constbgCol="#447abd";constgCol="#a2c2e8";constnGrid=20;letw1;letgSpace;functionsetup(){w1=int(max(500,min(windowWidth,windowHeight)*0.9));gSpace=(w1/nGrid)*0.95;describe("a fractal set on a blueprint inverted");createCanvas(w1,w1);pixelDensity(1);textSize(16);}functiondraw(){t=frameCount/30;letmaxIter=60;letc={x:-0.4+0.1*Math.sin(t)*Math.cos(t),y:0.4-0.3*Math.sin(t/3)*Math.cos(t/2)};background(bgCol);push();translate(w1/2,w1/2);drawGrid();noStroke();fill(gCol);text("set",-w1/2+10,w1/2-5);pop();loadPixels();for(letx=0;x<width;x++){for(lety=0;y<height;y++){leta=map(x,0,width,-1.7,1.7);letb=map(y,0,height,-1.7,1.7);letn=0;while(n<maxIter){letaa=a*a-b*b;letbb=2*a*b;a=aa+c.x;b=bb+c.y;if(a*a+b*b>4)break;n++;}letbright=map(n,0,maxIter,0,1);bright=map(Math.cos(bright),0,1,0,165);letpix=(x+y*width)*4;if(bright>100){pixels[pix+0]=bright+68;pixels[pix+1]=bright+122;pixels[pix+2]=bright+189;pixels[pix+3]=105;}}}updatePixels();push();rectMode(CENTER);noStroke();translate(w1/2,w1/2);fill(bgCol);rect(-width/2+gSpace/2,0,gSpace,height);rect(width/2-gSpace/2,0,gSpace,height);rect(0,-width/2+gSpace/2,height,gSpace);rect(0,width/2-gSpace/2,height,gSpace);noStroke();fill(gCol);text("set",-w1/2+10,w1/2-5);pop();}functiondrawGrid(){rectMode(CENTER);textSize(16);stroke(gCol);strokeWeight(0.1);for(leti=1;i<=nGrid;i++){for(letj=1;j<=nGrid;j++){line(-w1/2+gSpace*i,-w1/2+gSpace,-w1/2+gSpace*i,w1/2-gSpace);line(-w1/2+gSpace,-w1/2+gSpace*i,w1/2-gSpace,-w1/2+gSpace*i);}}noFill();strokeWeight(3);rect(0,0,w1-2*gSpace);}