The key to this is to setup()
the visible drawing, and use screensize()
to allocate the size of your image's total backing store. And then use the x
, y
, width
, and height
arguments of the postscript()
method to capture what you want.
The following will draw a visible circle and one too large to be seen in the window. It will then dump the entire image with both circles:
from turtle import Screen, Turtle
screen = Screen()
screen.setup(600, 480) # what's visible
screen.screensize(1200, 960) # total backing store
turtle = Turtle()
turtle.hideturtle()
turtle.speed('fastest')
turtle.penup()
turtle.sety(-100)
turtle.pendown()
turtle.circle(100) # visible
turtle.penup()
turtle.sety(-400)
turtle.pendown()
turtle.circle(400) # offscreen
canvas = screen.getcanvas()
canvas.postscript(file="test.eps", x=-600, y=-480, width=1200, height=960)
# wait for program to quit, then examine file 'test.eps'
Although you'll need to preallocate the large backing store (screensize()
), you only need to dump as much of it as you want by keeping track of your user's actions.