# Why do some functions loop, and others don't?

**URL:** https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223
**Category:** Beginners
**Created:** [September 29, 2020, 2:25pm UTC](https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223 "2020-09-29T14:25:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![SheCurvesMobius](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shecurvesmobius/32/7054_2.png) [@SheCurvesMobius](https://discourse.processing.org/u/SheCurvesMobius)
#### Post date: [September 29, 2020, 2:25pm UTC](https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223/1 "2020-09-29T14:25:49Z")

</div>

Hi all,

I’m wondering if anyone has any insight into why some functions, will affect the next frame in the draw loop, while others won’t.

For example:

1. the fill() function (written at the bottom of the draw loop) will affect the ellipse (written at the top of the draw loop)

```auto
function setup() {
  createCanvas(400, 400);
}

function draw() {
  ellipse(100, 100, 100, 100);
  fill(255, 0, 0);
}

```

1. the translate() function (written at the bottom of the draw loop) will NOT affect the ellipse (written at the top of the draw loop)

```auto
function setup() {
  createCanvas(400, 400);
}

function draw() {
  ellipse(100, 100, 100, 100);
  translate(200, 200);
}

```

---

<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: [September 29, 2020, 2:59pm UTC](https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223/2 "2020-09-29T14:59:10Z")

</div>

That’s true.

The Matrix gets resetted (like with popMatrix()) at start of the draw() function

The colors get not

---

<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: [September 29, 2020, 3:06pm UTC](https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223/3 "2020-09-29T15:06:50Z")

</div>

> [@SheCurvesMobius](#):
>
> … why some functions will affect the next frame in the draw loop, while others won’t.

The main canvas got all of its transformation methods reset before each **draw()** callback iteration:

- [reference | p5.js](http://p5js.org/reference/#group-Transform)

Other method groups like color stick on the main canvas for each **draw()**:

- [reference | p5.js](http://p5js.org/reference/#group-Color)

Canvas created via **createGraphics()** don’t auto-reset its transformation btW:

- [reference | p5.js](http://p5js.org/reference/#/p5/createGraphics)

---

<div class="post-metadata">

### Author: ![SheCurvesMobius](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shecurvesmobius/32/7054_2.png) [@SheCurvesMobius](https://discourse.processing.org/u/SheCurvesMobius)
#### Post date: [September 29, 2020, 3:08pm UTC](https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223/4 "2020-09-29T15:08:44Z")

</div>

Thanks everyone. Very helpful 🙂

---

<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: [September 29, 2020, 9:42pm UTC](https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223/5 "2020-09-29T21:42:34Z")

</div>

Hello,

Also discussed here:  
[https://p5js.org/reference/#/p5/draw](https://p5js.org/reference/#/p5/draw)

`:)`

---

<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: [September 30, 2020, 9:05am UTC](https://discourse.processing.org/t/why-do-some-functions-loop-and-others-dont/24223/6 "2020-09-30T09:05:05Z")

</div>

why-do-some-functions-loop-and-others-dont

I would say, why do some parameters (set by functions like fill or translate or rotate…) stay fixed when draw() begins a new cycle and others don‘t
