I am creating a floor plan and I want to know how to constraint certain areas to not draw in

Hey guys, I am working on an abstract floor plan using processing. I am making a grid with random rectangles and small ellipses. I have some voids on the four corners and one in the middle. Right now I am just covering up the grid with my big ellipses(voids) to create emptiness. Is there a way to make by rectangles and (smaller) ellipses like really not appear behind those (bigger)ellipses. Like right now I am just hiding them, since the loop just covers them on top each time. I would like them not to appear at all there. Like make a constraint to not draw in those areas. Is there a simple way to do so ? I am quite new, so I would take any kind of help! Thanks:)

here is my script right now:

float x=0;
float y=0;

void setup(){
    size(800,1000);
  background(255);
    stroke(0);
   strokeWeight(1);
   noLoop();
}

void draw(){

stroke(0);

// Random Boxed spaces. 
  for(x=0; x<width; x=x+80){

    for(y=0; y<height; y=y+80){ 
      
      int minW= 5;
      int maxW=75;
      int minH=10;
      int maxH=55;
      
      
      //Interior support columns.
      //fill(120);
      ellipse(x+40,y-20,8,8);
      
      //Cubic Spaces
      //fill(190);
      rect(x,y,random(minW,maxW),random(minH,maxH));

  }
   
  }
 
    pushMatrix();
    
  //fill(0);
  //Middle void.
  ellipse(width/2,height/2,200,400);
  //bottom right void
  ellipse(width,height,380,800);
  //bottom left void.
  ellipse(0,height,380,800);
  //top right void.
  ellipse(0,0,650,800);
  //top left void.
  ellipse(width,0,650,800);
}
1 Like

Yes, technically. You could just calculate if the ellipses/rects you want to display are within the bounds of the „empty spaces“.

For that you‘ll need to do boundary checks, and if the ellipse/rect happens to be within the boundary/ overlapping, then don‘t draw the ellipse/rect. But that‘s gonna decrease performance noticably if you do more than ~ 100 loops each for loop (100^2).

As for how boundary checks work, here‘s some links :

2 Ellipses :

2 Rects is actually pretty simple :

//the Prefix ‚e‘ represents the boundaries of empty spaces. 
if (eX < x && eX + eW > x + w && eY < y && eY + eH > y + w ) 
isWithinEmptySpace = true;

Checking wether Ellipse is within a Rect is also simple :

It‘s the same Code as with 2 Rects, if you don‘t have Center mode… if you draw the Ellipse normally though it will be Center mode, so Here’s how to check for that :

if (eX < x - w/2 && eX + eW > x + w/2 && eY < y - h/2 && eY + eH > y + w/2 ) 
isWithinEmptySpace = true;

2 Circles :

Just check wether their distance is smaller than the Sum of their radii.

Rect within a Circle :

Check if any of the corners (x, y, x+w, y+h) distance to the Center of the Circle is smaller than the radius of the Circle.

Rect within ellipse :

Idk… maybe try calculating the relative position and lerp the width/2 with height/2 according to the angle and then use that as value to compare against the distance calculation… but that might be overcomplicated…

1 Like