Simple turtle graphics
import time
# Draw a "circle". Turtle graphics are optimized, so the circle that is
# drawn is really a polygon. However you can see the turtle change its
# heading one degree at a time.
def circle():
width = 640
height = 480
world = makeWorld(width, height) # Make a "canvas" for the turtle to draw on
turtle = makeTurtle(world) # Create a turtle in the world.
# Put the turtle somewhere in the middle of the world before drawing
penUp(turtle)
moveTo(turtle, int(width/3), int(height/2))
penDown(turtle)
# Now, draw the circle
for degree in range(0, 360):
turn(turtle, 1) # Turn one degree at a time
forward(turtle, 2) # A small circle. One pixel is too small.
time.sleep(0.05) # So that we can see the turtle doing the drawing
Link to this Page