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