Turtle: Drawing Module
The object of the drawing can be understood as a turtle or a robot or a pen, and it can only understand limited commands. the origin of the drawing window (0,0) is in the middle of the canvas, and the default orientation is horizontal to the right.
Motion Commands:
Turtle.forward (STEP): Move the step length in the current direction.
Turtle.backward (STEP): Moves the step length in the opposite direction of the current direction.
Turtle.right (n): turns n degrees to the right.
Turtle.left (n): Turn n degrees to the left.
Turtle.goto (x, y): Moves to (x, y) coordinates.
Trutle.speed (n): The speed of the drawing can be set to 10, N is an integer belonging to [1,10].
Stroke control Commands:
Turtle.up (): The stroke is lifted and does not draw when moving.
Turtle.down (): Stroke falls.
Turtle.setheading (d): Change the orientation of the robot. For example: Turtle.setheading (90), set the direction the robot is facing 90 degrees.
Turtle.pensize (size): Sets the width of the stroke.
Turtle.pencolor (COLORSTR): Sets the color of the stroke.
Turtle.reset (): Clears the window, resets the position and orientation of the pen
Turtle.reset (): Clears the window without resetting the turtle.
Turtle.circle (c,step=e): Draw a circle with a radius of C, which is formed by a straight line of E.
Turtle.begin_fill (): Starts the fill.
Turtle.fillcolor (COLORSTR): The color of the fill.
Trutle.end_fill (): End fill.
For example, populate a Pentagon:
Turtle.begin_fill (): Starts the fill.
Turtle.fillcolor (COLORSTR): The color of the fill.
Turtle.circle (50,step=5): Draw the shape you want to fill: Pentagon.
Trutle.end_fill (): End fill.
Other commands:
The Turtle.done () program continues to execute (only when it is present, the window continues to exist).
Turtle.undo (): Undo last Action (previous operation was present)
Turtle.hideturtle (): Hide turtles.
Turtle.showturtle (): Shows turtles.
Turtle.screensize (BG=COLORSTR): Sets the canvas background color.
python1.0-----Turtle Module