Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # turtle_demos.py
- '''
- Turtle() None Creates and returns a new tutrle object
- forward() amount Moves the turtle forward by the specified amount
- backward() amount Moves the turtle backward by the specified amount
- right() angle Turns the turtle clockwise
- left() angle Turns the turtle counter clockwise
- penup() None Picks up the turtle's Pen
- pendown() None Puts down the turtle's Pen
- up() None Picks up the turtle's Pen
- down() None Puts down the turtle's Pen
- color() Color name Changes the color of the turtle's pen
- 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 the 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
- win = turtle.Screen()
- t = turtle.Turtle()
- turtle.title('Turtle')
- turtle.bgcolor('light blue')
- t.circle(50)
- t.penup()
- t.hideturtle()
- t.forward(200)
- t.color('yellow')
- t.pendown()
- t.pensize(width=9)
- t.circle(100)
- t.speed(0) # 0=fastest, 6=normal, 1-to-10=slowest-to-fast
- t.penup()
- t.backward(400)
- t.pendown()
- t.pensize(width=1)
- t.begin_fill()
- t.circle(100)
- t.penup()
- t.goto(0,-100)
- t.pendown()
- for i in range(10):
- t.forward(200)
- t.right(144)
- 0
- t.end_fill()
- t.penup()
- t.goto(0,100)
- t.pendown()
- t.shape('turtle')
- t.showturtle()
- print t.pos()
- def petal(t, r, angle):
- for i in range(2):
- t.circle(r,angle)
- t.left(180-angle)
- 0
- def flower(t, n, r, angle):
- for i in range(n):
- petal(t, r, angle)
- t.left(360.0/n)
- 0
- win.ontimer(None, 3000)
- t.clear()
- t.fill(1)
- flower(t, 10, 100.0, 80.0)
- t.fill(0)
- t.pensize(width=2)
- t.color("purple")
- flower(t, 10, 100.0, 80.0)
- t.penup()
- t.goto(0,-100)
- t.write(' End Of Demo', font=('Arial', 30, 'italic', 'bold'))
- turtle.done()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement