# Shapes inside other shapes

**URL:** https://discourse.processing.org/t/shapes-inside-other-shapes/32619
**Category:** Processing for Android
**Created:** [October 5, 2021, 12:43am UTC](https://discourse.processing.org/t/shapes-inside-other-shapes/32619 "2021-10-05T00:43:13Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![hotfooted](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hotfooted/32/3670_2.png) [@hotfooted](https://discourse.processing.org/u/hotfooted)
#### Post date: [October 5, 2021, 2:07am UTC](https://discourse.processing.org/t/shapes-inside-other-shapes/32619/2 "2021-10-05T02:07:45Z")

</div>

is the last image you found the solution? in any case based on [this post](https://discourse.processing.org/t/using-pgraphics-to-create-a-mask/16740/2) by @GSA_IxD you could do it like so

```auto
PGraphics mask, buffer;

void setup() {
  size(1024, 1024, P2D);
  
  mask = createGraphics(width, height, P2D);
  buffer = createGraphics(width, height, P2D); 
}

void draw() {
  background(255);
  updateMask();
  updateBuffer();
  buffer.mask(mask);
  image(buffer, 0, 0);
}

void updateMask() {
  mask.beginDraw();
  mask.noStroke();
  mask.fill(255);
  mask.quad(500, 300, 700, 500, 500, 700, 300, 500);
  mask.endDraw();
}

void updateBuffer() {
  buffer.beginDraw();
  buffer.background(255, 255, 0);
  buffer.strokeWeight(25);
  buffer.stroke(0, 0, 0);
  for (float x=312.5; x<700; x=x+50) {
    buffer.line(x, 300, x, 700);
  }
  buffer.endDraw();
}

```

---

_[View the full topic](https://discourse.processing.org/t/shapes-inside-other-shapes/32619)._
