constbgCol="#447abd";constgCol="#a2c2e8";constnGrid=20;letw;letgSpace;functionsetup(){w=max(500,min(windowWidth,windowHeight)*0.9);describe("Integer partitions from 1 to 5 are shown connected at corners with one ant the top and branching out. The sketch is a blueprint design.");createCanvas(w,w);rectMode(CENTER);angleMode(DEGREES);textSize(16);}functiondraw(){background(bgCol);translate(w/2,w/2);drawGrid();t=frameCount/3;stroke(255);strokeWeight(1);push();translate(0,3*gSpace);fillRect(0,-8*gSpace,1);fillRect(-1*gSpace,-7*gSpace,-1);fillRect(-1*gSpace,-6*gSpace,-1);fillRect(1*gSpace,-7*gSpace,-1);fillRect(2*gSpace,-7*gSpace,-1);fillRect(-2*gSpace,-5*gSpace,1);fillRect(-3*gSpace,-5*gSpace,1);fillRect(-4*gSpace,-5*gSpace,1);fillRect(3*gSpace,-6*gSpace,1);fillRect(3*gSpace,-5*gSpace,1);fillRect(3*gSpace,-4*gSpace,1);fillRect(0,-5*gSpace,1);fillRect(0,-4*gSpace,1);fillRect(1*gSpace,-4*gSpace,1);fillRect(4*gSpace,-3*gSpace,-1);fillRect(5*gSpace,-3*gSpace,-1);fillRect(6*gSpace,-3*gSpace,-1);fillRect(7*gSpace,-3*gSpace,-1);fillRect(-5*gSpace,-4*gSpace,-1);fillRect(-5*gSpace,-3*gSpace,-1);fillRect(-5*gSpace,-2*gSpace,-1);fillRect(-5*gSpace,-1*gSpace,-1);fillRect(2*gSpace,-3*gSpace,-1);fillRect(2*gSpace,-2*gSpace,-1);fillRect(2*gSpace,-1*gSpace,-1);fillRect(3*gSpace,-1*gSpace,-1);fillRect(-7*gSpace,-7*gSpace,-1);fillRect(-5*gSpace,-7*gSpace,-1);fillRect(-5*gSpace,-6*gSpace,-1);fillRect(-6*gSpace,-7*gSpace,-1);fillRect(-1*gSpace,-3*gSpace,-1);fillRect(-2*gSpace,-3*gSpace,-1);fillRect(-1*gSpace,-2*gSpace,-1);fillRect(-2*gSpace,-2*gSpace,-1);fillRect(8*gSpace,-8*gSpace,1);fillRect(8*gSpace,-7*gSpace,1);fillRect(8*gSpace,-6*gSpace,1);fillRect(8*gSpace,-5*gSpace,1);fillRect(8*gSpace,-4*gSpace,1);fillRect(8*gSpace,-2*gSpace,1);fillRect(8*gSpace,-1*gSpace,1);fillRect(8*gSpace,0*gSpace,1);fillRect(8*gSpace,1*gSpace,1);fillRect(7*gSpace,1*gSpace,1);fillRect(4*gSpace,0*gSpace,1);fillRect(4*gSpace,1*gSpace,1);fillRect(4*gSpace,2*gSpace,1);fillRect(4*gSpace,3*gSpace,1);fillRect(5*gSpace,3*gSpace,1);fillRect(-8*gSpace,-6*gSpace,1);fillRect(-8*gSpace,-5*gSpace,1);fillRect(-8*gSpace,-4*gSpace,1);fillRect(-8*gSpace,-3*gSpace,1);fillRect(-8*gSpace,-2*gSpace,1);fillRect(-8*gSpace,2*gSpace,1);fillRect(-7*gSpace,2*gSpace,1);fillRect(-6*gSpace,2*gSpace,1);fillRect(-6*gSpace,1*gSpace,1);fillRect(-6*gSpace,0*gSpace,1);fillRect(-3*gSpace,-1*gSpace,1);fillRect(-3*gSpace,0*gSpace,1);fillRect(-3*gSpace,1*gSpace,1);fillRect(-4*gSpace,1*gSpace,1);fillRect(-4*gSpace,0*gSpace,1);fillRect(0*gSpace,-1*gSpace,1);fillRect(0*gSpace,0*gSpace,1);fillRect(0*gSpace,1*gSpace,1);fillRect(1*gSpace,1*gSpace,1);fillRect(1*gSpace,0*gSpace,1);pop();noStroke();fill(gCol);text("integer partitions",-w/2+10,w/2-10);}functionfillRect(x,y,s){push();translate(x,y);stroke(gCol);strokeWeight(2);if(s===1){scale(1,1);}else{scale(1,-1);}for(leti=0;i<=6;i++){line(-gSpace/2+(gSpace/6)*i,-gSpace/2,-gSpace/2,-gSpace/2+(gSpace/6)*i);line(gSpace/2-(gSpace/6)*i,gSpace/2,gSpace/2,gSpace/2-(gSpace/6)*i);}pop();}functiondrawGrid(){gSpace=(w/nGrid)*0.95;stroke(gCol);strokeWeight(0.3);for(leti=1;i<=nGrid;i++){for(letj=1;j<=nGrid;j++){line(-w/2+gSpace*i,-w/2+gSpace,-w/2+gSpace*i,w/2-gSpace);line(-w/2+gSpace,-w/2+gSpace*i,w/2-gSpace,-w/2+gSpace*i);}}noFill();strokeWeight(3);rect(0,0,w-2*gSpace);}functionmousePressed(){setup();draw();}functionwindowResized(){setup();draw();}