1-Python - 绘制小蟒蛇

效果

额!这个蟒蛇不太凶!

代码示例

import turtle
import time


def drawSnake(rad, angle, len, neckrad):
    for _ in range(len):
        turtle.circle(rad, angle)
        turtle.circle(-rad, angle)
    turtle.circle(rad, angle / 2)
    turtle.forward(rad / 2)  # 直线前进
    turtle.circle(neckrad, 180)
    turtle.forward(rad / 4)


if __name__ == "__main__":
    turtle.setup(1500, 1400, 0, 0)
    turtle.pensize(30)  # 画笔尺寸
    turtle.pencolor("green")
    turtle.seth(-40)  # 前进的方向
    drawSnake(70, 80, 2, 15)
    time.sleep(2)

that's all, see also:

10分钟轻松学会 Python turtle 绘图

posted @ 2019-02-26 18:05  听雨危楼  阅读(372)  评论(0编辑  收藏  举报