let WALL_STROKE_WEIGHT,PILLAR_SIZE;
createCols("https://coolors.co/22223b-ffef9f-424967-32425d"),
createCols("https://coolors.co/eef1ef-242424-dbebc6-f6dbd0-f8f5e2-d2eef9"),
createCols("https://coolors.co/e2f4f8-1458bd-b9dbf8-daebfb")
const COLS = Pallet[Math.floor(Math.random()*Pallet.length)];
const BorderCol = COLS[1];
const HeilightCols = COLS.slice(2, COLS.length);
createCanvas(windowWidth, windowHeight);
drawingContext.shadowOffsetX = 0;
drawingContext.shadowOffsetY = 0;
drawingContext.shadowBlur = 50;
drawingContext.shadowColor = color(BorderCol).setAlpha(80);
let num = int(random(3,10));
let roomSize = min(width,height)/num;
WALL_STROKE_WEIGHT = roomSize/50;
PILLAR_SIZE = WALL_STROKE_WEIGHT*1.7;
for(let y = 0; y < height; y+=roomSize*1.3){
for(let x = 0; x < width; x+=roomSize*1.3){
let nr = new Room(x+roomSize*random(-0.1,0.1),y+roomSize*random(-0.1,0.1),roomSize,roomSize,int(random(2,5)),int(random(2,5)),0.9);
let noiseCol = color(BorderCol);
for (let i = 0; i < 300000; i++) {
let s = noise(x*0.01, y*0.01)*2;
let gridCol = color(BorderCol);
for(let x = 0; x < width; x +=8)line(x,0,x,height);
for(let y = 0; y < height; y +=8)line(0,y,width,y);
function createCols(_url)
let slash_index = _url.lastIndexOf('/');
let pallate_str = _url.slice(slash_index + 1);
let arr = pallate_str.split('-');
for (let i = 0; i < arr.length; i++) {
constructor(x,y,w,h,dx,dy,maxOffset)
this.pos = createVector(x,y);
this.gridPos = randomGridPos(w,h,dx,dy,maxOffset);
this.outlineGridIndex = randomVertexFromGrid(this.gridPos);
this.vertPos = []; for(let i = 0; i < this.outlineGridIndex.length; i++)this.vertPos[i] = this.gridPos[this.outlineGridIndex[i].y][this.outlineGridIndex[i].x];
let rtex = createGraphics(w+1,h+1);
for(const p of this.vertPos)rtex.vertex(p.x,p.y);
for(let yi = 0; yi < gp.length-1; yi++){
for(let xi = 0; xi < gp[0].length-1; xi++){
let centerpos = p5.Vector.lerp(gp[yi][xi],gp[yi][xi+1],0.5);
if(this.isInRoom(xi,yi,true) && this.isInRoom(xi+1,yi,true) && this.isOnEdge(centerpos.x,centerpos.y,false) == false && random()<0.2){
rtex.line(gp[yi][xi].x,gp[yi][xi].y,gp[yi][xi+1].x,gp[yi][xi+1].y);
centerpos = p5.Vector.lerp(gp[yi][xi],gp[yi+1][xi],0.5);
if(this.isInRoom(xi,yi,true) && this.isInRoom(xi,yi+1,true) && this.isOnEdge(centerpos.x,centerpos.y,false) == false && random() < 0.2){
rtex.line(gp[yi][xi].x,gp[yi][xi].y,gp[yi+1][xi].x,gp[yi+1][xi].y);
isInRoom(x,y,useIndex = false){
let posx = useIndex ? this.gridPos[y][x].x : x;
let posy = useIndex ? this.gridPos[y][x].y : y;
let col = this.PlanTex.get(posx,posy);
if(brightness(col) > 90)return true;
isOnEdge(x,y,useIndex = false){
let posx = useIndex ? this.gridPos[y][x].x : x;
let posy = useIndex ? this.gridPos[y][x].y : y;
let col = this.PlanTex.get(posx,posy);
if(green(col) > 240)return true;
for(let i = 0; i < p.length; i++){
for(let j = 0; j < p[i].length; j++){
circle(p[i][j].x,p[i][j].y,5);
drawUnit(xi,yi,drawRight = false, drawBottom = false){
let center = createVector((gp[yi][xi].x + gp[yi][xi+1].x)*0.5,(gp[yi][xi].y + gp[yi+1][xi].y)*0.5);
let wid = gp[yi][xi+1].x-gp[yi][xi].x;
let hei = gp[yi+1][xi].y - gp[yi][xi].y;
if(this.isInRoom(center.x,center.y) == true){
strokeWeight(WALL_STROKE_WEIGHT/3);
let step = WALL_STROKE_WEIGHT*1.5;
rect(corner.x,corner.y+y,wid/2,step);
line(corner.x + wid/4,corner.y,corner.x + wid/4,corner.y+hei);
fill(HeilightCols[int(random(HeilightCols.length))]);
strokeWeight(WALL_STROKE_WEIGHT/3);
let w = wid*random(0.2,0.5);
let h = hei*random(0.2,0.5);
rect(center.x-w/2,center.y-h/2,w,h,min(w,h)*0.2);
strokeWeight(WALL_STROKE_WEIGHT/5);
let span = WALL_STROKE_WEIGHT;
for(let x = 0; x <wid; x+=span){
line(corner.x + x,corner.y,corner.x + x,corner.y+hei);
strokeWeight(WALL_STROKE_WEIGHT/5);
let span = WALL_STROKE_WEIGHT*1.8;
for(let x = 0; x <wid; x+=span){
line(corner.x + x,corner.y,corner.x + x,corner.y+hei);
for(let y = 0; y <hei; y+=span){
line(corner.x,corner.y+y,corner.x+wid,corner.y+y);
fill(HeilightCols[int(random(HeilightCols.length))]);
let w = wid-WALL_STROKE_WEIGHT*3;
let h = hei-WALL_STROKE_WEIGHT*3;
rect(center.x-w/2,center.y-h/2,w,h);
strokeWeight(WALL_STROKE_WEIGHT/4);
let radius = min(hei,wid)*random(0.2,0.4);
for(let r = 0; r < TAU; r+= TAU/30){
let cr = radius*random(0.9,1.1);
vertex(center.x + cos(r)*cr,center.y + sin(r)*cr);
let noiseCol = color(BorderCol);
for(let i = 0; i < 1000; i++){
let cr = radius*(1-pow(random(),2));
circle(center.x + cos(r)*cr,center.y + sin(r)*cr,0.1);
strokeWeight(WALL_STROKE_WEIGHT/5);
let w = wid-WALL_STROKE_WEIGHT*3;
let h = hei-WALL_STROKE_WEIGHT*3;
rect(center.x-w/2,center.y-h/2,w,h);
line(center.x-w/2,center.y-h/2,center.x-w/2+w,center.y-h/2+h);
rect(center.x-w/2-PILLAR_SIZE/2,center.y-h/2-PILLAR_SIZE/2,PILLAR_SIZE,PILLAR_SIZE);
rect(center.x-w/2+w-PILLAR_SIZE/2,center.y-h/2+h-PILLAR_SIZE/2,PILLAR_SIZE,PILLAR_SIZE);
strokeWeight(WALL_STROKE_WEIGHT/5);
let span = WALL_STROKE_WEIGHT*1.5;
for(let y = 0; y < hei; y+= span){
for(let x = 0; x < wid; x+= span)line(x,y,x+span/2,y);
this.drawWall(xi,yi,xi+1,yi);
this.drawWall(xi,yi,xi,yi+1);
if(drawRight)this.drawWall(xi+1,yi,xi+1,yi+1);
if(drawBottom)this.drawWall(xi,yi+1,xi+1,yi+1);
let center = p5.Vector.lerp(p1,p2,0.5);
if(this.isOnEdge(p1.x,p1.y) && this.isOnEdge(p2.x,p2.y)&& this.isOnEdge(center.x,center.y,false))
strokeWeight(WALL_STROKE_WEIGHT);
line(p1.x,p1.y,p2.x,p2.y);
strokeWeight(WALL_STROKE_WEIGHT/3);
line(map(0.2,0,1,p1.x,p2.x),map(0.2,0,1,p1.y,p2.y),map(0.8,0,1,p1.x,p2.x),map(0.8,0,1,p1.y,p2.y));
let dp1= p5.Vector.lerp(p1,p2,0.35);
let dp2= p5.Vector.lerp(p1,p2,0.65);
let startAngle = atan2(dp2.y-dp1.y,dp2.x-dp1.x);
let endAngle = startAngle + PI/2;
strokeWeight(WALL_STROKE_WEIGHT+0.5);
line(dp1.x,dp1.y,dp2.x,dp2.y);
strokeWeight(WALL_STROKE_WEIGHT/4);
line(dp1.x,dp1.y,dp2.x,dp2.y);
strokeWeight(WALL_STROKE_WEIGHT/4);
line(dp1.x,dp1.y,dp1.x + cos(endAngle)*r,dp1.y + sin(endAngle)*r);
strokeWeight(WALL_STROKE_WEIGHT/2);
if(startAngle < endAngle)arc(dp1.x,dp1.y,r*2,r*2,startAngle,endAngle);
else arc(dp1.x,dp1.y,r*2,r*2,endAngle,startAngle);
rect(p1.x-PILLAR_SIZE/2,p1.y-PILLAR_SIZE/2,PILLAR_SIZE,PILLAR_SIZE);
rect(p2.x-PILLAR_SIZE/2,p2.y-PILLAR_SIZE/2,PILLAR_SIZE,PILLAR_SIZE);
for(let yi = 0; yi < gp.length-1; yi++){
for(let xi = 0; xi < gp[0].length-1; xi++){
let drawRight = xi == gp[0].length-2 ? true : false;
let drawBottom = yi ==gp.length-2 ? true : false;
this.drawUnit(xi,yi,drawRight,drawBottom);