# Use the 'with' statement.
# This makes any changes you make to the graphics state -- such as
# colors and transformations -- temporary, and will be reset to
# the previous state at the end of the 'with' block.
with savedState():
    # set a color
    fill(1, 0, 0)
    # do a transformation
    translate(450, 50)
    rotate(45)
    # draw something
    rect(0, 0, 700, 600)
# already returned to the previously saved graphics state
# so this will be a black rectangle
rect(0, 0, 50, 50)