# How to get x and y value of a shape?

**URL:** <https://discourse.processing.org/t/how-to-get-x-and-y-value-of-a-shape/28367>\
**Category:** Beginners\
**Created:** [March 9, 2021, 6:09am UTC](https://discourse.processing.org/t/how-to-get-x-and-y-value-of-a-shape/28367 "2021-03-09T06:09:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HolaCola](https://avatars.discourse-cdn.com/v4/letter/h/fbc32d/32.png) [@HolaCola](https://discourse.processing.org/u/HolaCola)\
**Post date:** [March 9, 2021, 6:09am UTC](https://discourse.processing.org/t/how-to-get-x-and-y-value-of-a-shape/28367/1 "2021-03-09T06:09:25Z")

</div>

Is there any method to get x and y axis value of a 2D shape (i.e. a circle or rectangle)? I haven’t found any related reference.

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [March 9, 2021, 7:43am UTC](https://discourse.processing.org/t/how-to-get-x-and-y-value-of-a-shape/28367/2 "2021-03-09T07:43:47Z")

</div>

well you can always draw a rectangle, but for a circle, given the angle and radius, you can calculate the position with

```auto
float x = CenterCricleX + cos(angle)*radius;
float y = CenterCircleY + sin(angle)*radius

```

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [March 9, 2021, 8:29am UTC](https://discourse.processing.org/t/how-to-get-x-and-y-value-of-a-shape/28367/3 "2021-03-09T08:29:23Z")

</div>

What do you mean by “getting the x and y axis value of a 2d shape”?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 9, 2021, 10:22am UTC](https://discourse.processing.org/t/how-to-get-x-and-y-value-of-a-shape/28367/4 "2021-03-09T10:22:54Z")

</div>

This question is vague. A shape fills a space, sure in coding terms it has an x and y, but its difficult to understand what is meant by get x and y.

If youve drawn the shape then your program should already have location details. If youre talking about testing collisions and seeing if x and y are inside a shape thats different.

If you want the midpoint of a shape again that might be different depending on the draw mode.

Pleaze specify what is required

---

<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:** [March 9, 2021, 10:47am UTC](https://discourse.processing.org/t/how-to-get-x-and-y-value-of-a-shape/28367/5 "2021-03-09T10:47:40Z")

</div>

> [@HolaCola](#):
>
> I haven’t found any related reference.

Hello,

For starters…

Check put the references, examples and tutorials here:  
[https://processing.org/](https://processing.org/)

Use the search bar on the Processing website to search the site:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/10677c3a2084372640431a9f305e069b8c65ff7b.png)  
Start with _circle_ and _rectangle_.

Be sure to read the entire reference and the related items at the bottom.

`:)`
