# How can I get the coordinate of one shape

**URL:** <https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376>\
**Category:** Processing\
**Tags:** homework\
**Created:** [April 15, 2021, 12:21pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376 "2021-04-15T12:21:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![turtle](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@turtle](https://discourse.processing.org/u/turtle)\
**Post date:** [April 15, 2021, 12:21pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376/1 "2021-04-15T12:21:12Z")

</div>

my code as following:

```javascript
let elli = ellipse(100,100,100,100);

```

so next how can I get the coordinate of the ellipse?

---

<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:** [April 15, 2021, 12:26pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376/2 "2021-04-15T12:26:43Z")

</div>

Well, you already know it since you entered the values manually. You might want to check the doc for [ellipse()](https://processing.org/reference/ellipse_.html) if you don’t know what the arguments you gave mean.

---

<div class="post-metadata">

**Author:** ![turtle](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@turtle](https://discourse.processing.org/u/turtle)\
**Post date:** [April 15, 2021, 12:46pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376/3 "2021-04-15T12:46:32Z")

</div>

Thanks for your reply.  
In fact, I know what these arguments mean. However in my case, the coordinates may be variables that have been defined in another place, so it is not explicit for me. I just wonder wether there are some property just like `ellipse.x` or method like`ellipse.coordinate(x)`.

---

<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:** [April 15, 2021, 1:07pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376/4 "2021-04-15T13:07:34Z")

</div>

Ok it makes more sense now.

Short answer, you don’t have property like this. The reason is ellipse is not an object but simply a function that draws something on the canvas.

But of course, you have several way to achieve what you want to do.  
The simplest way would be to have 2 arrays holding your x and y coordinates. Actually you can have a look at this [thread](https://discourse.processing.org/t/how-to-fix-the-code-belowed-in-order-to-delete-the-leftmost-ellipse-when-keypressed/29353); this solution is implemented there (and I would not be surprised if you both have the same assignement =)

If you want to be a tiny bit more fancy, you can have an arrayList of PVector. It is almost the same as the solution above but instead of having 2 array you only have one.

And if you want to go the extra mile, you can also create your own Ellipse class to hold their coordinate and take care of other logic like drawing them on screen for exemple. Here again using an arrayList of Ellipse object could be the solution.

---

<div class="post-metadata">

**Author:** ![turtle](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@turtle](https://discourse.processing.org/u/turtle)\
**Post date:** [April 15, 2021, 1:23pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376/5 "2021-04-15T13:23:58Z")

</div>

Thanks for your reply again, the problem has been resolved. 😀

---

<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:** [April 15, 2021, 1:43pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376/6 "2021-04-15T13:43:44Z")

</div>

> [@jb4x](#):
>
> And if you want to go the extra mile, you can also create your own Ellipse class to hold their coordinate

```auto
let elli = ellipse(100,100,100,100);

```

this is p5.js, so elli is an object here, but it doesn’t hold x and y, just some data

interestingly, you can click on the arrows in the console to expand objects

```auto

let a1 = (255);

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  
  fill(a1);
  let elli = ellipse(100,100,100,100);
  
  print(elli);
  print(elli._pixelDensity);
  
  print(elli._setupDone);
  print(_curElement);
  
}

```

---

<div class="post-metadata">

**Author:** ![turtle](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@turtle](https://discourse.processing.org/u/turtle)\
**Post date:** [April 15, 2021, 2:00pm UTC](https://discourse.processing.org/t/how-can-i-get-the-coordinate-of-one-shape/29376/7 "2021-04-15T14:00:00Z")

</div>

oh, it’s cool! 😁  
JS is an object-oriented language.
