# Contour rectangle with an ellipse

**URL:** <https://discourse.processing.org/t/contour-rectangle-with-an-ellipse/30408>\
**Category:** Coding Questions\
**Created:** [June 1, 2021, 8:53am UTC](https://discourse.processing.org/t/contour-rectangle-with-an-ellipse/30408 "2021-06-01T08:53:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guidoDimasi](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@guidoDimasi](https://discourse.processing.org/u/guidoDimasi)\
**Post date:** [June 1, 2021, 8:53am UTC](https://discourse.processing.org/t/contour-rectangle-with-an-ellipse/30408/1 "2021-06-01T08:53:45Z")

</div>

Hi,  
there a simple way to contour a rectangle with an ellipse?  
i’ve tried vertex, curvedvertex but nothing work well

what i’m trying to accomplish is a way to apply some sort of a circle mask to a underlyng object,shape,image.  
an example of the image i’m trying to replicate is : [https://whatsittech.com/wp-content/uploads/2017/10/Tycho-Album-Cover-Awake.jpg](https://whatsittech.com/wp-content/uploads/2017/10/Tycho-Album-Cover-Awake.jpg)

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [June 1, 2021, 3:54pm UTC](https://discourse.processing.org/t/contour-rectangle-with-an-ellipse/30408/2 "2021-06-01T15:54:16Z")

</div>

Hi @guidoDimasi ,

Welcome to the forum! 😉

You can use the `PImage.mask()` function to do that :

> **[mask() / Reference](https://processing.org/reference/PImage_mask_.html)**
>
> Masks part of an image from displaying by loading another image and using it as an alpha channel. This mask image should only contain grayscale data, but only the blue color channel is used. The mask …

> Masks part of an image from displaying by loading another image and using it as an alpha channel. This mask image should only contain grayscale data, but only the blue color channel is used. The mask image needs to be the same size as the image to which it is applied.

You can also check a previous message I did on a masking technique with PGraphics :

> [@blendMode and transparency](https://discourse.processing.org/t/blendmode-and-transparency/27781/6):
>
> Hi again! Thanks @behreajj for the insight on how to do this with Java AWT! wink Just for fun, here’s a method that support arbitrary shapes by using a mask (of black pixels) that we then fill with the gradient using PGraphics : /\*\* \* Draw a rhombus shape mask of size s \*/ void rhombusMask(PGraphics mask, int s) { // It's important to fill it with black mask.beginDraw(); mask.fill(0); mask.noStroke(); mask.translate(mask.width / 2, mask.height / 2 - s); mask.beginShap…

---

<div class="post-metadata">

**Author:** ![guidoDimasi](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@guidoDimasi](https://discourse.processing.org/u/guidoDimasi)\
**Post date:** [June 20, 2021, 1:33pm UTC](https://discourse.processing.org/t/contour-rectangle-with-an-ellipse/30408/3 "2021-06-20T13:33:05Z")

</div>

thank u! it was what i need for my experiment!
