Python's graphical drawing turtle Library

Source: Internet
Author: User
Tags goto

Turtle Drawing Villain

Import Turtleturtle.setup (700,700,100,100) #setup () Set the form size, the latter two parameters are optional, and the function is not required for the Turtle.speed (Ten) #设置画笔移到速度, the parameter value is 0-10, The larger the number, the greater the speed Turtle.pensize #设置画笔尺寸大小turtle. PenColor (' green ') #设置画笔颜色turtle. Penup () # Lift the brush (moving to the brush when lifted will not leave a trace on the canvas) Turtle.goto (0,190) #将画笔移到 (x, y) Turtle.pendown () #将画笔落下turtle. Circle (80,360) #画圆, The radius is positive to indicate that the center is on the left of the brush turtle.fillcolor (' yellow ') Turtle.penup () Turtle.goto ( -20,250) turtle.seth ( -90) #改变海龟行进方向, but not marching, belongs to Absolute angle Turtle.pendown () turtle.circle (20,180) Turtle.penup () Turtle.goto ( -10,280) Turtle.pendown () turtle.circle ( 20,180) Turtle.penup () Turtle.goto (50,280) turtle.left (#tuetle). Left () turtle.right () can change the turtle's travel angle, which is a relative angle, Left counterclockwise moves to the angle, right moves clockwise to angle Turtle.pendown () turtle.circle (20,180) Turtle.penup () Turtle.goto ( -25,195) Turtle.pendown ( ) TURTLE.FD (+) #画笔向前移到距离 turtle.left (TURTLE.FD) turtle.left (+) TURTLE.FD (turtle.penup) Turtle.goto (- 90,170) turtle.left (180) Turtle.down () for I in range (1,5): If I%2!=0:TURTLE.FD ($) ELSE:TURTLE.FD ) Turtle.left (all) for i in [ -90,90]: Turtle.penup () Turtle.goto (i,120) if I==-90:turtle.right (Else:turtle.left) Turtle.down () Turtle. FD (+) Turtle.left (TURTLE.FD) turtle.right (turtle.circle) Turtle.penup () Turtle.goto ( -60,-30) Turt Le.right (+) Turtle.pendown () turtle.fd (turtle.left) turtle.fd (turtle.penup) Turtle.goto Turtle.right (+) Turtle.pendown () turtle.fd (turtle.right) turtle.fd (+) Turtle.penup () Hide Brush #turtle.showturtle () #显示画笔turtle. BK #向后移到画笔turtle. PenColor (' red ') Turtle.dot #绘制一个半径为r的原点

The results are as follows

Python's graphical drawing turtle Library

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.