# What parts of the transform get reset in the draw loop? Does the matrix stack get reset?

**URL:** <https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454>\
**Category:** Beginners\
**Created:** [June 10, 2022, 3:22pm UTC](https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454 "2022-06-10T15:22:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![LordXerus](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@LordXerus](https://discourse.processing.org/u/LordXerus)\
**Post date:** [June 10, 2022, 3:22pm UTC](https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454/1 "2022-06-10T15:22:35Z")

</div>

Asking because this wasn’t clear in the reference. I thought that the entire matrix stack was discarded, but I ran into the cannot push more than 32 time error. Are the translate, rotate, and scale the only things that are reset? What about the styling?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [June 10, 2022, 3:57pm UTC](https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454/2 "2022-06-10T15:57:36Z")

</div>

Hi @LordXerus,

It only resets the current transformation matrix, not the transformation stack. Means you have to take care and use push and pop transformation matrices carefully.

Style will be handled a bit different. It will also not resetted but expanded and not stops at a depth of 32.

Cheers  
---- mnse

---

<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:** [June 10, 2022, 4:40pm UTC](https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454/3 "2022-06-10T16:40:26Z")

</div>

Good answer.

```auto
pushMatrix();

...

popMatrix();

```

must always come as a pair

---

<div class="post-metadata">

**Author:** ![LordXerus](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@LordXerus](https://discourse.processing.org/u/LordXerus)\
**Post date:** [June 10, 2022, 5:43pm UTC](https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454/4 "2022-06-10T17:43:13Z")

</div>

What does style being expanded mean?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [June 10, 2022, 5:51pm UTC](https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454/5 "2022-06-10T17:51:30Z")

</div>

See here…

[Reference: expand](https://processing.org/reference/expand_.html)

> To be more concrete. The stack which is used to store the current style properties by pushStyle() is expanded and not limited by 32 elements as the stack which is used for pushMatrix().

Cheers  
—mnse

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 10, 2022, 10:32pm UTC](https://discourse.processing.org/t/what-parts-of-the-transform-get-reset-in-the-draw-loop-does-the-matrix-stack-get-reset/37454/6 "2022-06-10T22:32:58Z")

</div>

Hello @LordXerus,

> [@LordXerus](#):
>
> What does style being expanded mean?

Reference was already provided.

You can see where it is used in the source code:

> <https://github.com/benfry/processing4/blob/dcae2e141dd89068bde62e8ef9769ebad9f3505c/core/src/processing/core/PGraphics.java#L6370>

I often check the source to see what is going on [under the hood](https://idioms.thefreedictionary.com/look+under+the+hood).

`:)`
