Save/restore system attribute

I see how to set the values for many system attributes, but I don’t see how to obtain the current value of a system attribute. For example, one can set the color to fill shapes via fill(), but how does one determine the current fill value? I would like to be able to save and restore system attributes, so that I can temporarily change them. For example:

// Draw something
drawComplexFigure(); // Changes the fill color several times (saves/restores current fill value)
// draw something using value of fill before call to drawComplexFigure.

My example is specific to fill, but I would like to be able to do this for all system attributes (font, stroke, textSize, textAlign, rectMode, etc).

1 Like

1 Like

Thx. Exactly what I needed to find.

1 Like

Welcome to the forum!


Note that pushMatrix / popMatrix works in the same way for transformations like translate, rotate, scale etc.

If you are working with a mix of styles and transformation operations, in recent versions of Processing you can also use push / pop to manage combinations of matrix and style.

1 Like

Thx. That’s good to know, too.