# How to keep a shape in center, when the window size is changing?

**URL:** <https://discourse.processing.org/t/how-to-keep-a-shape-in-center-when-the-window-size-is-changing/23766>\
**Category:** Beginners\
**Created:** [September 10, 2020, 12:35am UTC](https://discourse.processing.org/t/how-to-keep-a-shape-in-center-when-the-window-size-is-changing/23766 "2020-09-10T00:35:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newtothis](https://avatars.discourse-cdn.com/v4/letter/n/7ba0ec/32.png) [@newtothis](https://discourse.processing.org/u/newtothis)\
**Post date:** [September 10, 2020, 12:35am UTC](https://discourse.processing.org/t/how-to-keep-a-shape-in-center-when-the-window-size-is-changing/23766/1 "2020-09-10T00:35:15Z")

</div>

```auto
void setup()
{
  size(800,1200);
  background(200);
  
  
 }
// *****************************

void draw()
{
  
 
  
  stroke(75);
  strokeWeight(5);
  fill(25);
  rect(135,310,500,500);
}
  

```

---

<div class="post-metadata">

**Author:** ![Hyperion65](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hyperion65/32/10569_2.png) [@Hyperion65](https://discourse.processing.org/u/Hyperion65)\
**Post date:** [September 10, 2020, 12:50am UTC](https://discourse.processing.org/t/how-to-keep-a-shape-in-center-when-the-window-size-is-changing/23766/2 "2020-09-10T00:50:03Z")

</div>

use:

```auto
width 
and
height

```

🙂
