python图形绘制

import turtle


def drawSnake(rad,angle,len,nackrad):
    for i in range(len):
        turtle.circle(rad,angle)#rad:圆形轨迹半径的位置;angle:轨迹弧度值
        turtle.circle(-rad,angle)
    turtle.circle(rad,angle/2)
    turtle.fd(rad)#轨迹距离
    turtle.circle(neckrad+1,180)
    turtle.fd(rad*2/3)


def main():
    turtle.setup(1300,800,0,0)#弹窗:(宽度,高度,左上角的位置)
    pythonsize=30
    turtle.pensize(pythonsize)#(轨迹宽度)
    turtle.pencolor("blue")#轨迹颜色
    turtle.seth(-40)#初始方向,水平向右为0,逆时针360°,负数为反向
    drawSnake(40,80,5,pythonsize/2)#调用自定义函数



 

main()

python图形绘制_第1张图片

你可能感兴趣的:(Python)