import turtle t = turtle.Turtle() # Draw a square for i in range(4): t.forward(100) t.right(90) # Turn on screen tracer ts = t.getscreen().getcanvas() ts.postscript(file='square.eps') ts.postscript(file='square.svg') ts.get_tk_widget().pack() # Draw circles t.penup() t.right(45) t.forward(50) t.pendown() for i in range(4): t.circle(50) t.right(90) # Save recorded image ts.postscript(file='circles.eps') ts.postscript(file='circles.svg') ts.get_tk_widget().pack() turtle.done()
import turtle # Create turtle object t = turtle.Turtle() # Turn on screen tracer ts = t.getscreen().getcanvas() ts.postscript(file='spiral.eps') ts.postscript(file='spiral.svg') ts.get_tk_widget().pack() # Draw spiral for i in range(100): t.forward(2*i) t.right(20) # Save recorded images ts.postscript(file='spiral.eps') ts.postscript(file='spiral.svg') ts.get_tk_widget().pack() turtle.done()Package Library: Python Turtle Screen tracer is part of the Python Turtle graphics library, which is included in the Python Standard Library.