# Equivalent (PShape?) to Java2D Area subtract

**URL:** <https://discourse.processing.org/t/equivalent-pshape-to-java2d-area-subtract/36559>\
**Category:** Beginners\
**Created:** [April 23, 2022, 11:06pm UTC](https://discourse.processing.org/t/equivalent-pshape-to-java2d-area-subtract/36559 "2022-04-23T23:06:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sciss](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sciss/32/3580_2.png) [@sciss](https://discourse.processing.org/u/sciss)\
**Post date:** [April 23, 2022, 11:06pm UTC](https://discourse.processing.org/t/equivalent-pshape-to-java2d-area-subtract/36559/1 "2022-04-23T23:06:10Z")

</div>

Hi there. I’m trying to grasp the relationship between `PShape` and `java.awt.Shape`. In particular, how can I subtract one `PShape` from another, or intersect them. E.g. `new java.awt.geom.Area(shape1).subtract(new java.awt.geom.Area(shape2))`. Is that possible?

---

<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:** [April 23, 2022, 11:12pm UTC](https://discourse.processing.org/t/equivalent-pshape-to-java2d-area-subtract/36559/2 "2022-04-23T23:12:19Z")

</div>

Hello,

One way…

Reference:

> **[Reference](https://processing.org/reference/PShape_beginContour_.html)**
>
> The beginContour() and endContour() methods make it possible to define shapes with other shapes cut out of them. For example, the inside of a letter 'O'. These two functions are always u…

`:)`

---

<div class="post-metadata">

**Author:** ![sciss](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sciss/32/3580_2.png) [@sciss](https://discourse.processing.org/u/sciss)\
**Post date:** [April 23, 2022, 11:14pm UTC](https://discourse.processing.org/t/equivalent-pshape-to-java2d-area-subtract/36559/3 "2022-04-23T23:14:17Z")

</div>

Thanks, I saw `beginContour`; but can I “paste” an existing `PShape` here? Or do I have to retrace all vertices? Seems rather low level approach.

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [April 24, 2022, 9:06am UTC](https://discourse.processing.org/t/equivalent-pshape-to-java2d-area-subtract/36559/4 "2022-04-24T09:06:27Z")

</div>

There’s not really any relationship between `PShape` and `awt.Shape`.

You can use the [Processing Geometry Suite](https://discourse.processing.org/t/processing-geometry-suite/29924) library to perform 2D boolean operations (addition, subtraction, intersection, etc.) on PShapes **directly**.

[![](https://raw.githubusercontent.com/micycle1/PGS/master/resources/boolean/subtract.gif) ](https://raw.githubusercontent.com/micycle1/PGS/master/resources/boolean/subtract.gif)
