Turtle Attributes And Methods
Python's turtle graphics give you a lot of options for controlling the
turtle cursor and drawing various shapes and patterns on the screen.
Turtle Attributes
- position() -provides a tuple of coordinates as the current position of the turtle.
- heading() -returns the current heading angle of the turtle in degrees.
- color() -returns a tuple of RGB values representing the turtle's current color.
- pensize() -returns the current pen size of the turtle.
- speed() -returns the current speed of the turtle.
Turtle Methods
- forward(distance): This option propels the turtle forward by a predetermined amount.
- backward(distance): This option sends the turtle back the specified amount of time.
- right(angle): This option moves the turtle to the right at the specified degree angle.
- left(angle): Moves the turtle to the left at the specified degree angle.
- penup() : raises the turtle's pen so that it can't draw while it moves.
- pendown():puts the pen down on the turtle so it can draw while it moves.
- setposition(x, y):sets the position of the turtle to the specified x and y coordinates.
- setheading(angle) :sets the heading angle of the turtle to the specified degree.
- dot(size, color) :draws a dot of the specified size and color at the turtle's current position.
- circle(radius, extent):draws a circle with the radius and extent you specify (the percentage of the circle to be drawn).
- begin_fill():begins to fill the space that the turtle's movements have enclosed.
- end_fill():stops occupying the space that the turtle's movements have enclosed.
More topic in Python