# PGS shape union

**URL:** https://discourse.processing.org/t/pgs-shape-union/34342
**Category:** Libraries
**Created:** [December 28, 2021, 5:01pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342 "2021-12-28T17:01:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)
#### Post date: [December 28, 2021, 5:01pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/1 "2021-12-28T17:01:19Z")

</div>

Hi, I’m trying to create a new Shape from 2 more simple.  
I use the PGS\_library with the function union :

```auto
output = PGS_ShapeBoolean.union(shape[0].getShape(), shape[1].getShape());

```

The new shape is created but still keep the inside lines and I just need those from the new diameter. Here’s the bad result :  
 ![noShape](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6cd6f33928145e888a8d7a0a08b7889bbe323eed.png)

Any ideas ?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [December 28, 2021, 6:30pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/2 "2021-12-28T18:30:35Z")

</div>

No idea.

Switch the stroke of the two initial shapes off and after union switch its stroke back on? 😉

---

<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: [December 28, 2021, 7:43pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/3 "2021-12-28T19:43:52Z")

</div>

Hello @matheplica,

It works here with this simple example that I conjured up:

```auto
import micycle.pgs.*;
import java.util.List;

PShape s, s1, s2;
boolean inward = true;

void setup() 
  {
  size(400, 400);

  s1 = createShape(RECT, 0, 0, 50, 50);
  s2 = createShape(TRIANGLE, 0, 0, 50, 25, 35, 80);

  s = new PShape();
  s = PGS_ShapeBoolean.union(s1, s2);
  
  shape(s, 100, 100);
  }
  
void draw()
  {
  background(0);
  shape(s1, 100, 50);
  shape(s2, 250, 50); 
  shape(s, mouseX, mouseY);
  }

```

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

Reference:

> [@Processing Geometry Suite](https://discourse.processing.org/t/processing-geometry-suite/29924):
>
> Processing Geometry Suite Hi everyone. I’m pleased to share something I’ve been working on the past few months – a 2D computational geometry that I’ve called Processing Geometry Suite. The focus of the library is on visualisation rather than providing underlying data structures and so all methods in the library are static and most of them take in and return PShapes or PVectors. I’ve made a real effort to make it easy to pick up – it’s well [documented](https://micycle1.github.io/PGS/micycle/pgs/package-summary.html), the Github is replete with gifs illust…

My first time using this library and can’t add more to this topic.

Can you provide a [minimal example](https://stackoverflow.com/help/minimal-reproducible-example)?

`:)`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [December 28, 2021, 8:00pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/4 "2021-12-28T20:00:48Z")

</div>

That’s fascinating

What does it stand for psg?

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [December 28, 2021, 8:12pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/5 "2021-12-28T20:12:09Z")

</div>

> [@Chrisir](#):
>
> What does it stand for psg?

# Processing Geometry Suite

---

<div class="post-metadata">

### Author: ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)
#### Post date: [December 29, 2021, 10:00am UTC](https://discourse.processing.org/t/pgs-shape-union/34342/6 "2021-12-29T10:00:52Z")

</div>

Ok just a basic forget.  
I need to close my path.

```auto
sh = createShape();
    sh.beginShape();
    sh.noStroke();
    sh.fill(0);
    for (int i=0; i<len; i++) sh.vertex(int(random(300)), int(random(300)));
    sh.vertex(sh.getVertex(0).x, sh.getVertex(0).y);
    sh.endShape(CLOSE);//here

```

Thanks for help

---

<div class="post-metadata">

### Author: ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)
#### Post date: [December 29, 2021, 1:54pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/7 "2021-12-29T13:54:17Z")

</div>

Thanks for your suite it’s very good good job.  
Now, I try to use :

PGS\_Morphology.fieldWarp()

I searching the same parameter than on your example with the leaf on the github site without sucess. Sorry but I’m lost.

---

<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: [December 29, 2021, 4:23pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/8 "2021-12-29T16:23:36Z")

</div>

> [@matheplica](#):
>
> Thanks for your suite it’s very good good job.

It is not my suite.

Thank @micycle.

`:)`

---

<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: [December 30, 2021, 11:33am UTC](https://discourse.processing.org/t/pgs-shape-union/34342/9 "2021-12-30T11:33:30Z")

</div>

It should take the same parameters as the example – either way the docs for that method are [here](https://micycle1.github.io/PGS/micycle/pgs/PGS_Morphology.html#fieldWarp(processing.core.PShape,double,double,boolean)).

---

<div class="post-metadata">

### Author: ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)
#### Post date: [December 31, 2021, 8:22pm UTC](https://discourse.processing.org/t/pgs-shape-union/34342/10 "2021-12-31T20:22:41Z")

</div>

Thanks, I will try to ask question less quickly !  
Happy new year to everyone on the earth
