# PGS point in Shape - eratic behavior

**URL:** <https://discourse.processing.org/t/pgs-point-in-shape-eratic-behavior/32633>\
**Category:** Libraries\
**Created:** [October 5, 2021, 1:09pm UTC](https://discourse.processing.org/t/pgs-point-in-shape-eratic-behavior/32633 "2021-10-05T13:09:02Z")\
**Posts on this page:** 2\
**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:** [October 5, 2021, 1:09pm UTC](https://discourse.processing.org/t/pgs-point-in-shape-eratic-behavior/32633/1 "2021-10-05T13:09:02Z")

</div>

Hi, I’m trying to see if my mouse is inside a shape with the [PGS library](https://github.com/micycle1/PGS).  
There’s maybe something wrong, I’ve got sometimes “ok” in the console.  
Here’s my code :

```auto
import micycle.pgs.*;
PShape sh;
void setup() {
  sh = createShape();
  sh.beginShape();
  sh.vertex(20, 20);
  sh.vertex(90, 40);
  sh.vertex(40, 90);
  sh.vertex(20, 20);
  sh.endShape();
}
void draw() {
  background(128);
  shape(sh);
  if (PGS_ShapePredicates.containsPoint(sh, new PVector(mouseX, mouseY))) print("ok");
}

```

Thanks

---

<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:** [October 5, 2021, 1:57pm UTC](https://discourse.processing.org/t/pgs-point-in-shape-eratic-behavior/32633/2 "2021-10-05T13:57:46Z")

</div>

Ok, I found my shape must be close.

```auto
sh.endShape(CLOSE);

```
