# Getting PShape primitive sizes

**URL:** <https://discourse.processing.org/t/getting-pshape-primitive-sizes/7375>\
**Category:** Coding Questions\
**Created:** [January 10, 2019, 1:53am UTC](https://discourse.processing.org/t/getting-pshape-primitive-sizes/7375 "2019-01-10T01:53:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleksi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/aleksi/32/11065_2.png) [@Aleksi](https://discourse.processing.org/u/Aleksi)\
**Post date:** [January 10, 2019, 1:53am UTC](https://discourse.processing.org/t/getting-pshape-primitive-sizes/7375/1 "2019-01-10T01:53:19Z")

</div>

Is there a way to obtain the size of a PShape primitive?

```auto
PShape ps1 = createShape();
ps1.beginShape();
ps1.vertex(-50, -50);
ps1.vertex(50, -50);
ps1.vertex(50, 50);
ps1.vertex(-50, 50);
ps1.endShape(CLOSE);
println(ps1.width, " ",ps1.height);
// prints 50.0 50.0

PShape ps2 = createShape(RECT, -50, -50, 100, 100);
println(ps2.width, " ", ps2.height);
// prints 0.0 0.0

```

If so, would it work with PShape GROUPs?

Hmm… I just noticed that printing the width,height of ps1 doesn’t give the absolute size since it ignores values less than 0. Obviously the size of ps1 should be 100,100.

Here’s ps1 “corrected”:

```auto
PShape ps1 = createShape();
ps1.beginShape();
ps1.vertex(0, 0);
ps1.vertex(0, 100);
ps1.vertex(100, 100);
ps1.vertex(0, 100);
ps1.endShape(CLOSE);
println(ps1.width, " ",ps1.height);
// prints 100.0 100.0

// ok, let's create ps1 another 100 units away
PShape ps1 = createShape();
ps1.beginShape();
ps1.vertex(100, 100);
ps1.vertex(100, 200);
ps1.vertex(200, 200);
ps1.vertex(100, 200);
ps1.endShape(CLOSE);
println(ps1.width, " ",ps1.height);
// prints 200.0 200.0

```

So it seems to determine the size based on its position to the canvas?!

Which raises the question: how does one obtain the absolute size of _any_ PShape object?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 10, 2019, 2:41am UTC](https://discourse.processing.org/t/getting-pshape-primitive-sizes/7375/2 "2019-01-10T02:41:29Z")

</div>

-a- yes, looks like the properties

> shape.width and shape.height

not work for that primitives

-b- and what you now show in your second example gets even more bad  
when i used minus values…

 ![2019-01-10_09-34-50_snap](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a6d6bba8087613d58b35094e80eba1fa9bc787bd.png)

-c- and also not work on groups

so might be a bug?
