a different idea ( here use JAVA ) could be to work with prepared THEMEs
void setup() {
size(200, 200);
set_Theme(1, 1, 0); // Theme 1, fill ON, stroke OFF
}
void draw() {
background(bg);
translate(width/2, height/2);
circle(0, 0, 50);
// temporary change color ( tc (text color) from theme OR any other color )
fill(tc); // fill(color(200,0,200));
text("sun", -25, 50);
reset_Style(); //instead wrap it into pushStyle popStyle, or recall set_Theme(), just reset to theme
}
//_________________________________________________________________________________ RESET to THEME settings
void reset_Style() {
strokeWeight(sw); // set the line width
if ( bfill == 1) fill(fc);
else noFill();
if ( bstroke == 1) stroke(sc);
else noStroke();
}
// ________________________________________________________________________________ THEME IDEA
color bg, fc, sc, tc; // color: background / fill / stroke / text /
int bfill=1, bstroke=1; // yes i want that global too
float sw=1, ts = 15; // stroke Weight / text size /
PFont myFont;
void set_Theme(int itheme, int b_fill, int b_stroke) { // Set the drawing style: fill, stroke, strokeWeight...
boolean diagp = true;
String name="";
bfill = b_fill; // copy to global theme vars
bstroke = b_stroke;
//printArray(PFont.list());
switch(itheme) {
case 0:
name = "theme default";
bg = color(200, 200, 0);
fc = color(0, 200, 0);
sc = color(0, 0, 200);
tc = color(200, 0, 0);
sw = 1.5;
myFont = createFont("Georgia", 20);
ts = 12;
break;
case 1:
name = "theme night sky";
bg = color(0, 0, 80);
fc = color(255, 255, 0);
sc = color(127);
tc = color(255);
sw = 0.5;
myFont = createFont("Yu Gothic Bold", 20);
ts = 25;
break;
}
reset_Style(); // set fill stroke strokeWeight
// set the by theme used text
textFont(myFont);
textSize(ts);
// prepared options for disable ...
rectMode(CENTER);
if ( diagp ) println(name+", with fill "+bfill+", with stroke "+bstroke);
}
/*
// https://discourse.processing.org/t/set-drawing-style-in-one-function/13254
// Set the drawing style: fill, stroke, strokeWeight
function setStyle(fc, sc = null, sw = null) {
fc ? fill(fc) : noFill();
sc ? stroke(sc) : noStroke();
sw ? strokeWeight(sw) : 0;
}
*/