We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am making a sketch that has various little circles rotating around my screen, each in a separate subroutine the circle color, stroke weight, stroke, fill, may all be different. Is it good practice (or even acceptable) to put pushStyle() and popStyle() at the start and end of each subroutine?
I.e. (psuedocode)
void yellowCircle(){
pushStyle();
fill(100,0,100);
stroke(3);
ellipse(10,10,10,10);
popStyle();
}
void blueCircle(){
pushStyle();
fill(0,0,255);
stroke(1);
strokeWeight(3);
ellipse(30,30,30,30);
popStyle();
}
or is doing that a 'roundabout' way of doing it the proper way (whatever that may be)?
Thanks for any tips on best practices with pushStyle()/popStyle()!
Answers
It looks ok to me
pushStyle makes sense basically when the propertys are set (elsewhere before pushStyle()) and used then (after popStyle) eg. in draw().
When you set the properties anyway (as it looks like from what I see) you can skip pushStyle and popStyle