I have a question concerning the current graphics state and the Graphics State Stack in PostScript.
In my code I now have a Stack which represents the current graphics state. When I initialise my interpreter it creates a new GraphicsState object and adds it to the 'gsstack'.
My Current Graphics State is implemented as: 'gsstack'.Peek() which always returns the topmost graphics state.
with the gsave operator I create a clone of the current graphics state and push that on the 'gsstack', so I have a new topmost graphics state on the stack (and this means I have a new Current Graphics State object).
Now with the grestore I read this from http://www.tailrecursive.org/postscript/operators.html#grestore
"Sets the current graphics state to the topmost graphics state on graphics state stack and pops that state off the stack. "
How does that grestore work, because my current graphics state is already the topmost graphics state... should I just pop it off the stack?
Or is my implementation wrong? When I initialise my interpreter should I create a new Current Graphics State object, but not add it to the 'gsstack' and only push it to the 'gsstack' when the gsave operator is called?
Thanks in advance