# Cannot center rectangle

**URL:** https://discourse.processing.org/t/cannot-center-rectangle/14543
**Category:** Coding Questions
**Created:** [October 9, 2019, 9:10am UTC](https://discourse.processing.org/t/cannot-center-rectangle/14543 "2019-10-09T09:10:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![organelle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/organelle/32/6706_2.png) [@organelle](https://discourse.processing.org/u/organelle)
#### Post date: [October 9, 2019, 9:10am UTC](https://discourse.processing.org/t/cannot-center-rectangle/14543/1 "2019-10-09T09:10:24Z")

</div>

The rectMode(CENTER) cannot center my rectangle in my canvas. How do I fix this?

---

<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: [October 9, 2019, 9:15am UTC](https://discourse.processing.org/t/cannot-center-rectangle/14543/2 "2019-10-09T09:15:23Z")

</div>

Use this command rectMode(CENTER) **before** rect() please

Welcome to the forum!

---

<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: [October 9, 2019, 9:43am UTC](https://discourse.processing.org/t/cannot-center-rectangle/14543/3 "2019-10-09T09:43:10Z")

</div>

Or show your code please

---

<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: [October 9, 2019, 10:37am UTC](https://discourse.processing.org/t/cannot-center-rectangle/14543/4 "2019-10-09T10:37:48Z")

</div>

please play

```auto
void setup() {
  size(100, 100);
  rectMode(CENTER); // test also disable with // 
  fill(0, 200, 200);
  stroke(0, 200, 0);
  strokeWeight(3);
}
void draw() {
  background(200, 200, 0);
  for ( int d = 90; d > 1; d -= 10 ) rect(width/2, height/2, d, d);
}

```

[https://processing.org/reference/rectMode\_.html](https://processing.org/reference/rectMode_.html)  
[https://processing.org/reference/rect\_.html](https://processing.org/reference/rect_.html)
