# How to center the alignment always

**URL:** <https://discourse.processing.org/t/how-to-center-the-alignment-always/13223>\
**Category:** Coding Questions\
**Created:** [August 7, 2019, 12:25am UTC](https://discourse.processing.org/t/how-to-center-the-alignment-always/13223 "2019-08-07T00:25:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hemanth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hemanth/32/6027_2.png) [@Hemanth](https://discourse.processing.org/u/Hemanth)\
**Post date:** [August 7, 2019, 12:25am UTC](https://discourse.processing.org/t/how-to-center-the-alignment-always/13223/1 "2019-08-07T00:25:49Z")

</div>

Hi, I was learning processing and I was trying something with the co ordinates, and I am having trouble in aligning to the center of the display window, for reference I have attached the video.

In detailed explanation or example there are two circles starting to slide across X & Y axis,  
so when the animation is triggered they will move across the screen and cross exactly at the center of the display window no matter of the ratio of the width and the height, like 500x500 or 500x700 or 700x500.

is there any idea that I can get.

 ![04%20am](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0bb52d86e0e97eceefa2e03cd74904ed0c7a40f3.png)

---

<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:** [August 7, 2019, 1:36am UTC](https://discourse.processing.org/t/how-to-center-the-alignment-always/13223/2 "2019-08-07T01:36:07Z")

</div>

do you use a

```auto
translate( width/2,height/2);

```

in draw ( beginning)?

then your math must be PLUS / MINUS rel. to NULL

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [August 7, 2019, 4:52pm UTC](https://discourse.processing.org/t/how-to-center-the-alignment-always/13223/3 "2019-08-07T16:52:30Z")

</div>

Hi there Hermanth, welcome to the forum. Have you tried coding something yet which you want to share? That way we have something to work from.

> [@Hemanth](#):
>
> exactly at the center of the display window no matter of the ratio of the width and the height

To make sure something is at the middle of the screen, divide the width or height by two 🙂

---

<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:** [August 7, 2019, 6:31pm UTC](https://discourse.processing.org/t/how-to-center-the-alignment-always/13223/4 "2019-08-07T18:31:28Z")

</div>

Yeah, width and height are inbuilt variables and you can calculate the center with

width/2

height/2

You can also call ellipseMode(CENTER); prior using ellipse
