python1.0-----Turtle Module

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.