# Masking - I want to get rid of the outside of the circle

**URL:** <https://discourse.processing.org/t/masking-i-want-to-get-rid-of-the-outside-of-the-circle/31428>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [July 24, 2021, 9:40pm UTC](https://discourse.processing.org/t/masking-i-want-to-get-rid-of-the-outside-of-the-circle/31428 "2021-07-24T21:40:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 24, 2021, 10:26pm UTC](https://discourse.processing.org/t/masking-i-want-to-get-rid-of-the-outside-of-the-circle/31428/2 "2021-07-24T22:26:22Z")

</div>

Hello,

One way is using mask() with images:  
[https://processing.org/reference/PImage\_mask\_.html](https://processing.org/reference/PImage_mask_.html)

Here is a simple template from the references:

```auto
// Masking
// v1.0.0
// GLV 2021-07-24

PGraphics pg1;
PImage img1;

void setup() 
  {
  size(330, 280);
  img1 = loadImage("frog.png");
  pg1 = createGraphics(330, 280); 
  }

void draw() 
  {
  background(0);

  pg1.beginDraw();
  //Your code for the mask goes here
  pg1.endDraw();
  
  img1.mask(pg1);
  
  image(img1, 0, 0);
  }

```

You will need to draw a circle with an alpha for transparency in your mask image.  
I used a picture for img1 but this could also be another PGraphic for your bars.

This is the result (circle moved with mouse):

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cd21ed92dff1bb1bb2ee57fd6f61c4cdc7fb6e4b.png)

I provided some references here:  
[https://discourse.processing.org/t/i-want-to-masking/31382/2](https://discourse.processing.org/t/i-want-to-masking/31382/2)  
See the UPDATE.

You will have to do some work with PGraphics to understand this approach.

I was also able to do this with this example:  
[https://processing.org/examples/brightness.html](https://processing.org/examples/brightness.html)  
You asked about this in another topic.

You already had two topics that are related to this that were _homework_.  
I tagged this topic as _homework_.

You have a lot of blank lines in your posted code; these could be cleaned up to make code more readable for the community.

The rest is up to you.

Have fun!

`:)`

---

_[View the full topic](https://discourse.processing.org/t/masking-i-want-to-get-rid-of-the-outside-of-the-circle/31428)._
