# Geomerative - fitting text inside arbitrary shapes?

**URL:** <https://discourse.processing.org/t/geomerative-fitting-text-inside-arbitrary-shapes/4917>\
**Category:** Libraries\
**Created:** [October 27, 2018, 3:26am UTC](https://discourse.processing.org/t/geomerative-fitting-text-inside-arbitrary-shapes/4917 "2018-10-27T03:26:58Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [October 27, 2018, 1:25pm UTC](https://discourse.processing.org/t/geomerative-fitting-text-inside-arbitrary-shapes/4917/3 "2018-10-27T13:25:33Z")

</div>

OK I explored a bit more would something like this be acceptable?

```java
import geomerative.*;

RShape shape;
RShape rect;

void setup(){
  size(600, 600, P2D);
  RG.init(this);
  RG.setPolygonizer(RG.ADAPTATIVE);
  shape = RG.getRect(100,100,100,50);
}

void draw(){
  fill(255);
  rect = RShape.createRectangle(mouseX, mouseY, 10, 10);
  shape.draw(this);
  if (shape.contains(rect.getCentroid())){
    fill(255, 0, 0);
  }
  else{
    fill(255);
  }
  rect.draw(this);
}

```

OR

```java
import geomerative.*;

RShape bounds;
RShape my_rect;

void setup() {
  size(600, 600);
  RG.init(this);
  RG.setPolygonizer(RG.ADAPTATIVE);
  bounds = RG.getRect(105, 105, 95, 45);
}

void draw() {
  fill(255);
  my_rect = RShape.createRectangle(mouseX, mouseY, 10, 10);
  rect(100, 100, 100, 50);
  if (inBounds(my_rect)){
    fill(255, 0, 0);
  } else {
    fill(255);
  }
  my_rect.draw(this);
}

boolean inBounds(RShape shp) {
  RPoint[] pts = shp.getPoints();
  for (int i = 0; i < pts.length; i++) {
    if (!bounds.contains(pts[i]))
    { 
      return false;
    }
  }
  return true;
}

```

For something a bit more sophisticated.

---

_[View the full topic](https://discourse.processing.org/t/geomerative-fitting-text-inside-arbitrary-shapes/4917)._
