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:
- the fill() function (written at the bottom of the draw loop) will affect the ellipse (written at the top of the draw loop)
function setup() {
createCanvas(400, 400);
}
function draw() {
ellipse(100, 100, 100, 100);
fill(255, 0, 0);
}
- the translate() function (written at the bottom of the draw loop) will NOT affect the ellipse (written at the top of the draw loop)
function setup() {
createCanvas(400, 400);
}
function draw() {
ellipse(100, 100, 100, 100);
translate(200, 200);
}
1 Like
Chrisir
2
That’s true.
The Matrix gets resetted (like with popMatrix()) at start of the draw() function
The colors get not
The main canvas got all of its transformation methods reset before each draw() callback iteration:
Other method groups like color stick on the main canvas for each draw():
Canvas created via createGraphics() don’t auto-reset its transformation btW:
Thanks everyone. Very helpful
1 Like
glv
5
Chrisir
6
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