# rectMode for only 1 rect

**URL:** https://discourse.processing.org/t/rectmode-for-only-1-rect/37737
**Category:** Beginners
**Created:** [June 27, 2022, 6:25pm UTC](https://discourse.processing.org/t/rectmode-for-only-1-rect/37737 "2022-06-27T18:25:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sander](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Sander](https://discourse.processing.org/u/Sander)
#### Post date: [June 27, 2022, 6:25pm UTC](https://discourse.processing.org/t/rectmode-for-only-1-rect/37737/1 "2022-06-27T18:25:14Z")

</div>

Hey,  
i am new in Processing and i have a question…  
i want to center 1 rect but the function rectMode centers all rects how can i change this?

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [June 27, 2022, 6:47pm UTC](https://discourse.processing.org/t/rectmode-for-only-1-rect/37737/2 "2022-06-27T18:47:02Z")

</div>

Welcome, @Sander

How about if you switch the mode, draw a rectangle, then switch back?

```auto
rectMode(CENTER);
rect(...);
rectMode(CORNER);
rect(...);

```

---

<div class="post-metadata">

### Author: ![Sander](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Sander](https://discourse.processing.org/u/Sander)
#### Post date: [June 27, 2022, 7:52pm UTC](https://discourse.processing.org/t/rectmode-for-only-1-rect/37737/3 "2022-06-27T19:52:09Z")

</div>

it works, thanks for the answer and i am sorry…  
i am new 😄

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [June 27, 2022, 8:53pm UTC](https://discourse.processing.org/t/rectmode-for-only-1-rect/37737/4 "2022-06-27T20:53:11Z")

</div>

In case you have a bunch of **rect()** commands it’s worth using **pushStyle()** before **rectMode()**; and then once finished call **popStyle()** to get **rectMode()** (or other used styles) back to its previous style:

> **[Reference](https://processing.org/reference/pushStyle_.html)**
>
> The pushStyle() function saves the current style settings and popStyle() restores the prior settings. Note that these functions are always used together. They allow you to change the sty…

> **[Reference](https://processing.org/reference/popStyle_.html)**
>
> The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these functions are always used together. They allow you to change the style setting…
