turtle graphics sample program

Summary of Turtle Methods:

Method     Parameters      Description
------     ----------      -----------
Turtle     None            Creates and returns a new turtle object
forward    distance        Moves the turtle forward
backward   distance        Moves the turle backward
right      angle           Turns the turtle clockwise
left       angle           Turns the turtle counter clockwise
up         None            Picks up the turtles tail
down       None            Puts down the turtles tail
color      color name      Changes the color of the turtle's tail
fillcolor  color name      Changes the color of the turtle will use to fill a polygon
heading    None            Returns the current heading
position   None            Returns the current position
goto       x,y             Move the turtle to position x,y
begin_fill None            Remember the starting point for a filled polygon
end_fill   None            Close the polygon and fill with the current fill color
dot        None            Leave a dot at the current position
stamp      None            Leaves an impression of a turtle shape at the current location
shape      shapename       Should be 'arrow', 'classic', 'turtle', or 'circle'


import turtle            

w = 700
h = 500
turtle.setup(w, h)           # set resolution
gw = turtle.Screen()         # creates a graphics window
gw.bgcolor("gray10")         # set the window background color
gw.title('Turtle Demo')      # set title

oogway = turtle.Turtle()     # create a turtle, store in variable oogway
oogway.color("darkorange")   # change characteristics...
oogway.speed('fast')         # slowest, slow, normal, fast, fastest

# draw something
for i in range(4):
  oogway.dot()                                   # make a small dot at current location
  print i, oogway.heading(), oogway.position()   # NOTE: 0,0 is center of screen
  oogway.forward(150)                            # move forward by 150 units
  oogway.left(90)                                # turn by 90 degrees

oogway.hideturtle()      # hide the arrow/turtle
gw.exitonclick()         # wait for mouse click to close window