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

**URL:** https://discourse.processing.org/t/i-am-creating-a-floor-plan-and-i-want-to-know-how-to-constraint-certain-areas-to-not-draw-in/16081
**Category:** Coding Questions
**Created:** [December 3, 2019, 3:30pm UTC](https://discourse.processing.org/t/i-am-creating-a-floor-plan-and-i-want-to-know-how-to-constraint-certain-areas-to-not-draw-in/16081 "2019-12-03T15:30:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![elcougario](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@elcougario](https://discourse.processing.org/u/elcougario)
#### Post date: [December 3, 2019, 3:30pm UTC](https://discourse.processing.org/t/i-am-creating-a-floor-plan-and-i-want-to-know-how-to-constraint-certain-areas-to-not-draw-in/16081/1 "2019-12-03T15:30:39Z")

</div>

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:

```auto
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);
}

```

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [December 3, 2019, 5:05pm UTC](https://discourse.processing.org/t/i-am-creating-a-floor-plan-and-i-want-to-know-how-to-constraint-certain-areas-to-not-draw-in/16081/2 "2019-12-03T17:05:33Z")

</div>

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 :

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/24497/ellipse-collisions)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

2 Rects is actually pretty simple :

```auto
//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 :

```auto
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…
