python graphics drawing

import turtle


def drawSnake(rad,angle,len,nackrad):
    for i in range(len):
        turtle.circle(rad,angle)#rad: the position of the radius of the circular trajectory; angle: the radian value of the trajectory
        turtle.circle(- rad,angle)
    turtle.circle(rad,angle/2)
    turtle.fd(rad)#Track distance
    turtle.circle(neckrad+1,180)
    turtle.fd(rad*2/3)


def main():
    turtle.setup( 1300,800,0,0)#pop-up window: (width, height, upper left corner position)
    pythonsize=30
    turtle.pensize(pythonsize)#(track width)
    turtle.pencolor("blue")#track color
    turtle.seth (-40)#Initial direction, horizontal right is 0, counterclockwise 360°, negative number is reverse
    drawSnake(40,80,5,pythonsize/2)#Call custom function


main()


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326057994&siteId=291194637