Python-turtle Library Knowledge Summary (Python drawing tool)

Source: Internet
Author: User

  Turtle: Turtle (Turtle pool)

The Turtle Library is a very popular function library for drawing images in the Python language .

You need to import the library before using: Import Turtle

? Turtle.setup (Width,height,startx,starty)
-setup () setting the position and size of the form
The coordinates of the starting point relative to the desktop and the height of the width of the window, if the starting point of the window is not written, the default is the right center of the desktop
The coordinate origin of the form defaults to the center of the window
? Absolute coordinates
0turtle.goto (100,100): refers to the coordinates given in parentheses from the current point
The turtle coordinates, the current point as a coordinate, with the front direction, the back direction, the left direction, the right side
0TURTLE.FD (d): means to run along the turtle's front direction
0TURTLE.BK (d): means running in the opposite direction of the turtle
0turtle.circle (R,angle): Refers to a circular movement along the left side of the turtle
? Absolute Angle
0turtle.seth (angle): Only changes the direction of the Turtle (angle counterclockwise), but does not travel, angle for absolute degrees
? Turtle Angle
0turtle.left (angle)
0turtle.right (angle)

First, RGB color system

 RGB color values range from 0-255 integers or 0-1 decimals

  

  

second, switch RGB color mode 

   Turtle.colormode (Mode)

      • 1.0:rgb decimal Mode
      • 255:rgb integer pattern

Three, brush control function

1, Turtle.penup () alias Turtle.pu ()
Brush up, leave no trace
2, Turtle.pendown () alias TURTLE.PD ()
Brushes Fall, leaving traces
3, Turtle.pensize (width) alias turtle.width (width)
Brush width
4, Turtle.pencolor (color)
Color is a string of colors or an RGB value
Eg:turtle.pencolor ("Purple") color string
Turtle.pencolor (0.63,0.13,0.94) RGB decimal value
Turtle.pencolor ((0.63,0.13,0.94)) RGB tuple value

Iv. Motion Control functions  

1. Turtle.forword (d) alias Turtle.fd (d)
Marching Forward
D: Travel distance, can be negative
2, Turtle.circle (R,extent=none)
Draw a radian of extent angle according to radius r
R: The location of the default center point on the left R distance of the turtle

Five, direction control function

1, turtle.setheading (angle) alias Turtle.seth (angle)
Changing direction of travel
2, Angle: Change the direction of the angle (absolute coordinates, absolute angle)
3, Turtle.left (angle)
4, turtle.right (angle)
Angle: Angle of rotation in the current direction (turtle angle)

Blog Address: http://www.cnblogs.com/yudanqu/

This blog wants to give beginners a little help, if you know what you like, then I am very happy. Lack of place also hope that many advice.

Python-turtle Library Knowledge Summary (Python drawing tool)

Related Article

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.