Expression painter:gsave() records the painter settings and pushes this information on top of a stack of painter settings. Subsequent calls to painter:grestore() can be used to restore the saved settings.

Functions painter:gsave and painter:restore should be used to bracket code segments that perform some rendering in order to ensure that the painter settings remain unchanged.